documentation.d.ts 3.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690886918869288693886948869588696886978869888699887008870188702887038870488705887068870788708887098871088711887128871388714887158871688717887188871988720887218872288723887248872588726887278872888729887308873188732887338873488735887368873788738887398874088741887428874388744887458874688747887488874988750887518875288753887548875588756887578875888759887608876188762887638876488765887668876788768887698877088771887728877388774887758877688777887788877988780887818878288783887848878588786887878878888789887908879188792887938879488795887968879788798887998880088801888028880388804888058880688807888088880988810888118881288813888148881588816888178881888819888208882188822888238882488825888268882788828888298883088831888328883388834888358883688837888388883988840888418884288843888448884588846888478884888849888508885188852888538885488855888568885788858888598886088861888628886388864888658886688867888688886988870888718887288873888748887588876888778887888879888808888188882888838888488885888868888788888888898889088891888928889388894888958889688897888988889988900889018890288903889048890588906889078890888909889108891188912889138891488915889168891788918889198892088921889228892388924889258892688927889288892988930889318893288933889348893588936889378893888939889408894188942889438894488945889468894788948889498895088951889528895388954889558895688957889588895988960889618896288963889648896588966889678896888969889708897188972889738897488975889768897788978889798898088981889828898388984889858898688987889888898988990889918899288993889948899588996889978899888999890008900189002890038900489005890068900789008890098901089011890128901389014890158901689017890188901989020890218902289023890248902589026890278902889029890308903189032890338903489035890368903789038890398904089041890428904389044890458904689047890488904989050890518905289053890548905589056890578905889059890608906189062890638906489065890668906789068890698907089071890728907389074890758907689077890788907989080890818908289083890848908589086890878908889089890908909189092890938909489095890968909789098890998910089101891028910389104891058910689107891088910989110891118911289113891148911589116891178911889119891208912189122891238912489125891268912789128891298913089131891328913389134891358913689137891388913989140891418914289143891448914589146891478914889149891508915189152891538915489155891568915789158891598916089161891628916389164891658916689167891688916989170891718917289173891748917589176891778917889179891808918189182891838918489185891868918789188891898919089191891928919389194891958919689197891988919989200892018920289203892048920589206892078920889209892108921189212892138921489215892168921789218892198922089221892228922389224892258922689227892288922989230892318923289233892348923589236892378923889239892408924189242892438924489245892468924789248892498925089251892528925389254892558925689257892588925989260892618926289263892648926589266892678926889269892708927189272892738927489275892768927789278892798928089281892828928389284892858928689287892888928989290892918929289293892948929589296892978929889299893008930189302893038930489305893068930789308893098931089311893128931389314893158931689317893188931989320893218932289323893248932589326893278932889329893308933189332893338933489335893368933789338893398934089341893428934389344893458934689347893488934989350893518935289353893548935589356893578935889359893608936189362893638936489365893668936789368893698937089371893728937389374893758937689377893788937989380893818938289383893848938589386893878938889389893908939189392893938939489395893968939789398893998940089401894028940389404894058940689407894088940989410894118941289413894148941589416894178941889419894208942189422894238942489425894268942789428894298943089431894328943389434894358943689437894388943989440894418944289443894448944589446894478944889449894508945189452894538945489455894568945789458894598946089461894628946389464894658946689467894688946989470894718947289473894748947589476894778947889479894808948189482894838948489485894868948789488894898949089491894928949389494894958949689497894988949989500895018950289503895048950589506895078950889509895108951189512895138951489515895168951789518895198952089521895228952389524895258952689527895288952989530895318953289533895348953589536895378953889539895408954189542895438954489545895468954789548895498955089551895528955389554895558955689557895588955989560895618956289563895648956589566895678956889569895708957189572895738957489575895768957789578895798958089581895828958389584895858958689587895888958989590895918959289593895948959589596895978959889599896008960189602896038960489605896068960789608896098961089611896128961389614896158961689617896188961989620896218962289623896248962589626896278962889629896308963189632896338963489635896368963789638896398964089641896428964389644896458964689647896488964989650896518965289653896548965589656896578965889659896608966189662896638966489665896668966789668896698967089671896728967389674896758967689677896788967989680896818968289683896848968589686896878968889689896908969189692896938969489695896968969789698896998970089701897028970389704897058970689707897088970989710897118971289713897148971589716897178971889719897208972189722897238972489725897268972789728897298973089731897328973389734897358973689737897388973989740897418974289743897448974589746897478974889749897508975189752897538975489755897568975789758897598976089761897628976389764897658976689767897688976989770897718977289773897748977589776897778977889779897808978189782897838978489785897868978789788897898979089791897928979389794897958979689797897988979989800898018980289803898048980589806898078980889809898108981189812898138981489815898168981789818898198982089821898228982389824898258982689827898288982989830898318983289833898348983589836898378983889839898408984189842898438984489845898468984789848898498985089851898528985389854898558985689857898588985989860898618986289863898648986589866898678986889869898708987189872898738987489875898768987789878898798988089881898828988389884898858988689887898888988989890898918989289893898948989589896898978989889899899008990189902899038990489905899068990789908899098991089911899128991389914899158991689917899188991989920899218992289923899248992589926899278992889929899308993189932899338993489935899368993789938899398994089941899428994389944899458994689947899488994989950899518995289953899548995589956899578995889959899608996189962899638996489965899668996789968899698997089971899728997389974899758997689977899788997989980899818998289983899848998589986899878998889989899908999189992899938999489995899968999789998899999000090001900029000390004900059000690007900089000990010900119001290013900149001590016900179001890019900209002190022900239002490025900269002790028900299003090031900329003390034900359003690037900389003990040900419004290043900449004590046900479004890049900509005190052900539005490055900569005790058900599006090061900629006390064900659006690067900689006990070900719007290073900749007590076900779007890079900809008190082900839008490085900869008790088900899009090091900929009390094900959009690097900989009990100901019010290103901049010590106901079010890109901109011190112901139011490115901169011790118901199012090121901229012390124901259012690127901289012990130901319013290133901349013590136901379013890139901409014190142901439014490145901469014790148901499015090151901529015390154901559015690157901589015990160901619016290163901649016590166901679016890169901709017190172901739017490175901769017790178901799018090181901829018390184901859018690187901889018990190901919019290193901949019590196901979019890199902009020190202902039020490205902069020790208902099021090211902129021390214902159021690217902189021990220902219022290223902249022590226902279022890229902309023190232902339023490235902369023790238902399024090241902429024390244902459024690247902489024990250902519025290253902549025590256902579025890259902609026190262902639026490265902669026790268902699027090271902729027390274902759027690277902789027990280902819028290283902849028590286902879028890289902909029190292902939029490295902969029790298902999030090301903029030390304903059030690307903089030990310903119031290313903149031590316903179031890319903209032190322903239032490325903269032790328903299033090331903329033390334903359033690337903389033990340903419034290343903449034590346903479034890349903509035190352903539035490355903569035790358903599036090361903629036390364903659036690367903689036990370903719037290373903749037590376903779037890379903809038190382903839038490385903869038790388903899039090391903929039390394903959039690397903989039990400904019040290403904049040590406904079040890409904109041190412904139041490415904169041790418904199042090421904229042390424904259042690427904289042990430904319043290433904349043590436904379043890439904409044190442904439044490445904469044790448904499045090451904529045390454904559045690457904589045990460904619046290463904649046590466904679046890469904709047190472904739047490475904769047790478904799048090481904829048390484904859048690487904889048990490904919049290493904949049590496904979049890499905009050190502905039050490505905069050790508905099051090511905129051390514905159051690517905189051990520905219052290523905249052590526905279052890529905309053190532905339053490535905369053790538905399054090541905429054390544905459054690547905489054990550905519055290553905549055590556905579055890559905609056190562905639056490565905669056790568905699057090571905729057390574905759057690577905789057990580905819058290583905849058590586905879058890589905909059190592905939059490595905969059790598905999060090601906029060390604906059060690607906089060990610906119061290613906149061590616906179061890619906209062190622906239062490625906269062790628906299063090631906329063390634906359063690637906389063990640906419064290643906449064590646906479064890649906509065190652906539065490655906569065790658906599066090661906629066390664906659066690667906689066990670906719067290673906749067590676906779067890679906809068190682906839068490685906869068790688906899069090691906929069390694906959069690697906989069990700907019070290703907049070590706907079070890709907109071190712907139071490715907169071790718907199072090721907229072390724907259072690727907289072990730907319073290733907349073590736907379073890739907409074190742907439074490745907469074790748907499075090751907529075390754907559075690757907589075990760907619076290763907649076590766907679076890769907709077190772907739077490775907769077790778907799078090781907829078390784907859078690787907889078990790907919079290793907949079590796907979079890799908009080190802908039080490805908069080790808908099081090811908129081390814908159081690817908189081990820908219082290823908249082590826908279082890829908309083190832908339083490835908369083790838908399084090841908429084390844908459084690847908489084990850908519085290853908549085590856908579085890859908609086190862908639086490865908669086790868908699087090871908729087390874908759087690877908789087990880908819088290883908849088590886908879088890889908909089190892908939089490895908969089790898908999090090901909029090390904909059090690907909089090990910909119091290913909149091590916909179091890919909209092190922909239092490925909269092790928909299093090931909329093390934909359093690937909389093990940909419094290943909449094590946909479094890949909509095190952909539095490955909569095790958909599096090961909629096390964909659096690967909689096990970909719097290973909749097590976909779097890979909809098190982909839098490985909869098790988909899099090991909929099390994909959099690997909989099991000910019100291003910049100591006910079100891009910109101191012910139101491015910169101791018910199102091021910229102391024910259102691027910289102991030910319103291033910349103591036910379103891039910409104191042910439104491045910469104791048910499105091051910529105391054910559105691057910589105991060910619106291063910649106591066910679106891069910709107191072910739107491075910769107791078910799108091081910829108391084910859108691087910889108991090910919109291093910949109591096910979109891099911009110191102911039110491105911069110791108911099111091111911129111391114911159111691117911189111991120911219112291123911249112591126911279112891129911309113191132911339113491135911369113791138911399114091141911429114391144911459114691147911489114991150911519115291153911549115591156911579115891159911609116191162911639116491165911669116791168911699117091171911729117391174911759117691177911789117991180911819118291183911849118591186911879118891189911909119191192911939119491195911969119791198911999120091201912029120391204912059120691207912089120991210912119121291213912149121591216912179121891219912209122191222912239122491225912269122791228912299123091231912329123391234912359123691237912389123991240912419124291243912449124591246912479124891249912509125191252912539125491255912569125791258912599126091261912629126391264912659126691267912689126991270912719127291273912749127591276912779127891279912809128191282912839128491285912869128791288912899129091291912929129391294912959129691297912989129991300913019130291303913049130591306913079130891309913109131191312913139131491315913169131791318913199132091321913229132391324913259132691327913289132991330913319133291333913349133591336913379133891339913409134191342913439134491345913469134791348913499135091351913529135391354913559135691357913589135991360913619136291363913649136591366913679136891369913709137191372913739137491375913769137791378913799138091381913829138391384913859138691387913889138991390913919139291393913949139591396913979139891399914009140191402914039140491405914069140791408914099141091411914129141391414914159141691417914189141991420914219142291423914249142591426914279142891429914309143191432914339143491435914369143791438914399144091441914429144391444914459144691447914489144991450914519145291453914549145591456914579145891459914609146191462914639146491465914669146791468914699147091471914729147391474914759147691477914789147991480914819148291483914849148591486914879148891489914909149191492914939149491495914969149791498914999150091501915029150391504915059150691507915089150991510915119151291513915149151591516915179151891519915209152191522915239152491525915269152791528915299153091531915329153391534915359153691537915389153991540915419154291543915449154591546915479154891549915509155191552915539155491555915569155791558915599156091561915629156391564915659156691567915689156991570915719157291573915749157591576915779157891579915809158191582915839158491585915869158791588915899159091591915929159391594915959159691597915989159991600916019160291603916049160591606916079160891609916109161191612916139161491615916169161791618916199162091621916229162391624916259162691627916289162991630916319163291633916349163591636916379163891639916409164191642916439164491645916469164791648916499165091651916529165391654916559165691657916589165991660916619166291663916649166591666916679166891669916709167191672916739167491675916769167791678916799168091681916829168391684916859168691687916889168991690916919169291693916949169591696916979169891699917009170191702917039170491705917069170791708917099171091711917129171391714917159171691717917189171991720917219172291723917249172591726917279172891729917309173191732917339173491735917369173791738917399174091741917429174391744917459174691747917489174991750917519175291753917549175591756917579175891759917609176191762917639176491765917669176791768917699177091771917729177391774917759177691777917789177991780917819178291783917849178591786917879178891789917909179191792917939179491795917969179791798917999180091801918029180391804918059180691807918089180991810918119181291813918149181591816918179181891819918209182191822918239182491825918269182791828918299183091831918329183391834918359183691837918389183991840918419184291843918449184591846918479184891849918509185191852918539185491855918569185791858918599186091861918629186391864918659186691867918689186991870918719187291873918749187591876918779187891879918809188191882918839188491885918869188791888918899189091891918929189391894918959189691897918989189991900919019190291903919049190591906919079190891909919109191191912919139191491915919169191791918919199192091921919229192391924919259192691927919289192991930919319193291933919349193591936919379193891939919409194191942919439194491945919469194791948919499195091951919529195391954919559195691957919589195991960919619196291963919649196591966919679196891969919709197191972919739197491975919769197791978919799198091981919829198391984919859198691987919889198991990919919199291993919949199591996919979199891999920009200192002920039200492005920069200792008920099201092011920129201392014920159201692017920189201992020920219202292023920249202592026920279202892029920309203192032920339203492035920369203792038920399204092041920429204392044920459204692047920489204992050920519205292053920549205592056920579205892059920609206192062920639206492065920669206792068920699207092071920729207392074920759207692077920789207992080920819208292083920849208592086920879208892089920909209192092920939209492095920969209792098920999210092101921029210392104921059210692107921089210992110921119211292113921149211592116921179211892119921209212192122921239212492125921269212792128921299213092131921329213392134921359213692137921389213992140921419214292143921449214592146921479214892149921509215192152921539215492155921569215792158921599216092161921629216392164921659216692167921689216992170921719217292173921749217592176921779217892179921809218192182921839218492185921869218792188921899219092191921929219392194921959219692197921989219992200922019220292203922049220592206922079220892209922109221192212922139221492215922169221792218922199222092221922229222392224922259222692227922289222992230922319223292233922349223592236922379223892239922409224192242922439224492245922469224792248922499225092251922529225392254922559225692257922589225992260922619226292263922649226592266922679226892269922709227192272922739227492275922769227792278922799228092281922829228392284922859228692287922889228992290922919229292293922949229592296922979229892299923009230192302923039230492305923069230792308923099231092311923129231392314923159231692317923189231992320923219232292323923249232592326923279232892329923309233192332923339233492335923369233792338923399234092341923429234392344923459234692347923489234992350923519235292353923549235592356923579235892359923609236192362923639236492365923669236792368923699237092371923729237392374923759237692377923789237992380923819238292383923849238592386923879238892389923909239192392923939239492395923969239792398923999240092401924029240392404924059240692407924089240992410924119241292413924149241592416924179241892419924209242192422924239242492425924269242792428924299243092431924329243392434924359243692437924389243992440924419244292443924449244592446924479244892449924509245192452924539245492455924569245792458924599246092461924629246392464924659246692467924689246992470924719247292473924749247592476924779247892479924809248192482924839248492485924869248792488924899249092491924929249392494924959249692497924989249992500925019250292503925049250592506925079250892509925109251192512925139251492515925169251792518925199252092521925229252392524925259252692527925289252992530925319253292533925349253592536925379253892539925409254192542925439254492545925469254792548925499255092551925529255392554925559255692557925589255992560925619256292563925649256592566925679256892569925709257192572925739257492575925769257792578925799258092581925829258392584925859258692587925889258992590925919259292593925949259592596925979259892599926009260192602926039260492605926069260792608926099261092611926129261392614926159261692617926189261992620926219262292623926249262592626926279262892629926309263192632926339263492635926369263792638926399264092641926429264392644926459264692647926489264992650926519265292653926549265592656926579265892659926609266192662926639266492665926669266792668926699267092671926729267392674926759267692677926789267992680926819268292683926849268592686926879268892689926909269192692926939269492695926969269792698926999270092701927029270392704927059270692707927089270992710927119271292713927149271592716927179271892719927209272192722927239272492725927269272792728927299273092731927329273392734927359273692737927389273992740927419274292743927449274592746927479274892749927509275192752927539275492755927569275792758927599276092761927629276392764927659276692767927689276992770927719277292773927749277592776927779277892779927809278192782927839278492785927869278792788927899279092791927929279392794927959279692797927989279992800928019280292803928049280592806928079280892809928109281192812928139281492815928169281792818928199282092821928229282392824928259282692827928289282992830928319283292833928349283592836928379283892839928409284192842928439284492845928469284792848928499285092851928529285392854928559285692857928589285992860928619286292863928649286592866928679286892869928709287192872928739287492875928769287792878928799288092881928829288392884928859288692887928889288992890928919289292893928949289592896928979289892899929009290192902929039290492905929069290792908929099291092911929129291392914929159291692917929189291992920929219292292923929249292592926929279292892929929309293192932929339293492935929369293792938929399294092941929429294392944929459294692947929489294992950929519295292953929549295592956929579295892959929609296192962929639296492965929669296792968929699297092971929729297392974929759297692977929789297992980929819298292983929849298592986929879298892989929909299192992929939299492995929969299792998929999300093001930029300393004930059300693007930089300993010930119301293013930149301593016930179301893019930209302193022930239302493025930269302793028930299303093031930329303393034930359303693037930389303993040930419304293043930449304593046930479304893049930509305193052930539305493055930569305793058930599306093061930629306393064930659306693067930689306993070930719307293073930749307593076930779307893079930809308193082930839308493085930869308793088930899309093091930929309393094930959309693097930989309993100931019310293103931049310593106931079310893109931109311193112931139311493115931169311793118931199312093121931229312393124931259312693127931289312993130931319313293133931349313593136931379313893139931409314193142931439314493145931469314793148931499315093151931529315393154931559315693157931589315993160931619316293163931649316593166931679316893169931709317193172931739317493175931769317793178931799318093181931829318393184931859318693187931889318993190931919319293193931949319593196931979319893199932009320193202932039320493205932069320793208932099321093211932129321393214932159321693217932189321993220932219322293223932249322593226932279322893229932309323193232932339323493235932369323793238932399324093241932429324393244932459324693247932489324993250932519325293253932549325593256932579325893259932609326193262932639326493265932669326793268932699327093271932729327393274932759327693277932789327993280932819328293283932849328593286932879328893289932909329193292932939329493295932969329793298932999330093301933029330393304933059330693307933089330993310933119331293313933149331593316933179331893319933209332193322933239332493325933269332793328933299333093331933329333393334933359333693337933389333993340933419334293343933449334593346933479334893349933509335193352933539335493355933569335793358933599336093361933629336393364933659336693367933689336993370933719337293373933749337593376933779337893379933809338193382933839338493385933869338793388933899339093391933929339393394933959339693397933989339993400934019340293403934049340593406934079340893409934109341193412934139341493415934169341793418934199342093421934229342393424934259342693427934289342993430934319343293433934349343593436934379343893439934409344193442934439344493445934469344793448934499345093451934529345393454934559345693457934589345993460934619346293463934649346593466934679346893469934709347193472934739347493475934769347793478934799348093481934829348393484934859348693487934889348993490934919349293493934949349593496934979349893499935009350193502935039350493505935069350793508935099351093511935129351393514935159351693517935189351993520935219352293523935249352593526935279352893529935309353193532935339353493535935369353793538935399354093541935429354393544935459354693547935489354993550935519355293553935549355593556935579355893559935609356193562935639356493565935669356793568935699357093571935729357393574935759357693577935789357993580935819358293583935849358593586935879358893589935909359193592935939359493595935969359793598935999360093601936029360393604936059360693607936089360993610936119361293613936149361593616936179361893619936209362193622936239362493625936269362793628936299363093631936329363393634936359363693637936389363993640936419364293643936449364593646936479364893649936509365193652936539365493655936569365793658936599366093661936629366393664936659366693667936689366993670936719367293673936749367593676936779367893679936809368193682936839368493685936869368793688936899369093691936929369393694936959369693697936989369993700937019370293703937049370593706937079370893709937109371193712937139371493715937169371793718937199372093721937229372393724937259372693727937289372993730937319373293733937349373593736937379373893739937409374193742937439374493745937469374793748937499375093751937529375393754937559375693757937589375993760937619376293763937649376593766937679376893769937709377193772937739377493775937769377793778937799378093781937829378393784937859378693787937889378993790937919379293793937949379593796937979379893799938009380193802938039380493805938069380793808938099381093811938129381393814938159381693817938189381993820938219382293823938249382593826938279382893829938309383193832938339383493835938369383793838938399384093841938429384393844938459384693847938489384993850938519385293853938549385593856938579385893859938609386193862938639386493865938669386793868938699387093871938729387393874938759387693877938789387993880938819388293883938849388593886938879388893889938909389193892938939389493895938969389793898938999390093901939029390393904939059390693907939089390993910939119391293913939149391593916939179391893919939209392193922939239392493925939269392793928939299393093931939329393393934939359393693937939389393993940939419394293943939449394593946939479394893949939509395193952939539395493955939569395793958939599396093961939629396393964939659396693967939689396993970939719397293973939749397593976
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used throughout the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependencies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the resource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the resource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the resource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the resource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailed logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTH_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTH_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve normal index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_NORMAL_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_NORMAL_TEXTURE_TYPE: number;
  1130. /**
  1131. * Constant used to retrieve albedo index in the textures array in the prepass
  1132. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1133. */
  1134. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1135. /**
  1136. * Prefixes used by the engine for custom effects
  1137. */
  1138. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1139. }
  1140. }
  1141. declare module BABYLON {
  1142. /** @hidden */
  1143. export interface HardwareTextureWrapper {
  1144. underlyingResource: any;
  1145. set(hardwareTexture: any): void;
  1146. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1147. reset(): void;
  1148. release(): void;
  1149. }
  1150. }
  1151. declare module BABYLON {
  1152. /**
  1153. * This represents the required contract to create a new type of texture loader.
  1154. */
  1155. export interface IInternalTextureLoader {
  1156. /**
  1157. * Defines whether the loader supports cascade loading the different faces.
  1158. */
  1159. supportCascades: boolean;
  1160. /**
  1161. * This returns if the loader support the current file information.
  1162. * @param extension defines the file extension of the file being loaded
  1163. * @param mimeType defines the optional mime type of the file being loaded
  1164. * @returns true if the loader can load the specified file
  1165. */
  1166. canLoad(extension: string, mimeType?: string): boolean;
  1167. /**
  1168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1169. * @param data contains the texture data
  1170. * @param texture defines the BabylonJS internal texture
  1171. * @param createPolynomials will be true if polynomials have been requested
  1172. * @param onLoad defines the callback to trigger once the texture is ready
  1173. * @param onError defines the callback to trigger in case of error
  1174. * @param options options to be passed to the loader
  1175. */
  1176. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1177. /**
  1178. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1179. * @param data contains the texture data
  1180. * @param texture defines the BabylonJS internal texture
  1181. * @param callback defines the method to call once ready to upload
  1182. * @param options options to be passed to the loader
  1183. */
  1184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /**
  1189. * @hidden
  1190. */
  1191. export interface IColor4Like {
  1192. r: float;
  1193. g: float;
  1194. b: float;
  1195. a: float;
  1196. }
  1197. /**
  1198. * @hidden
  1199. */
  1200. export interface IColor3Like {
  1201. r: float;
  1202. g: float;
  1203. b: float;
  1204. }
  1205. /**
  1206. * @hidden
  1207. */
  1208. export interface IVector4Like {
  1209. x: float;
  1210. y: float;
  1211. z: float;
  1212. w: float;
  1213. }
  1214. /**
  1215. * @hidden
  1216. */
  1217. export interface IVector3Like {
  1218. x: float;
  1219. y: float;
  1220. z: float;
  1221. }
  1222. /**
  1223. * @hidden
  1224. */
  1225. export interface IVector2Like {
  1226. x: float;
  1227. y: float;
  1228. }
  1229. /**
  1230. * @hidden
  1231. */
  1232. export interface IMatrixLike {
  1233. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1234. updateFlag: int;
  1235. }
  1236. /**
  1237. * @hidden
  1238. */
  1239. export interface IViewportLike {
  1240. x: float;
  1241. y: float;
  1242. width: float;
  1243. height: float;
  1244. }
  1245. /**
  1246. * @hidden
  1247. */
  1248. export interface IPlaneLike {
  1249. normal: IVector3Like;
  1250. d: float;
  1251. normalize(): void;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /**
  1256. * Class used to store and describe the pipeline context associated with an effect
  1257. */
  1258. export interface IPipelineContext {
  1259. /**
  1260. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1261. */
  1262. isAsync: boolean;
  1263. /**
  1264. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1265. */
  1266. isReady: boolean;
  1267. /** @hidden */
  1268. _name?: string;
  1269. /** @hidden */
  1270. _getVertexShaderCode(): string | null;
  1271. /** @hidden */
  1272. _getFragmentShaderCode(): string | null;
  1273. /** @hidden */
  1274. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1275. /** @hidden */
  1276. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1277. [key: string]: number;
  1278. }, uniformsNames: string[], uniforms: {
  1279. [key: string]: Nullable<WebGLUniformLocation>;
  1280. }, samplerList: string[], samplers: {
  1281. [key: string]: number;
  1282. }, attributesNames: string[], attributes: number[]): void;
  1283. /** Releases the resources associated with the pipeline. */
  1284. dispose(): void;
  1285. /**
  1286. * Sets an integer value on a uniform variable.
  1287. * @param uniformName Name of the variable.
  1288. * @param value Value to be set.
  1289. */
  1290. setInt(uniformName: string, value: number): void;
  1291. /**
  1292. * Sets an int2 value on a uniform variable.
  1293. * @param uniformName Name of the variable.
  1294. * @param x First int in int2.
  1295. * @param y Second int in int2.
  1296. */
  1297. setInt2(uniformName: string, x: number, y: number): void;
  1298. /**
  1299. * Sets an int3 value on a uniform variable.
  1300. * @param uniformName Name of the variable.
  1301. * @param x First int in int3.
  1302. * @param y Second int in int3.
  1303. * @param z Third int in int3.
  1304. */
  1305. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1306. /**
  1307. * Sets an int4 value on a uniform variable.
  1308. * @param uniformName Name of the variable.
  1309. * @param x First int in int4.
  1310. * @param y Second int in int4.
  1311. * @param z Third int in int4.
  1312. * @param w Fourth int in int4.
  1313. */
  1314. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1315. /**
  1316. * Sets an int array on a uniform variable.
  1317. * @param uniformName Name of the variable.
  1318. * @param array array to be set.
  1319. */
  1320. setIntArray(uniformName: string, array: Int32Array): void;
  1321. /**
  1322. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1323. * @param uniformName Name of the variable.
  1324. * @param array array to be set.
  1325. */
  1326. setIntArray2(uniformName: string, array: Int32Array): void;
  1327. /**
  1328. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1329. * @param uniformName Name of the variable.
  1330. * @param array array to be set.
  1331. */
  1332. setIntArray3(uniformName: string, array: Int32Array): void;
  1333. /**
  1334. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1335. * @param uniformName Name of the variable.
  1336. * @param array array to be set.
  1337. */
  1338. setIntArray4(uniformName: string, array: Int32Array): void;
  1339. /**
  1340. * Sets an array on a uniform variable.
  1341. * @param uniformName Name of the variable.
  1342. * @param array array to be set.
  1343. */
  1344. setArray(uniformName: string, array: number[] | Float32Array): void;
  1345. /**
  1346. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1347. * @param uniformName Name of the variable.
  1348. * @param array array to be set.
  1349. */
  1350. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1351. /**
  1352. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1353. * @param uniformName Name of the variable.
  1354. * @param array array to be set.
  1355. */
  1356. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1357. /**
  1358. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1359. * @param uniformName Name of the variable.
  1360. * @param array array to be set.
  1361. */
  1362. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1363. /**
  1364. * Sets matrices on a uniform variable.
  1365. * @param uniformName Name of the variable.
  1366. * @param matrices matrices to be set.
  1367. */
  1368. setMatrices(uniformName: string, matrices: Float32Array): void;
  1369. /**
  1370. * Sets matrix on a uniform variable.
  1371. * @param uniformName Name of the variable.
  1372. * @param matrix matrix to be set.
  1373. */
  1374. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1375. /**
  1376. * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1377. * @param uniformName Name of the variable.
  1378. * @param matrix matrix to be set.
  1379. */
  1380. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1381. /**
  1382. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1383. * @param uniformName Name of the variable.
  1384. * @param matrix matrix to be set.
  1385. */
  1386. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1387. /**
  1388. * Sets a float on a uniform variable.
  1389. * @param uniformName Name of the variable.
  1390. * @param value value to be set.
  1391. */
  1392. setFloat(uniformName: string, value: number): void;
  1393. /**
  1394. * Sets a Vector2 on a uniform variable.
  1395. * @param uniformName Name of the variable.
  1396. * @param vector2 vector2 to be set.
  1397. */
  1398. setVector2(uniformName: string, vector2: IVector2Like): void;
  1399. /**
  1400. * Sets a float2 on a uniform variable.
  1401. * @param uniformName Name of the variable.
  1402. * @param x First float in float2.
  1403. * @param y Second float in float2.
  1404. */
  1405. setFloat2(uniformName: string, x: number, y: number): void;
  1406. /**
  1407. * Sets a Vector3 on a uniform variable.
  1408. * @param uniformName Name of the variable.
  1409. * @param vector3 Value to be set.
  1410. */
  1411. setVector3(uniformName: string, vector3: IVector3Like): void;
  1412. /**
  1413. * Sets a float3 on a uniform variable.
  1414. * @param uniformName Name of the variable.
  1415. * @param x First float in float3.
  1416. * @param y Second float in float3.
  1417. * @param z Third float in float3.
  1418. */
  1419. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1420. /**
  1421. * Sets a Vector4 on a uniform variable.
  1422. * @param uniformName Name of the variable.
  1423. * @param vector4 Value to be set.
  1424. */
  1425. setVector4(uniformName: string, vector4: IVector4Like): void;
  1426. /**
  1427. * Sets a float4 on a uniform variable.
  1428. * @param uniformName Name of the variable.
  1429. * @param x First float in float4.
  1430. * @param y Second float in float4.
  1431. * @param z Third float in float4.
  1432. * @param w Fourth float in float4.
  1433. */
  1434. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1435. /**
  1436. * Sets a Color3 on a uniform variable.
  1437. * @param uniformName Name of the variable.
  1438. * @param color3 Value to be set.
  1439. */
  1440. setColor3(uniformName: string, color3: IColor3Like): void;
  1441. /**
  1442. * Sets a Color4 on a uniform variable.
  1443. * @param uniformName Name of the variable.
  1444. * @param color3 Value to be set.
  1445. * @param alpha Alpha value to be set.
  1446. */
  1447. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1448. /**
  1449. * Sets a Color4 on a uniform variable
  1450. * @param uniformName defines the name of the variable
  1451. * @param color4 defines the value to be set
  1452. */
  1453. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1454. }
  1455. }
  1456. declare module BABYLON {
  1457. /**
  1458. * Class used to store gfx data (like WebGLBuffer)
  1459. */
  1460. export class DataBuffer {
  1461. private static _Counter;
  1462. /**
  1463. * Gets or sets the number of objects referencing this buffer
  1464. */
  1465. references: number;
  1466. /** Gets or sets the size of the underlying buffer */
  1467. capacity: number;
  1468. /**
  1469. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1470. */
  1471. is32Bits: boolean;
  1472. /**
  1473. * Gets the underlying buffer
  1474. */
  1475. get underlyingResource(): any;
  1476. /**
  1477. * Gets the unique id of this buffer
  1478. */
  1479. readonly uniqueId: number;
  1480. /**
  1481. * Constructs the buffer
  1482. */
  1483. constructor();
  1484. }
  1485. }
  1486. declare module BABYLON {
  1487. /** @hidden */
  1488. export interface IShaderProcessor {
  1489. attributeProcessor?: (attribute: string, preProcessors: {
  1490. [key: string]: string;
  1491. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1492. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1493. [key: string]: string;
  1494. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1495. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1496. [key: string]: string;
  1497. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1498. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1499. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1500. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1501. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1502. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1503. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1504. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1505. vertexCode: string;
  1506. fragmentCode: string;
  1507. };
  1508. }
  1509. }
  1510. declare module BABYLON {
  1511. /** @hidden */
  1512. export interface ShaderProcessingContext {
  1513. }
  1514. /** @hidden */
  1515. export interface ProcessingOptions {
  1516. defines: string[];
  1517. indexParameters: any;
  1518. isFragment: boolean;
  1519. shouldUseHighPrecisionShader: boolean;
  1520. supportsUniformBuffers: boolean;
  1521. shadersRepository: string;
  1522. includesShadersStore: {
  1523. [key: string]: string;
  1524. };
  1525. processor: Nullable<IShaderProcessor>;
  1526. version: string;
  1527. platformName: string;
  1528. lookForClosingBracketForUniformBuffer?: boolean;
  1529. processingContext: Nullable<ShaderProcessingContext>;
  1530. }
  1531. }
  1532. declare module BABYLON {
  1533. /** @hidden */
  1534. export class ShaderCodeNode {
  1535. line: string;
  1536. children: ShaderCodeNode[];
  1537. additionalDefineKey?: string;
  1538. additionalDefineValue?: string;
  1539. isValid(preprocessors: {
  1540. [key: string]: string;
  1541. }): boolean;
  1542. process(preprocessors: {
  1543. [key: string]: string;
  1544. }, options: ProcessingOptions): string;
  1545. }
  1546. }
  1547. declare module BABYLON {
  1548. /** @hidden */
  1549. export class ShaderCodeCursor {
  1550. private _lines;
  1551. lineIndex: number;
  1552. get currentLine(): string;
  1553. get canRead(): boolean;
  1554. set lines(value: string[]);
  1555. }
  1556. }
  1557. declare module BABYLON {
  1558. /** @hidden */
  1559. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1560. process(preprocessors: {
  1561. [key: string]: string;
  1562. }, options: ProcessingOptions): string;
  1563. }
  1564. }
  1565. declare module BABYLON {
  1566. /** @hidden */
  1567. export class ShaderDefineExpression {
  1568. isTrue(preprocessors: {
  1569. [key: string]: string;
  1570. }): boolean;
  1571. private static _OperatorPriority;
  1572. private static _Stack;
  1573. static postfixToInfix(postfix: string[]): string;
  1574. static infixToPostfix(infix: string): string[];
  1575. }
  1576. }
  1577. declare module BABYLON {
  1578. /** @hidden */
  1579. export class ShaderCodeTestNode extends ShaderCodeNode {
  1580. testExpression: ShaderDefineExpression;
  1581. isValid(preprocessors: {
  1582. [key: string]: string;
  1583. }): boolean;
  1584. }
  1585. }
  1586. declare module BABYLON {
  1587. /** @hidden */
  1588. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1589. define: string;
  1590. not: boolean;
  1591. constructor(define: string, not?: boolean);
  1592. isTrue(preprocessors: {
  1593. [key: string]: string;
  1594. }): boolean;
  1595. }
  1596. }
  1597. declare module BABYLON {
  1598. /** @hidden */
  1599. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1600. leftOperand: ShaderDefineExpression;
  1601. rightOperand: ShaderDefineExpression;
  1602. isTrue(preprocessors: {
  1603. [key: string]: string;
  1604. }): boolean;
  1605. }
  1606. }
  1607. declare module BABYLON {
  1608. /** @hidden */
  1609. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1610. leftOperand: ShaderDefineExpression;
  1611. rightOperand: ShaderDefineExpression;
  1612. isTrue(preprocessors: {
  1613. [key: string]: string;
  1614. }): boolean;
  1615. }
  1616. }
  1617. declare module BABYLON {
  1618. /** @hidden */
  1619. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1620. define: string;
  1621. operand: string;
  1622. testValue: string;
  1623. constructor(define: string, operand: string, testValue: string);
  1624. isTrue(preprocessors: {
  1625. [key: string]: string;
  1626. }): boolean;
  1627. }
  1628. }
  1629. declare module BABYLON {
  1630. /**
  1631. * Class used to enable access to offline support
  1632. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1633. */
  1634. export interface IOfflineProvider {
  1635. /**
  1636. * Gets a boolean indicating if scene must be saved in the database
  1637. */
  1638. enableSceneOffline: boolean;
  1639. /**
  1640. * Gets a boolean indicating if textures must be saved in the database
  1641. */
  1642. enableTexturesOffline: boolean;
  1643. /**
  1644. * Open the offline support and make it available
  1645. * @param successCallback defines the callback to call on success
  1646. * @param errorCallback defines the callback to call on error
  1647. */
  1648. open(successCallback: () => void, errorCallback: () => void): void;
  1649. /**
  1650. * Loads an image from the offline support
  1651. * @param url defines the url to load from
  1652. * @param image defines the target DOM image
  1653. */
  1654. loadImage(url: string, image: HTMLImageElement): void;
  1655. /**
  1656. * Loads a file from offline support
  1657. * @param url defines the URL to load from
  1658. * @param sceneLoaded defines a callback to call on success
  1659. * @param progressCallBack defines a callback to call when progress changed
  1660. * @param errorCallback defines a callback to call on error
  1661. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1662. */
  1663. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to help managing file picking and drag'n'drop
  1669. * File Storage
  1670. */
  1671. export class FilesInputStore {
  1672. /**
  1673. * List of files ready to be loaded
  1674. */
  1675. static FilesToLoad: {
  1676. [key: string]: File;
  1677. };
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Class used to define a retry strategy when error happens while loading assets
  1683. */
  1684. export class RetryStrategy {
  1685. /**
  1686. * Function used to defines an exponential back off strategy
  1687. * @param maxRetries defines the maximum number of retries (3 by default)
  1688. * @param baseInterval defines the interval between retries
  1689. * @returns the strategy function to use
  1690. */
  1691. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1692. }
  1693. }
  1694. declare module BABYLON {
  1695. /**
  1696. * @ignore
  1697. * Application error to support additional information when loading a file
  1698. */
  1699. export abstract class BaseError extends Error {
  1700. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1701. }
  1702. }
  1703. declare module BABYLON {
  1704. /** @ignore */
  1705. export class LoadFileError extends BaseError {
  1706. request?: WebRequest;
  1707. file?: File;
  1708. /**
  1709. * Creates a new LoadFileError
  1710. * @param message defines the message of the error
  1711. * @param request defines the optional web request
  1712. * @param file defines the optional file
  1713. */
  1714. constructor(message: string, object?: WebRequest | File);
  1715. }
  1716. /** @ignore */
  1717. export class RequestFileError extends BaseError {
  1718. request: WebRequest;
  1719. /**
  1720. * Creates a new LoadFileError
  1721. * @param message defines the message of the error
  1722. * @param request defines the optional web request
  1723. */
  1724. constructor(message: string, request: WebRequest);
  1725. }
  1726. /** @ignore */
  1727. export class ReadFileError extends BaseError {
  1728. file: File;
  1729. /**
  1730. * Creates a new ReadFileError
  1731. * @param message defines the message of the error
  1732. * @param file defines the optional file
  1733. */
  1734. constructor(message: string, file: File);
  1735. }
  1736. /**
  1737. * @hidden
  1738. */
  1739. export class FileTools {
  1740. /**
  1741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1742. */
  1743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1744. /**
  1745. * Gets or sets the base URL to use to load assets
  1746. */
  1747. static BaseUrl: string;
  1748. /**
  1749. * Default behaviour for cors in the application.
  1750. * It can be a string if the expected behavior is identical in the entire app.
  1751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1752. */
  1753. static CorsBehavior: string | ((url: string | string[]) => string);
  1754. /**
  1755. * Gets or sets a function used to pre-process url before using them to load assets
  1756. */
  1757. static PreprocessUrl: (url: string) => string;
  1758. /**
  1759. * Removes unwanted characters from an url
  1760. * @param url defines the url to clean
  1761. * @returns the cleaned url
  1762. */
  1763. private static _CleanUrl;
  1764. /**
  1765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1766. * @param url define the url we are trying
  1767. * @param element define the dom element where to configure the cors policy
  1768. */
  1769. static SetCorsBehavior(url: string | string[], element: {
  1770. crossOrigin: string | null;
  1771. }): void;
  1772. /**
  1773. * Loads an image as an HTMLImageElement.
  1774. * @param input url string, ArrayBuffer, or Blob to load
  1775. * @param onLoad callback called when the image successfully loads
  1776. * @param onError callback called when the image fails to load
  1777. * @param offlineProvider offline provider for caching
  1778. * @param mimeType optional mime type
  1779. * @returns the HTMLImageElement of the loaded image
  1780. */
  1781. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1782. /**
  1783. * Reads a file from a File object
  1784. * @param file defines the file to load
  1785. * @param onSuccess defines the callback to call when data is loaded
  1786. * @param onProgress defines the callback to call during loading process
  1787. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1788. * @param onError defines the callback to call when an error occurs
  1789. * @returns a file request object
  1790. */
  1791. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1792. /**
  1793. * Loads a file from a url
  1794. * @param url url to load
  1795. * @param onSuccess callback called when the file successfully loads
  1796. * @param onProgress callback called while file is loading (if the server supports this mode)
  1797. * @param offlineProvider defines the offline provider for caching
  1798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1799. * @param onError callback called when the file fails to load
  1800. * @returns a file request object
  1801. */
  1802. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1803. /**
  1804. * Loads a file
  1805. * @param url url to load
  1806. * @param onSuccess callback called when the file successfully loads
  1807. * @param onProgress callback called while file is loading (if the server supports this mode)
  1808. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1809. * @param onError callback called when the file fails to load
  1810. * @param onOpened callback called when the web request is opened
  1811. * @returns a file request object
  1812. */
  1813. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1814. /**
  1815. * Checks if the loaded document was accessed via `file:`-Protocol.
  1816. * @returns boolean
  1817. */
  1818. static IsFileURL(): boolean;
  1819. }
  1820. }
  1821. declare module BABYLON {
  1822. /** @hidden */
  1823. export class ShaderProcessor {
  1824. static Initialize(options: ProcessingOptions): void;
  1825. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1826. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1827. vertexCode: string;
  1828. fragmentCode: string;
  1829. };
  1830. private static _ProcessPrecision;
  1831. private static _ExtractOperation;
  1832. private static _BuildSubExpression;
  1833. private static _BuildExpression;
  1834. private static _MoveCursorWithinIf;
  1835. private static _MoveCursor;
  1836. private static _EvaluatePreProcessors;
  1837. private static _PreparePreProcessors;
  1838. private static _ProcessShaderConversion;
  1839. private static _ProcessIncludes;
  1840. /**
  1841. * Loads a file from a url
  1842. * @param url url to load
  1843. * @param onSuccess callback called when the file successfully loads
  1844. * @param onProgress callback called while file is loading (if the server supports this mode)
  1845. * @param offlineProvider defines the offline provider for caching
  1846. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1847. * @param onError callback called when the file fails to load
  1848. * @returns a file request object
  1849. * @hidden
  1850. */
  1851. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1852. }
  1853. }
  1854. declare module BABYLON {
  1855. /**
  1856. * Interface used to define common properties for effect fallbacks
  1857. */
  1858. export interface IEffectFallbacks {
  1859. /**
  1860. * Removes the defines that should be removed when falling back.
  1861. * @param currentDefines defines the current define statements for the shader.
  1862. * @param effect defines the current effect we try to compile
  1863. * @returns The resulting defines with defines of the current rank removed.
  1864. */
  1865. reduce(currentDefines: string, effect: Effect): string;
  1866. /**
  1867. * Removes the fallback from the bound mesh.
  1868. */
  1869. unBindMesh(): void;
  1870. /**
  1871. * Checks to see if more fallbacks are still available.
  1872. */
  1873. hasMoreFallbacks: boolean;
  1874. }
  1875. }
  1876. declare module BABYLON {
  1877. /**
  1878. * Interface for the size containing width and height
  1879. */
  1880. export interface ISize {
  1881. /**
  1882. * Width
  1883. */
  1884. width: number;
  1885. /**
  1886. * Heighht
  1887. */
  1888. height: number;
  1889. }
  1890. /**
  1891. * Size containing widht and height
  1892. */
  1893. export class Size implements ISize {
  1894. /**
  1895. * Width
  1896. */
  1897. width: number;
  1898. /**
  1899. * Height
  1900. */
  1901. height: number;
  1902. /**
  1903. * Creates a Size object from the given width and height (floats).
  1904. * @param width width of the new size
  1905. * @param height height of the new size
  1906. */
  1907. constructor(width: number, height: number);
  1908. /**
  1909. * Returns a string with the Size width and height
  1910. * @returns a string with the Size width and height
  1911. */
  1912. toString(): string;
  1913. /**
  1914. * "Size"
  1915. * @returns the string "Size"
  1916. */
  1917. getClassName(): string;
  1918. /**
  1919. * Returns the Size hash code.
  1920. * @returns a hash code for a unique width and height
  1921. */
  1922. getHashCode(): number;
  1923. /**
  1924. * Updates the current size from the given one.
  1925. * @param src the given size
  1926. */
  1927. copyFrom(src: Size): void;
  1928. /**
  1929. * Updates in place the current Size from the given floats.
  1930. * @param width width of the new size
  1931. * @param height height of the new size
  1932. * @returns the updated Size.
  1933. */
  1934. copyFromFloats(width: number, height: number): Size;
  1935. /**
  1936. * Updates in place the current Size from the given floats.
  1937. * @param width width to set
  1938. * @param height height to set
  1939. * @returns the updated Size.
  1940. */
  1941. set(width: number, height: number): Size;
  1942. /**
  1943. * Multiplies the width and height by numbers
  1944. * @param w factor to multiple the width by
  1945. * @param h factor to multiple the height by
  1946. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1947. */
  1948. multiplyByFloats(w: number, h: number): Size;
  1949. /**
  1950. * Clones the size
  1951. * @returns a new Size copied from the given one.
  1952. */
  1953. clone(): Size;
  1954. /**
  1955. * True if the current Size and the given one width and height are strictly equal.
  1956. * @param other the other size to compare against
  1957. * @returns True if the current Size and the given one width and height are strictly equal.
  1958. */
  1959. equals(other: Size): boolean;
  1960. /**
  1961. * The surface of the Size : width * height (float).
  1962. */
  1963. get surface(): number;
  1964. /**
  1965. * Create a new size of zero
  1966. * @returns a new Size set to (0.0, 0.0)
  1967. */
  1968. static Zero(): Size;
  1969. /**
  1970. * Sums the width and height of two sizes
  1971. * @param otherSize size to add to this size
  1972. * @returns a new Size set as the addition result of the current Size and the given one.
  1973. */
  1974. add(otherSize: Size): Size;
  1975. /**
  1976. * Subtracts the width and height of two
  1977. * @param otherSize size to subtract to this size
  1978. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1979. */
  1980. subtract(otherSize: Size): Size;
  1981. /**
  1982. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1983. * @param start starting size to lerp between
  1984. * @param end end size to lerp between
  1985. * @param amount amount to lerp between the start and end values
  1986. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1987. */
  1988. static Lerp(start: Size, end: Size, amount: number): Size;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Base class of all the textures in babylon.
  1994. * It groups all the common properties required to work with Thin Engine.
  1995. */
  1996. export class ThinTexture {
  1997. protected _wrapU: number;
  1998. /**
  1999. * | Value | Type | Description |
  2000. * | ----- | ------------------ | ----------- |
  2001. * | 0 | CLAMP_ADDRESSMODE | |
  2002. * | 1 | WRAP_ADDRESSMODE | |
  2003. * | 2 | MIRROR_ADDRESSMODE | |
  2004. */
  2005. get wrapU(): number;
  2006. set wrapU(value: number);
  2007. protected _wrapV: number;
  2008. /**
  2009. * | Value | Type | Description |
  2010. * | ----- | ------------------ | ----------- |
  2011. * | 0 | CLAMP_ADDRESSMODE | |
  2012. * | 1 | WRAP_ADDRESSMODE | |
  2013. * | 2 | MIRROR_ADDRESSMODE | |
  2014. */
  2015. get wrapV(): number;
  2016. set wrapV(value: number);
  2017. /**
  2018. * | Value | Type | Description |
  2019. * | ----- | ------------------ | ----------- |
  2020. * | 0 | CLAMP_ADDRESSMODE | |
  2021. * | 1 | WRAP_ADDRESSMODE | |
  2022. * | 2 | MIRROR_ADDRESSMODE | |
  2023. */
  2024. wrapR: number;
  2025. /**
  2026. * With compliant hardware and browser (supporting anisotropic filtering)
  2027. * this defines the level of anisotropic filtering in the texture.
  2028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2029. */
  2030. anisotropicFilteringLevel: number;
  2031. /**
  2032. * Define the current state of the loading sequence when in delayed load mode.
  2033. */
  2034. delayLoadState: number;
  2035. /**
  2036. * How a texture is mapped.
  2037. * Unused in thin texture mode.
  2038. */
  2039. get coordinatesMode(): number;
  2040. /**
  2041. * Define if the texture is a cube texture or if false a 2d texture.
  2042. */
  2043. get isCube(): boolean;
  2044. set isCube(value: boolean);
  2045. /**
  2046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2047. */
  2048. get is3D(): boolean;
  2049. set is3D(value: boolean);
  2050. /**
  2051. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2052. */
  2053. get is2DArray(): boolean;
  2054. set is2DArray(value: boolean);
  2055. /**
  2056. * Get the class name of the texture.
  2057. * @returns "ThinTexture"
  2058. */
  2059. getClassName(): string;
  2060. /** @hidden */
  2061. _texture: Nullable<InternalTexture>;
  2062. protected _engine: Nullable<ThinEngine>;
  2063. private _cachedSize;
  2064. private _cachedBaseSize;
  2065. /**
  2066. * Instantiates a new ThinTexture.
  2067. * Base class of all the textures in babylon.
  2068. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2069. * @param internalTexture Define the internalTexture to wrap
  2070. */
  2071. constructor(internalTexture: Nullable<InternalTexture>);
  2072. /**
  2073. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2074. * @returns true if fully ready
  2075. */
  2076. isReady(): boolean;
  2077. /**
  2078. * Triggers the load sequence in delayed load mode.
  2079. */
  2080. delayLoad(): void;
  2081. /**
  2082. * Get the underlying lower level texture from Babylon.
  2083. * @returns the internal texture
  2084. */
  2085. getInternalTexture(): Nullable<InternalTexture>;
  2086. /**
  2087. * Get the size of the texture.
  2088. * @returns the texture size.
  2089. */
  2090. getSize(): ISize;
  2091. /**
  2092. * Get the base size of the texture.
  2093. * It can be different from the size if the texture has been resized for POT for instance
  2094. * @returns the base size
  2095. */
  2096. getBaseSize(): ISize;
  2097. /**
  2098. * Update the sampling mode of the texture.
  2099. * Default is Trilinear mode.
  2100. *
  2101. * | Value | Type | Description |
  2102. * | ----- | ------------------ | ----------- |
  2103. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2104. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2105. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2106. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2107. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2108. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2109. * | 7 | NEAREST_LINEAR | |
  2110. * | 8 | NEAREST_NEAREST | |
  2111. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2112. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2113. * | 11 | LINEAR_LINEAR | |
  2114. * | 12 | LINEAR_NEAREST | |
  2115. *
  2116. * > _mag_: magnification filter (close to the viewer)
  2117. * > _min_: minification filter (far from the viewer)
  2118. * > _mip_: filter used between mip map levels
  2119. *@param samplingMode Define the new sampling mode of the texture
  2120. */
  2121. updateSamplingMode(samplingMode: number): void;
  2122. /**
  2123. * Release and destroy the underlying lower level texture aka internalTexture.
  2124. */
  2125. releaseInternalTexture(): void;
  2126. /**
  2127. * Dispose the texture and release its associated resources.
  2128. */
  2129. dispose(): void;
  2130. }
  2131. }
  2132. declare module BABYLON {
  2133. /**
  2134. * Defines an array and its length.
  2135. * It can be helpful to group result from both Arrays and smart arrays in one structure.
  2136. */
  2137. export interface ISmartArrayLike<T> {
  2138. /**
  2139. * The data of the array.
  2140. */
  2141. data: Array<T>;
  2142. /**
  2143. * The active length of the array.
  2144. */
  2145. length: number;
  2146. }
  2147. /**
  2148. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2149. */
  2150. export class SmartArray<T> implements ISmartArrayLike<T> {
  2151. /**
  2152. * The full set of data from the array.
  2153. */
  2154. data: Array<T>;
  2155. /**
  2156. * The active length of the array.
  2157. */
  2158. length: number;
  2159. protected _id: number;
  2160. /**
  2161. * Instantiates a Smart Array.
  2162. * @param capacity defines the default capacity of the array.
  2163. */
  2164. constructor(capacity: number);
  2165. /**
  2166. * Pushes a value at the end of the active data.
  2167. * @param value defines the object to push in the array.
  2168. */
  2169. push(value: T): void;
  2170. /**
  2171. * Iterates over the active data and apply the lambda to them.
  2172. * @param func defines the action to apply on each value.
  2173. */
  2174. forEach(func: (content: T) => void): void;
  2175. /**
  2176. * Sorts the full sets of data.
  2177. * @param compareFn defines the comparison function to apply.
  2178. */
  2179. sort(compareFn: (a: T, b: T) => number): void;
  2180. /**
  2181. * Resets the active data to an empty array.
  2182. */
  2183. reset(): void;
  2184. /**
  2185. * Releases all the data from the array as well as the array.
  2186. */
  2187. dispose(): void;
  2188. /**
  2189. * Concats the active data with a given array.
  2190. * @param array defines the data to concatenate with.
  2191. */
  2192. concat(array: any): void;
  2193. /**
  2194. * Returns the position of a value in the active data.
  2195. * @param value defines the value to find the index for
  2196. * @returns the index if found in the active data otherwise -1
  2197. */
  2198. indexOf(value: T): number;
  2199. /**
  2200. * Returns whether an element is part of the active data.
  2201. * @param value defines the value to look for
  2202. * @returns true if found in the active data otherwise false
  2203. */
  2204. contains(value: T): boolean;
  2205. private static _GlobalId;
  2206. }
  2207. /**
  2208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2209. * The data in this array can only be present once
  2210. */
  2211. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2212. private _duplicateId;
  2213. /**
  2214. * Pushes a value at the end of the active data.
  2215. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2216. * @param value defines the object to push in the array.
  2217. */
  2218. push(value: T): void;
  2219. /**
  2220. * Pushes a value at the end of the active data.
  2221. * If the data is already present, it won t be added again
  2222. * @param value defines the object to push in the array.
  2223. * @returns true if added false if it was already present
  2224. */
  2225. pushNoDuplicate(value: T): boolean;
  2226. /**
  2227. * Resets the active data to an empty array.
  2228. */
  2229. reset(): void;
  2230. /**
  2231. * Concats the active data with a given array.
  2232. * This ensures no duplicate will be present in the result.
  2233. * @param array defines the data to concatenate with.
  2234. */
  2235. concatWithNoDuplicate(array: any): void;
  2236. }
  2237. }
  2238. declare module BABYLON {
  2239. /**
  2240. * Class used to evaluate queries containing `and` and `or` operators
  2241. */
  2242. export class AndOrNotEvaluator {
  2243. /**
  2244. * Evaluate a query
  2245. * @param query defines the query to evaluate
  2246. * @param evaluateCallback defines the callback used to filter result
  2247. * @returns true if the query matches
  2248. */
  2249. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2250. private static _HandleParenthesisContent;
  2251. private static _SimplifyNegation;
  2252. }
  2253. }
  2254. declare module BABYLON {
  2255. /**
  2256. * Class used to store custom tags
  2257. */
  2258. export class Tags {
  2259. /**
  2260. * Adds support for tags on the given object
  2261. * @param obj defines the object to use
  2262. */
  2263. static EnableFor(obj: any): void;
  2264. /**
  2265. * Removes tags support
  2266. * @param obj defines the object to use
  2267. */
  2268. static DisableFor(obj: any): void;
  2269. /**
  2270. * Gets a boolean indicating if the given object has tags
  2271. * @param obj defines the object to use
  2272. * @returns a boolean
  2273. */
  2274. static HasTags(obj: any): boolean;
  2275. /**
  2276. * Gets the tags available on a given object
  2277. * @param obj defines the object to use
  2278. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2279. * @returns the tags
  2280. */
  2281. static GetTags(obj: any, asString?: boolean): any;
  2282. /**
  2283. * Adds tags to an object
  2284. * @param obj defines the object to use
  2285. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2286. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2287. */
  2288. static AddTagsTo(obj: any, tagsString: string): void;
  2289. /**
  2290. * @hidden
  2291. */
  2292. static _AddTagTo(obj: any, tag: string): void;
  2293. /**
  2294. * Removes specific tags from a specific object
  2295. * @param obj defines the object to use
  2296. * @param tagsString defines the tags to remove
  2297. */
  2298. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2299. /**
  2300. * @hidden
  2301. */
  2302. static _RemoveTagFrom(obj: any, tag: string): void;
  2303. /**
  2304. * Defines if tags hosted on an object match a given query
  2305. * @param obj defines the object to use
  2306. * @param tagsQuery defines the tag query
  2307. * @returns a boolean
  2308. */
  2309. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2310. }
  2311. }
  2312. declare module BABYLON {
  2313. /**
  2314. * Scalar computation library
  2315. */
  2316. export class Scalar {
  2317. /**
  2318. * Two pi constants convenient for computation.
  2319. */
  2320. static TwoPi: number;
  2321. /**
  2322. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2323. * @param a number
  2324. * @param b number
  2325. * @param epsilon (default = 1.401298E-45)
  2326. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2327. */
  2328. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2329. /**
  2330. * Returns a string : the upper case translation of the number i to hexadecimal.
  2331. * @param i number
  2332. * @returns the upper case translation of the number i to hexadecimal.
  2333. */
  2334. static ToHex(i: number): string;
  2335. /**
  2336. * Returns -1 if value is negative and +1 is value is positive.
  2337. * @param value the value
  2338. * @returns the value itself if it's equal to zero.
  2339. */
  2340. static Sign(value: number): number;
  2341. /**
  2342. * Returns the value itself if it's between min and max.
  2343. * Returns min if the value is lower than min.
  2344. * Returns max if the value is greater than max.
  2345. * @param value the value to clmap
  2346. * @param min the min value to clamp to (default: 0)
  2347. * @param max the max value to clamp to (default: 1)
  2348. * @returns the clamped value
  2349. */
  2350. static Clamp(value: number, min?: number, max?: number): number;
  2351. /**
  2352. * the log2 of value.
  2353. * @param value the value to compute log2 of
  2354. * @returns the log2 of value.
  2355. */
  2356. static Log2(value: number): number;
  2357. /**
  2358. * the floor part of a log2 value.
  2359. * @param value the value to compute log2 of
  2360. * @returns the log2 of value.
  2361. */
  2362. static ILog2(value: number): number;
  2363. /**
  2364. * Loops the value, so that it is never larger than length and never smaller than 0.
  2365. *
  2366. * This is similar to the modulo operator but it works with floating point numbers.
  2367. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2368. * With t = 5 and length = 2.5, the result would be 0.0.
  2369. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2370. * @param value the value
  2371. * @param length the length
  2372. * @returns the looped value
  2373. */
  2374. static Repeat(value: number, length: number): number;
  2375. /**
  2376. * Normalize the value between 0.0 and 1.0 using min and max values
  2377. * @param value value to normalize
  2378. * @param min max to normalize between
  2379. * @param max min to normalize between
  2380. * @returns the normalized value
  2381. */
  2382. static Normalize(value: number, min: number, max: number): number;
  2383. /**
  2384. * Denormalize the value from 0.0 and 1.0 using min and max values
  2385. * @param normalized value to denormalize
  2386. * @param min max to denormalize between
  2387. * @param max min to denormalize between
  2388. * @returns the denormalized value
  2389. */
  2390. static Denormalize(normalized: number, min: number, max: number): number;
  2391. /**
  2392. * Calculates the shortest difference between two given angles given in degrees.
  2393. * @param current current angle in degrees
  2394. * @param target target angle in degrees
  2395. * @returns the delta
  2396. */
  2397. static DeltaAngle(current: number, target: number): number;
  2398. /**
  2399. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2400. * @param tx value
  2401. * @param length length
  2402. * @returns The returned value will move back and forth between 0 and length
  2403. */
  2404. static PingPong(tx: number, length: number): number;
  2405. /**
  2406. * Interpolates between min and max with smoothing at the limits.
  2407. *
  2408. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2409. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2410. * @param from from
  2411. * @param to to
  2412. * @param tx value
  2413. * @returns the smooth stepped value
  2414. */
  2415. static SmoothStep(from: number, to: number, tx: number): number;
  2416. /**
  2417. * Moves a value current towards target.
  2418. *
  2419. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2420. * Negative values of maxDelta pushes the value away from target.
  2421. * @param current current value
  2422. * @param target target value
  2423. * @param maxDelta max distance to move
  2424. * @returns resulting value
  2425. */
  2426. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2427. /**
  2428. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2429. *
  2430. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2431. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2432. * @param current current value
  2433. * @param target target value
  2434. * @param maxDelta max distance to move
  2435. * @returns resulting angle
  2436. */
  2437. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2438. /**
  2439. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2440. * @param start start value
  2441. * @param end target value
  2442. * @param amount amount to lerp between
  2443. * @returns the lerped value
  2444. */
  2445. static Lerp(start: number, end: number, amount: number): number;
  2446. /**
  2447. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2448. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2449. * @param start start value
  2450. * @param end target value
  2451. * @param amount amount to lerp between
  2452. * @returns the lerped value
  2453. */
  2454. static LerpAngle(start: number, end: number, amount: number): number;
  2455. /**
  2456. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2457. * @param a start value
  2458. * @param b target value
  2459. * @param value value between a and b
  2460. * @returns the inverseLerp value
  2461. */
  2462. static InverseLerp(a: number, b: number, value: number): number;
  2463. /**
  2464. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2465. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2466. * @param value1 spline value
  2467. * @param tangent1 spline value
  2468. * @param value2 spline value
  2469. * @param tangent2 spline value
  2470. * @param amount input value
  2471. * @returns hermite result
  2472. */
  2473. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2474. /**
  2475. * Returns a random float number between and min and max values
  2476. * @param min min value of random
  2477. * @param max max value of random
  2478. * @returns random value
  2479. */
  2480. static RandomRange(min: number, max: number): number;
  2481. /**
  2482. * This function returns percentage of a number in a given range.
  2483. *
  2484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2486. * @param number to convert to percentage
  2487. * @param min min range
  2488. * @param max max range
  2489. * @returns the percentage
  2490. */
  2491. static RangeToPercent(number: number, min: number, max: number): number;
  2492. /**
  2493. * This function returns number that corresponds to the percentage in a given range.
  2494. *
  2495. * PercentToRange(0.34,0,100) will return 34.
  2496. * @param percent to convert to number
  2497. * @param min min range
  2498. * @param max max range
  2499. * @returns the number
  2500. */
  2501. static PercentToRange(percent: number, min: number, max: number): number;
  2502. /**
  2503. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2504. * @param angle The angle to normalize in radian.
  2505. * @return The converted angle.
  2506. */
  2507. static NormalizeRadians(angle: number): number;
  2508. }
  2509. }
  2510. declare module BABYLON {
  2511. /**
  2512. * Constant used to convert a value to gamma space
  2513. * @ignorenaming
  2514. */
  2515. export const ToGammaSpace: number;
  2516. /**
  2517. * Constant used to convert a value to linear space
  2518. * @ignorenaming
  2519. */
  2520. export const ToLinearSpace = 2.2;
  2521. /**
  2522. * Constant used to define the minimal number value in Babylon.js
  2523. * @ignorenaming
  2524. */
  2525. let Epsilon: number;
  2526. }
  2527. declare module BABYLON {
  2528. /**
  2529. * Class used to represent a viewport on screen
  2530. */
  2531. export class Viewport {
  2532. /** viewport left coordinate */
  2533. x: number;
  2534. /** viewport top coordinate */
  2535. y: number;
  2536. /**viewport width */
  2537. width: number;
  2538. /** viewport height */
  2539. height: number;
  2540. /**
  2541. * Creates a Viewport object located at (x, y) and sized (width, height)
  2542. * @param x defines viewport left coordinate
  2543. * @param y defines viewport top coordinate
  2544. * @param width defines the viewport width
  2545. * @param height defines the viewport height
  2546. */
  2547. constructor(
  2548. /** viewport left coordinate */
  2549. x: number,
  2550. /** viewport top coordinate */
  2551. y: number,
  2552. /**viewport width */
  2553. width: number,
  2554. /** viewport height */
  2555. height: number);
  2556. /**
  2557. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2558. * @param renderWidth defines the rendering width
  2559. * @param renderHeight defines the rendering height
  2560. * @returns a new Viewport
  2561. */
  2562. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2563. /**
  2564. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2565. * @param renderWidth defines the rendering width
  2566. * @param renderHeight defines the rendering height
  2567. * @param ref defines the target viewport
  2568. * @returns the current viewport
  2569. */
  2570. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2571. /**
  2572. * Returns a new Viewport copied from the current one
  2573. * @returns a new Viewport
  2574. */
  2575. clone(): Viewport;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Class containing a set of static utilities functions for arrays.
  2581. */
  2582. export class ArrayTools {
  2583. /**
  2584. * Returns an array of the given size filled with element built from the given constructor and the parameters
  2585. * @param size the number of element to construct and put in the array
  2586. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2587. * @returns a new array filled with new objects
  2588. */
  2589. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2590. }
  2591. }
  2592. declare module BABYLON {
  2593. /**
  2594. * Represents a plane by the equation ax + by + cz + d = 0
  2595. */
  2596. export class Plane {
  2597. private static _TmpMatrix;
  2598. /**
  2599. * Normal of the plane (a,b,c)
  2600. */
  2601. normal: Vector3;
  2602. /**
  2603. * d component of the plane
  2604. */
  2605. d: number;
  2606. /**
  2607. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2608. * @param a a component of the plane
  2609. * @param b b component of the plane
  2610. * @param c c component of the plane
  2611. * @param d d component of the plane
  2612. */
  2613. constructor(a: number, b: number, c: number, d: number);
  2614. /**
  2615. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2616. */
  2617. asArray(): number[];
  2618. /**
  2619. * @returns a new plane copied from the current Plane.
  2620. */
  2621. clone(): Plane;
  2622. /**
  2623. * @returns the string "Plane".
  2624. */
  2625. getClassName(): string;
  2626. /**
  2627. * @returns the Plane hash code.
  2628. */
  2629. getHashCode(): number;
  2630. /**
  2631. * Normalize the current Plane in place.
  2632. * @returns the updated Plane.
  2633. */
  2634. normalize(): Plane;
  2635. /**
  2636. * Applies a transformation the plane and returns the result
  2637. * @param transformation the transformation matrix to be applied to the plane
  2638. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2639. */
  2640. transform(transformation: DeepImmutable<Matrix>): Plane;
  2641. /**
  2642. * Compute the dot product between the point and the plane normal
  2643. * @param point point to calculate the dot product with
  2644. * @returns the dot product (float) of the point coordinates and the plane normal.
  2645. */
  2646. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2647. /**
  2648. * Updates the current Plane from the plane defined by the three given points.
  2649. * @param point1 one of the points used to contruct the plane
  2650. * @param point2 one of the points used to contruct the plane
  2651. * @param point3 one of the points used to contruct the plane
  2652. * @returns the updated Plane.
  2653. */
  2654. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2655. /**
  2656. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2657. * Note that for this function to work as expected you should make sure that:
  2658. * - direction and the plane normal are normalized
  2659. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2660. * @param direction the direction to check if the plane is facing
  2661. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2662. * @returns True if the plane is facing the given direction
  2663. */
  2664. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2665. /**
  2666. * Calculates the distance to a point
  2667. * @param point point to calculate distance to
  2668. * @returns the signed distance (float) from the given point to the Plane.
  2669. */
  2670. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2671. /**
  2672. * Creates a plane from an array
  2673. * @param array the array to create a plane from
  2674. * @returns a new Plane from the given array.
  2675. */
  2676. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2677. /**
  2678. * Creates a plane from three points
  2679. * @param point1 point used to create the plane
  2680. * @param point2 point used to create the plane
  2681. * @param point3 point used to create the plane
  2682. * @returns a new Plane defined by the three given points.
  2683. */
  2684. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2685. /**
  2686. * Creates a plane from an origin point and a normal
  2687. * @param origin origin of the plane to be constructed
  2688. * @param normal normal of the plane to be constructed
  2689. * @returns a new Plane the normal vector to this plane at the given origin point.
  2690. * Note : the vector "normal" is updated because normalized.
  2691. */
  2692. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2693. /**
  2694. * Calculates the distance from a plane and a point
  2695. * @param origin origin of the plane to be constructed
  2696. * @param normal normal of the plane to be constructed
  2697. * @param point point to calculate distance to
  2698. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2699. */
  2700. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2701. }
  2702. }
  2703. declare module BABYLON {
  2704. /** @hidden */
  2705. export class PerformanceConfigurator {
  2706. /** @hidden */
  2707. static MatrixUse64Bits: boolean;
  2708. /** @hidden */
  2709. static MatrixTrackPrecisionChange: boolean;
  2710. /** @hidden */
  2711. static MatrixCurrentType: any;
  2712. /** @hidden */
  2713. static MatrixTrackedMatrices: Array<any> | null;
  2714. /** @hidden */
  2715. static SetMatrixPrecision(use64bits: boolean): void;
  2716. }
  2717. }
  2718. declare module BABYLON {
  2719. /**
  2720. * Class representing a vector containing 2 coordinates
  2721. */
  2722. export class Vector2 {
  2723. /** defines the first coordinate */
  2724. x: number;
  2725. /** defines the second coordinate */
  2726. y: number;
  2727. /**
  2728. * Creates a new Vector2 from the given x and y coordinates
  2729. * @param x defines the first coordinate
  2730. * @param y defines the second coordinate
  2731. */
  2732. constructor(
  2733. /** defines the first coordinate */
  2734. x?: number,
  2735. /** defines the second coordinate */
  2736. y?: number);
  2737. /**
  2738. * Gets a string with the Vector2 coordinates
  2739. * @returns a string with the Vector2 coordinates
  2740. */
  2741. toString(): string;
  2742. /**
  2743. * Gets class name
  2744. * @returns the string "Vector2"
  2745. */
  2746. getClassName(): string;
  2747. /**
  2748. * Gets current vector hash code
  2749. * @returns the Vector2 hash code as a number
  2750. */
  2751. getHashCode(): number;
  2752. /**
  2753. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2754. * @param array defines the source array
  2755. * @param index defines the offset in source array
  2756. * @returns the current Vector2
  2757. */
  2758. toArray(array: FloatArray, index?: number): Vector2;
  2759. /**
  2760. * Update the current vector from an array
  2761. * @param array defines the destination array
  2762. * @param index defines the offset in the destination array
  2763. * @returns the current Vector3
  2764. */
  2765. fromArray(array: FloatArray, index?: number): Vector2;
  2766. /**
  2767. * Copy the current vector to an array
  2768. * @returns a new array with 2 elements: the Vector2 coordinates.
  2769. */
  2770. asArray(): number[];
  2771. /**
  2772. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2773. * @param source defines the source Vector2
  2774. * @returns the current updated Vector2
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2777. /**
  2778. * Sets the Vector2 coordinates with the given floats
  2779. * @param x defines the first coordinate
  2780. * @param y defines the second coordinate
  2781. * @returns the current updated Vector2
  2782. */
  2783. copyFromFloats(x: number, y: number): Vector2;
  2784. /**
  2785. * Sets the Vector2 coordinates with the given floats
  2786. * @param x defines the first coordinate
  2787. * @param y defines the second coordinate
  2788. * @returns the current updated Vector2
  2789. */
  2790. set(x: number, y: number): Vector2;
  2791. /**
  2792. * Add another vector with the current one
  2793. * @param otherVector defines the other vector
  2794. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2795. */
  2796. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2797. /**
  2798. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2799. * @param otherVector defines the other vector
  2800. * @param result defines the target vector
  2801. * @returns the unmodified current Vector2
  2802. */
  2803. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2804. /**
  2805. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2806. * @param otherVector defines the other vector
  2807. * @returns the current updated Vector2
  2808. */
  2809. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2810. /**
  2811. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2812. * @param otherVector defines the other vector
  2813. * @returns a new Vector2
  2814. */
  2815. addVector3(otherVector: Vector3): Vector2;
  2816. /**
  2817. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2818. * @param otherVector defines the other vector
  2819. * @returns a new Vector2
  2820. */
  2821. subtract(otherVector: Vector2): Vector2;
  2822. /**
  2823. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2824. * @param otherVector defines the other vector
  2825. * @param result defines the target vector
  2826. * @returns the unmodified current Vector2
  2827. */
  2828. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2829. /**
  2830. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2831. * @param otherVector defines the other vector
  2832. * @returns the current updated Vector2
  2833. */
  2834. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2835. /**
  2836. * Multiplies in place the current Vector2 coordinates by the given ones
  2837. * @param otherVector defines the other vector
  2838. * @returns the current updated Vector2
  2839. */
  2840. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2841. /**
  2842. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2843. * @param otherVector defines the other vector
  2844. * @returns a new Vector2
  2845. */
  2846. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2847. /**
  2848. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @param result defines the target vector
  2851. * @returns the unmodified current Vector2
  2852. */
  2853. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2854. /**
  2855. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2856. * @param x defines the first coordinate
  2857. * @param y defines the second coordinate
  2858. * @returns a new Vector2
  2859. */
  2860. multiplyByFloats(x: number, y: number): Vector2;
  2861. /**
  2862. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2863. * @param otherVector defines the other vector
  2864. * @returns a new Vector2
  2865. */
  2866. divide(otherVector: Vector2): Vector2;
  2867. /**
  2868. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2869. * @param otherVector defines the other vector
  2870. * @param result defines the target vector
  2871. * @returns the unmodified current Vector2
  2872. */
  2873. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2874. /**
  2875. * Divides the current Vector2 coordinates by the given ones
  2876. * @param otherVector defines the other vector
  2877. * @returns the current updated Vector2
  2878. */
  2879. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets a new Vector2 with current Vector2 negated coordinates
  2882. * @returns a new Vector2
  2883. */
  2884. negate(): Vector2;
  2885. /**
  2886. * Negate this vector in place
  2887. * @returns this
  2888. */
  2889. negateInPlace(): Vector2;
  2890. /**
  2891. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2892. * @param result defines the Vector3 object where to store the result
  2893. * @returns the current Vector2
  2894. */
  2895. negateToRef(result: Vector2): Vector2;
  2896. /**
  2897. * Multiply the Vector2 coordinates by scale
  2898. * @param scale defines the scaling factor
  2899. * @returns the current updated Vector2
  2900. */
  2901. scaleInPlace(scale: number): Vector2;
  2902. /**
  2903. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2904. * @param scale defines the scaling factor
  2905. * @returns a new Vector2
  2906. */
  2907. scale(scale: number): Vector2;
  2908. /**
  2909. * Scale the current Vector2 values by a factor to a given Vector2
  2910. * @param scale defines the scale factor
  2911. * @param result defines the Vector2 object where to store the result
  2912. * @returns the unmodified current Vector2
  2913. */
  2914. scaleToRef(scale: number, result: Vector2): Vector2;
  2915. /**
  2916. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2917. * @param scale defines the scale factor
  2918. * @param result defines the Vector2 object where to store the result
  2919. * @returns the unmodified current Vector2
  2920. */
  2921. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2922. /**
  2923. * Gets a boolean if two vectors are equals
  2924. * @param otherVector defines the other vector
  2925. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2926. */
  2927. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2928. /**
  2929. * Gets a boolean if two vectors are equals (using an epsilon value)
  2930. * @param otherVector defines the other vector
  2931. * @param epsilon defines the minimal distance to consider equality
  2932. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2933. */
  2934. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2935. /**
  2936. * Gets a new Vector2 from current Vector2 floored values
  2937. * @returns a new Vector2
  2938. */
  2939. floor(): Vector2;
  2940. /**
  2941. * Gets a new Vector2 from current Vector2 floored values
  2942. * @returns a new Vector2
  2943. */
  2944. fract(): Vector2;
  2945. /**
  2946. * Gets the length of the vector
  2947. * @returns the vector length (float)
  2948. */
  2949. length(): number;
  2950. /**
  2951. * Gets the vector squared length
  2952. * @returns the vector squared length (float)
  2953. */
  2954. lengthSquared(): number;
  2955. /**
  2956. * Normalize the vector
  2957. * @returns the current updated Vector2
  2958. */
  2959. normalize(): Vector2;
  2960. /**
  2961. * Gets a new Vector2 copied from the Vector2
  2962. * @returns a new Vector2
  2963. */
  2964. clone(): Vector2;
  2965. /**
  2966. * Gets a new Vector2(0, 0)
  2967. * @returns a new Vector2
  2968. */
  2969. static Zero(): Vector2;
  2970. /**
  2971. * Gets a new Vector2(1, 1)
  2972. * @returns a new Vector2
  2973. */
  2974. static One(): Vector2;
  2975. /**
  2976. * Gets a new Vector2 set from the given index element of the given array
  2977. * @param array defines the data source
  2978. * @param offset defines the offset in the data source
  2979. * @returns a new Vector2
  2980. */
  2981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2982. /**
  2983. * Sets "result" from the given index element of the given array
  2984. * @param array defines the data source
  2985. * @param offset defines the offset in the data source
  2986. * @param result defines the target vector
  2987. */
  2988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2989. /**
  2990. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2991. * @param value1 defines 1st point of control
  2992. * @param value2 defines 2nd point of control
  2993. * @param value3 defines 3rd point of control
  2994. * @param value4 defines 4th point of control
  2995. * @param amount defines the interpolation factor
  2996. * @returns a new Vector2
  2997. */
  2998. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2999. /**
  3000. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  3001. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  3002. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  3003. * @param value defines the value to clamp
  3004. * @param min defines the lower limit
  3005. * @param max defines the upper limit
  3006. * @returns a new Vector2
  3007. */
  3008. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  3009. /**
  3010. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  3011. * @param value1 defines the 1st control point
  3012. * @param tangent1 defines the outgoing tangent
  3013. * @param value2 defines the 2nd control point
  3014. * @param tangent2 defines the incoming tangent
  3015. * @param amount defines the interpolation factor
  3016. * @returns a new Vector2
  3017. */
  3018. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3019. /**
  3020. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3021. * @param start defines the start vector
  3022. * @param end defines the end vector
  3023. * @param amount defines the interpolation factor
  3024. * @returns a new Vector2
  3025. */
  3026. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3027. /**
  3028. * Gets the dot product of the vector "left" and the vector "right"
  3029. * @param left defines first vector
  3030. * @param right defines second vector
  3031. * @returns the dot product (float)
  3032. */
  3033. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3034. /**
  3035. * Returns a new Vector2 equal to the normalized given vector
  3036. * @param vector defines the vector to normalize
  3037. * @returns a new Vector2
  3038. */
  3039. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3042. * @param left defines 1st vector
  3043. * @param right defines 2nd vector
  3044. * @returns a new Vector2
  3045. */
  3046. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3047. /**
  3048. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3049. * @param left defines 1st vector
  3050. * @param right defines 2nd vector
  3051. * @returns a new Vector2
  3052. */
  3053. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3054. /**
  3055. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3056. * @param vector defines the vector to transform
  3057. * @param transformation defines the matrix to apply
  3058. * @returns a new Vector2
  3059. */
  3060. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3061. /**
  3062. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3063. * @param vector defines the vector to transform
  3064. * @param transformation defines the matrix to apply
  3065. * @param result defines the target vector
  3066. */
  3067. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3068. /**
  3069. * Determines if a given vector is included in a triangle
  3070. * @param p defines the vector to test
  3071. * @param p0 defines 1st triangle point
  3072. * @param p1 defines 2nd triangle point
  3073. * @param p2 defines 3rd triangle point
  3074. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3075. */
  3076. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3077. /**
  3078. * Gets the distance between the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns the distance between vectors
  3082. */
  3083. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3084. /**
  3085. * Returns the squared distance between the vectors "value1" and "value2"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @returns the squared distance between vectors
  3089. */
  3090. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3091. /**
  3092. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3093. * @param value1 defines first vector
  3094. * @param value2 defines second vector
  3095. * @returns a new Vector2
  3096. */
  3097. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3098. /**
  3099. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3100. * @param value1 defines first vector
  3101. * @param value2 defines second vector
  3102. * @param ref defines third vector
  3103. * @returns ref
  3104. */
  3105. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3106. /**
  3107. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3108. * @param p defines the middle point
  3109. * @param segA defines one point of the segment
  3110. * @param segB defines the other point of the segment
  3111. * @returns the shortest distance
  3112. */
  3113. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3114. }
  3115. /**
  3116. * Class used to store (x,y,z) vector representation
  3117. * A Vector3 is the main object used in 3D geometry
  3118. * It can represent etiher the coordinates of a point the space, either a direction
  3119. * Reminder: js uses a left handed forward facing system
  3120. */
  3121. export class Vector3 {
  3122. private static _UpReadOnly;
  3123. private static _ZeroReadOnly;
  3124. /** @hidden */
  3125. _x: number;
  3126. /** @hidden */
  3127. _y: number;
  3128. /** @hidden */
  3129. _z: number;
  3130. /** @hidden */
  3131. _isDirty: boolean;
  3132. /** Gets or sets the x coordinate */
  3133. get x(): number;
  3134. set x(value: number);
  3135. /** Gets or sets the y coordinate */
  3136. get y(): number;
  3137. set y(value: number);
  3138. /** Gets or sets the z coordinate */
  3139. get z(): number;
  3140. set z(value: number);
  3141. /**
  3142. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3143. * @param x defines the first coordinates (on X axis)
  3144. * @param y defines the second coordinates (on Y axis)
  3145. * @param z defines the third coordinates (on Z axis)
  3146. */
  3147. constructor(x?: number, y?: number, z?: number);
  3148. /**
  3149. * Creates a string representation of the Vector3
  3150. * @returns a string with the Vector3 coordinates.
  3151. */
  3152. toString(): string;
  3153. /**
  3154. * Gets the class name
  3155. * @returns the string "Vector3"
  3156. */
  3157. getClassName(): string;
  3158. /**
  3159. * Creates the Vector3 hash code
  3160. * @returns a number which tends to be unique between Vector3 instances
  3161. */
  3162. getHashCode(): number;
  3163. /**
  3164. * Creates an array containing three elements : the coordinates of the Vector3
  3165. * @returns a new array of numbers
  3166. */
  3167. asArray(): number[];
  3168. /**
  3169. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3170. * @param array defines the destination array
  3171. * @param index defines the offset in the destination array
  3172. * @returns the current Vector3
  3173. */
  3174. toArray(array: FloatArray, index?: number): Vector3;
  3175. /**
  3176. * Update the current vector from an array
  3177. * @param array defines the destination array
  3178. * @param index defines the offset in the destination array
  3179. * @returns the current Vector3
  3180. */
  3181. fromArray(array: FloatArray, index?: number): Vector3;
  3182. /**
  3183. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3184. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3185. */
  3186. toQuaternion(): Quaternion;
  3187. /**
  3188. * Adds the given vector to the current Vector3
  3189. * @param otherVector defines the second operand
  3190. * @returns the current updated Vector3
  3191. */
  3192. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the given coordinates to the current Vector3
  3195. * @param x defines the x coordinate of the operand
  3196. * @param y defines the y coordinate of the operand
  3197. * @param z defines the z coordinate of the operand
  3198. * @returns the current updated Vector3
  3199. */
  3200. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3201. /**
  3202. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3203. * @param otherVector defines the second operand
  3204. * @returns the resulting Vector3
  3205. */
  3206. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3207. /**
  3208. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3209. * @param otherVector defines the second operand
  3210. * @param result defines the Vector3 object where to store the result
  3211. * @returns the current Vector3
  3212. */
  3213. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3214. /**
  3215. * Subtract the given vector from the current Vector3
  3216. * @param otherVector defines the second operand
  3217. * @returns the current updated Vector3
  3218. */
  3219. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3222. * @param otherVector defines the second operand
  3223. * @returns the resulting Vector3
  3224. */
  3225. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3226. /**
  3227. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3228. * @param otherVector defines the second operand
  3229. * @param result defines the Vector3 object where to store the result
  3230. * @returns the current Vector3
  3231. */
  3232. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3235. * @param x defines the x coordinate of the operand
  3236. * @param y defines the y coordinate of the operand
  3237. * @param z defines the z coordinate of the operand
  3238. * @returns the resulting Vector3
  3239. */
  3240. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3241. /**
  3242. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3243. * @param x defines the x coordinate of the operand
  3244. * @param y defines the y coordinate of the operand
  3245. * @param z defines the z coordinate of the operand
  3246. * @param result defines the Vector3 object where to store the result
  3247. * @returns the current Vector3
  3248. */
  3249. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3250. /**
  3251. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3252. * @returns a new Vector3
  3253. */
  3254. negate(): Vector3;
  3255. /**
  3256. * Negate this vector in place
  3257. * @returns this
  3258. */
  3259. negateInPlace(): Vector3;
  3260. /**
  3261. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3262. * @param result defines the Vector3 object where to store the result
  3263. * @returns the current Vector3
  3264. */
  3265. negateToRef(result: Vector3): Vector3;
  3266. /**
  3267. * Multiplies the Vector3 coordinates by the float "scale"
  3268. * @param scale defines the multiplier factor
  3269. * @returns the current updated Vector3
  3270. */
  3271. scaleInPlace(scale: number): Vector3;
  3272. /**
  3273. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3274. * @param scale defines the multiplier factor
  3275. * @returns a new Vector3
  3276. */
  3277. scale(scale: number): Vector3;
  3278. /**
  3279. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3280. * @param scale defines the multiplier factor
  3281. * @param result defines the Vector3 object where to store the result
  3282. * @returns the current Vector3
  3283. */
  3284. scaleToRef(scale: number, result: Vector3): Vector3;
  3285. /**
  3286. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3287. * @param scale defines the scale factor
  3288. * @param result defines the Vector3 object where to store the result
  3289. * @returns the unmodified current Vector3
  3290. */
  3291. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3292. /**
  3293. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3294. * @param origin defines the origin of the projection ray
  3295. * @param plane defines the plane to project to
  3296. * @returns the projected vector3
  3297. */
  3298. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3299. /**
  3300. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3301. * @param origin defines the origin of the projection ray
  3302. * @param plane defines the plane to project to
  3303. * @param result defines the Vector3 where to store the result
  3304. */
  3305. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3306. /**
  3307. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3308. * @param otherVector defines the second operand
  3309. * @returns true if both vectors are equals
  3310. */
  3311. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3312. /**
  3313. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3314. * @param otherVector defines the second operand
  3315. * @param epsilon defines the minimal distance to define values as equals
  3316. * @returns true if both vectors are distant less than epsilon
  3317. */
  3318. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3319. /**
  3320. * Returns true if the current Vector3 coordinates equals the given floats
  3321. * @param x defines the x coordinate of the operand
  3322. * @param y defines the y coordinate of the operand
  3323. * @param z defines the z coordinate of the operand
  3324. * @returns true if both vectors are equals
  3325. */
  3326. equalsToFloats(x: number, y: number, z: number): boolean;
  3327. /**
  3328. * Multiplies the current Vector3 coordinates by the given ones
  3329. * @param otherVector defines the second operand
  3330. * @returns the current updated Vector3
  3331. */
  3332. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3333. /**
  3334. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3335. * @param otherVector defines the second operand
  3336. * @returns the new Vector3
  3337. */
  3338. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3339. /**
  3340. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3341. * @param otherVector defines the second operand
  3342. * @param result defines the Vector3 object where to store the result
  3343. * @returns the current Vector3
  3344. */
  3345. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3348. * @param x defines the x coordinate of the operand
  3349. * @param y defines the y coordinate of the operand
  3350. * @param z defines the z coordinate of the operand
  3351. * @returns the new Vector3
  3352. */
  3353. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3354. /**
  3355. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3356. * @param otherVector defines the second operand
  3357. * @returns the new Vector3
  3358. */
  3359. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3360. /**
  3361. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3362. * @param otherVector defines the second operand
  3363. * @param result defines the Vector3 object where to store the result
  3364. * @returns the current Vector3
  3365. */
  3366. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3367. /**
  3368. * Divides the current Vector3 coordinates by the given ones.
  3369. * @param otherVector defines the second operand
  3370. * @returns the current updated Vector3
  3371. */
  3372. divideInPlace(otherVector: Vector3): Vector3;
  3373. /**
  3374. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3375. * @param other defines the second operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3381. * @param other defines the second operand
  3382. * @returns the current updated Vector3
  3383. */
  3384. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3385. /**
  3386. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3387. * @param x defines the x coordinate of the operand
  3388. * @param y defines the y coordinate of the operand
  3389. * @param z defines the z coordinate of the operand
  3390. * @returns the current updated Vector3
  3391. */
  3392. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3393. /**
  3394. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3395. * @param x defines the x coordinate of the operand
  3396. * @param y defines the y coordinate of the operand
  3397. * @param z defines the z coordinate of the operand
  3398. * @returns the current updated Vector3
  3399. */
  3400. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3401. /**
  3402. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3403. * Check if is non uniform within a certain amount of decimal places to account for this
  3404. * @param epsilon the amount the values can differ
  3405. * @returns if the the vector is non uniform to a certain number of decimal places
  3406. */
  3407. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3408. /**
  3409. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3410. */
  3411. get isNonUniform(): boolean;
  3412. /**
  3413. * Gets a new Vector3 from current Vector3 floored values
  3414. * @returns a new Vector3
  3415. */
  3416. floor(): Vector3;
  3417. /**
  3418. * Gets a new Vector3 from current Vector3 floored values
  3419. * @returns a new Vector3
  3420. */
  3421. fract(): Vector3;
  3422. /**
  3423. * Gets the length of the Vector3
  3424. * @returns the length of the Vector3
  3425. */
  3426. length(): number;
  3427. /**
  3428. * Gets the squared length of the Vector3
  3429. * @returns squared length of the Vector3
  3430. */
  3431. lengthSquared(): number;
  3432. /**
  3433. * Normalize the current Vector3.
  3434. * Please note that this is an in place operation.
  3435. * @returns the current updated Vector3
  3436. */
  3437. normalize(): Vector3;
  3438. /**
  3439. * Reorders the x y z properties of the vector in place
  3440. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3441. * @returns the current updated vector
  3442. */
  3443. reorderInPlace(order: string): this;
  3444. /**
  3445. * Rotates the vector around 0,0,0 by a quaternion
  3446. * @param quaternion the rotation quaternion
  3447. * @param result vector to store the result
  3448. * @returns the resulting vector
  3449. */
  3450. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3451. /**
  3452. * Rotates a vector around a given point
  3453. * @param quaternion the rotation quaternion
  3454. * @param point the point to rotate around
  3455. * @param result vector to store the result
  3456. * @returns the resulting vector
  3457. */
  3458. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3459. /**
  3460. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3461. * The cross product is then orthogonal to both current and "other"
  3462. * @param other defines the right operand
  3463. * @returns the cross product
  3464. */
  3465. cross(other: Vector3): Vector3;
  3466. /**
  3467. * Normalize the current Vector3 with the given input length.
  3468. * Please note that this is an in place operation.
  3469. * @param len the length of the vector
  3470. * @returns the current updated Vector3
  3471. */
  3472. normalizeFromLength(len: number): Vector3;
  3473. /**
  3474. * Normalize the current Vector3 to a new vector
  3475. * @returns the new Vector3
  3476. */
  3477. normalizeToNew(): Vector3;
  3478. /**
  3479. * Normalize the current Vector3 to the reference
  3480. * @param reference define the Vector3 to update
  3481. * @returns the updated Vector3
  3482. */
  3483. normalizeToRef(reference: Vector3): Vector3;
  3484. /**
  3485. * Creates a new Vector3 copied from the current Vector3
  3486. * @returns the new Vector3
  3487. */
  3488. clone(): Vector3;
  3489. /**
  3490. * Copies the given vector coordinates to the current Vector3 ones
  3491. * @param source defines the source Vector3
  3492. * @returns the current updated Vector3
  3493. */
  3494. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3495. /**
  3496. * Copies the given floats to the current Vector3 coordinates
  3497. * @param x defines the x coordinate of the operand
  3498. * @param y defines the y coordinate of the operand
  3499. * @param z defines the z coordinate of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. copyFromFloats(x: number, y: number, z: number): Vector3;
  3503. /**
  3504. * Copies the given floats to the current Vector3 coordinates
  3505. * @param x defines the x coordinate of the operand
  3506. * @param y defines the y coordinate of the operand
  3507. * @param z defines the z coordinate of the operand
  3508. * @returns the current updated Vector3
  3509. */
  3510. set(x: number, y: number, z: number): Vector3;
  3511. /**
  3512. * Copies the given float to the current Vector3 coordinates
  3513. * @param v defines the x, y and z coordinates of the operand
  3514. * @returns the current updated Vector3
  3515. */
  3516. setAll(v: number): Vector3;
  3517. /**
  3518. * Get the clip factor between two vectors
  3519. * @param vector0 defines the first operand
  3520. * @param vector1 defines the second operand
  3521. * @param axis defines the axis to use
  3522. * @param size defines the size along the axis
  3523. * @returns the clip factor
  3524. */
  3525. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3526. /**
  3527. * Get angle between two vectors
  3528. * @param vector0 angle between vector0 and vector1
  3529. * @param vector1 angle between vector0 and vector1
  3530. * @param normal direction of the normal
  3531. * @return the angle between vector0 and vector1
  3532. */
  3533. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3534. /**
  3535. * Returns a new Vector3 set from the index "offset" of the given array
  3536. * @param array defines the source array
  3537. * @param offset defines the offset in the source array
  3538. * @returns the new Vector3
  3539. */
  3540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3541. /**
  3542. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3543. * @param array defines the source array
  3544. * @param offset defines the offset in the source array
  3545. * @returns the new Vector3
  3546. * @deprecated Please use FromArray instead.
  3547. */
  3548. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3549. /**
  3550. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3551. * @param array defines the source array
  3552. * @param offset defines the offset in the source array
  3553. * @param result defines the Vector3 where to store the result
  3554. */
  3555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3556. /**
  3557. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3558. * @param array defines the source array
  3559. * @param offset defines the offset in the source array
  3560. * @param result defines the Vector3 where to store the result
  3561. * @deprecated Please use FromArrayToRef instead.
  3562. */
  3563. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3564. /**
  3565. * Sets the given vector "result" with the given floats.
  3566. * @param x defines the x coordinate of the source
  3567. * @param y defines the y coordinate of the source
  3568. * @param z defines the z coordinate of the source
  3569. * @param result defines the Vector3 where to store the result
  3570. */
  3571. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3572. /**
  3573. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3574. * @returns a new empty Vector3
  3575. */
  3576. static Zero(): Vector3;
  3577. /**
  3578. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3579. * @returns a new unit Vector3
  3580. */
  3581. static One(): Vector3;
  3582. /**
  3583. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3584. * @returns a new up Vector3
  3585. */
  3586. static Up(): Vector3;
  3587. /**
  3588. * Gets a up Vector3 that must not be updated
  3589. */
  3590. static get UpReadOnly(): DeepImmutable<Vector3>;
  3591. /**
  3592. * Gets a zero Vector3 that must not be updated
  3593. */
  3594. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3595. /**
  3596. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3597. * @returns a new down Vector3
  3598. */
  3599. static Down(): Vector3;
  3600. /**
  3601. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3602. * @param rightHandedSystem is the scene right-handed (negative z)
  3603. * @returns a new forward Vector3
  3604. */
  3605. static Forward(rightHandedSystem?: boolean): Vector3;
  3606. /**
  3607. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3608. * @param rightHandedSystem is the scene right-handed (negative-z)
  3609. * @returns a new forward Vector3
  3610. */
  3611. static Backward(rightHandedSystem?: boolean): Vector3;
  3612. /**
  3613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3614. * @returns a new right Vector3
  3615. */
  3616. static Right(): Vector3;
  3617. /**
  3618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3619. * @returns a new left Vector3
  3620. */
  3621. static Left(): Vector3;
  3622. /**
  3623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3625. * @param vector defines the Vector3 to transform
  3626. * @param transformation defines the transformation matrix
  3627. * @returns the transformed Vector3
  3628. */
  3629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3630. /**
  3631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3633. * @param vector defines the Vector3 to transform
  3634. * @param transformation defines the transformation matrix
  3635. * @param result defines the Vector3 where to store the result
  3636. */
  3637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3638. /**
  3639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3640. * This method computes tranformed coordinates only, not transformed direction vectors
  3641. * @param x define the x coordinate of the source vector
  3642. * @param y define the y coordinate of the source vector
  3643. * @param z define the z coordinate of the source vector
  3644. * @param transformation defines the transformation matrix
  3645. * @param result defines the Vector3 where to store the result
  3646. */
  3647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3648. /**
  3649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3651. * @param vector defines the Vector3 to transform
  3652. * @param transformation defines the transformation matrix
  3653. * @returns the new Vector3
  3654. */
  3655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3656. /**
  3657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3659. * @param vector defines the Vector3 to transform
  3660. * @param transformation defines the transformation matrix
  3661. * @param result defines the Vector3 where to store the result
  3662. */
  3663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3664. /**
  3665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3667. * @param x define the x coordinate of the source vector
  3668. * @param y define the y coordinate of the source vector
  3669. * @param z define the z coordinate of the source vector
  3670. * @param transformation defines the transformation matrix
  3671. * @param result defines the Vector3 where to store the result
  3672. */
  3673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3674. /**
  3675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3676. * @param value1 defines the first control point
  3677. * @param value2 defines the second control point
  3678. * @param value3 defines the third control point
  3679. * @param value4 defines the fourth control point
  3680. * @param amount defines the amount on the spline to use
  3681. * @returns the new Vector3
  3682. */
  3683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3684. /**
  3685. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3688. * @param value defines the current value
  3689. * @param min defines the lower range value
  3690. * @param max defines the upper range value
  3691. * @returns the new Vector3
  3692. */
  3693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3694. /**
  3695. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3698. * @param value defines the current value
  3699. * @param min defines the lower range value
  3700. * @param max defines the upper range value
  3701. * @param result defines the Vector3 where to store the result
  3702. */
  3703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3704. /**
  3705. * Checks if a given vector is inside a specific range
  3706. * @param v defines the vector to test
  3707. * @param min defines the minimum range
  3708. * @param max defines the maximum range
  3709. */
  3710. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3711. /**
  3712. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3713. * @param value1 defines the first control point
  3714. * @param tangent1 defines the first tangent vector
  3715. * @param value2 defines the second control point
  3716. * @param tangent2 defines the second tangent vector
  3717. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3718. * @returns the new Vector3
  3719. */
  3720. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3721. /**
  3722. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3723. * @param start defines the start value
  3724. * @param end defines the end value
  3725. * @param amount max defines amount between both (between 0 and 1)
  3726. * @returns the new Vector3
  3727. */
  3728. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3729. /**
  3730. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3731. * @param start defines the start value
  3732. * @param end defines the end value
  3733. * @param amount max defines amount between both (between 0 and 1)
  3734. * @param result defines the Vector3 where to store the result
  3735. */
  3736. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3737. /**
  3738. * Returns the dot product (float) between the vectors "left" and "right"
  3739. * @param left defines the left operand
  3740. * @param right defines the right operand
  3741. * @returns the dot product
  3742. */
  3743. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3744. /**
  3745. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3746. * The cross product is then orthogonal to both "left" and "right"
  3747. * @param left defines the left operand
  3748. * @param right defines the right operand
  3749. * @returns the cross product
  3750. */
  3751. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the cross product of "left" and "right"
  3754. * The cross product is then orthogonal to both "left" and "right"
  3755. * @param left defines the left operand
  3756. * @param right defines the right operand
  3757. * @param result defines the Vector3 where to store the result
  3758. */
  3759. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3760. /**
  3761. * Returns a new Vector3 as the normalization of the given vector
  3762. * @param vector defines the Vector3 to normalize
  3763. * @returns the new Vector3
  3764. */
  3765. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3766. /**
  3767. * Sets the given vector "result" with the normalization of the given first vector
  3768. * @param vector defines the Vector3 to normalize
  3769. * @param result defines the Vector3 where to store the result
  3770. */
  3771. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3772. /**
  3773. * Project a Vector3 onto screen space
  3774. * @param vector defines the Vector3 to project
  3775. * @param world defines the world matrix to use
  3776. * @param transform defines the transform (view x projection) matrix to use
  3777. * @param viewport defines the screen viewport to use
  3778. * @returns the new Vector3
  3779. */
  3780. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3781. /**
  3782. * Project a Vector3 onto screen space to reference
  3783. * @param vector defines the Vector3 to project
  3784. * @param world defines the world matrix to use
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @param viewport defines the screen viewport to use
  3787. * @param result the vector in which the screen space will be stored
  3788. * @returns the new Vector3
  3789. */
  3790. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3791. /** @hidden */
  3792. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3793. /**
  3794. * Unproject from screen space to object space
  3795. * @param source defines the screen space Vector3 to use
  3796. * @param viewportWidth defines the current width of the viewport
  3797. * @param viewportHeight defines the current height of the viewport
  3798. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3799. * @param transform defines the transform (view x projection) matrix to use
  3800. * @returns the new Vector3
  3801. */
  3802. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3803. /**
  3804. * Unproject from screen space to object space
  3805. * @param source defines the screen space Vector3 to use
  3806. * @param viewportWidth defines the current width of the viewport
  3807. * @param viewportHeight defines the current height of the viewport
  3808. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3809. * @param view defines the view matrix to use
  3810. * @param projection defines the projection matrix to use
  3811. * @returns the new Vector3
  3812. */
  3813. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3814. /**
  3815. * Unproject from screen space to object space
  3816. * @param source defines the screen space Vector3 to use
  3817. * @param viewportWidth defines the current width of the viewport
  3818. * @param viewportHeight defines the current height of the viewport
  3819. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3820. * @param view defines the view matrix to use
  3821. * @param projection defines the projection matrix to use
  3822. * @param result defines the Vector3 where to store the result
  3823. */
  3824. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3825. /**
  3826. * Unproject from screen space to object space
  3827. * @param sourceX defines the screen space x coordinate to use
  3828. * @param sourceY defines the screen space y coordinate to use
  3829. * @param sourceZ defines the screen space z coordinate to use
  3830. * @param viewportWidth defines the current width of the viewport
  3831. * @param viewportHeight defines the current height of the viewport
  3832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3833. * @param view defines the view matrix to use
  3834. * @param projection defines the projection matrix to use
  3835. * @param result defines the Vector3 where to store the result
  3836. */
  3837. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3838. /**
  3839. * Gets the minimal coordinate values between two Vector3
  3840. * @param left defines the first operand
  3841. * @param right defines the second operand
  3842. * @returns the new Vector3
  3843. */
  3844. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3845. /**
  3846. * Gets the maximal coordinate values between two Vector3
  3847. * @param left defines the first operand
  3848. * @param right defines the second operand
  3849. * @returns the new Vector3
  3850. */
  3851. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3852. /**
  3853. * Returns the distance between the vectors "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the distance
  3857. */
  3858. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3859. /**
  3860. * Returns the squared distance between the vectors "value1" and "value2"
  3861. * @param value1 defines the first operand
  3862. * @param value2 defines the second operand
  3863. * @returns the squared distance
  3864. */
  3865. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3866. /**
  3867. * Returns a new Vector3 located at the center between "value1" and "value2"
  3868. * @param value1 defines the first operand
  3869. * @param value2 defines the second operand
  3870. * @returns the new Vector3
  3871. */
  3872. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3873. /**
  3874. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3875. * @param value1 defines first vector
  3876. * @param value2 defines second vector
  3877. * @param ref defines third vector
  3878. * @returns ref
  3879. */
  3880. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3881. /**
  3882. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3883. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3884. * to something in order to rotate it from its local system to the given target system
  3885. * Note: axis1, axis2 and axis3 are normalized during this operation
  3886. * @param axis1 defines the first axis
  3887. * @param axis2 defines the second axis
  3888. * @param axis3 defines the third axis
  3889. * @returns a new Vector3
  3890. */
  3891. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3892. /**
  3893. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3894. * @param axis1 defines the first axis
  3895. * @param axis2 defines the second axis
  3896. * @param axis3 defines the third axis
  3897. * @param ref defines the Vector3 where to store the result
  3898. */
  3899. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3900. }
  3901. /**
  3902. * Vector4 class created for EulerAngle class conversion to Quaternion
  3903. */
  3904. export class Vector4 {
  3905. /** x value of the vector */
  3906. x: number;
  3907. /** y value of the vector */
  3908. y: number;
  3909. /** z value of the vector */
  3910. z: number;
  3911. /** w value of the vector */
  3912. w: number;
  3913. /**
  3914. * Creates a Vector4 object from the given floats.
  3915. * @param x x value of the vector
  3916. * @param y y value of the vector
  3917. * @param z z value of the vector
  3918. * @param w w value of the vector
  3919. */
  3920. constructor(
  3921. /** x value of the vector */
  3922. x: number,
  3923. /** y value of the vector */
  3924. y: number,
  3925. /** z value of the vector */
  3926. z: number,
  3927. /** w value of the vector */
  3928. w: number);
  3929. /**
  3930. * Returns the string with the Vector4 coordinates.
  3931. * @returns a string containing all the vector values
  3932. */
  3933. toString(): string;
  3934. /**
  3935. * Returns the string "Vector4".
  3936. * @returns "Vector4"
  3937. */
  3938. getClassName(): string;
  3939. /**
  3940. * Returns the Vector4 hash code.
  3941. * @returns a unique hash code
  3942. */
  3943. getHashCode(): number;
  3944. /**
  3945. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3946. * @returns the resulting array
  3947. */
  3948. asArray(): number[];
  3949. /**
  3950. * Populates the given array from the given index with the Vector4 coordinates.
  3951. * @param array array to populate
  3952. * @param index index of the array to start at (default: 0)
  3953. * @returns the Vector4.
  3954. */
  3955. toArray(array: FloatArray, index?: number): Vector4;
  3956. /**
  3957. * Update the current vector from an array
  3958. * @param array defines the destination array
  3959. * @param index defines the offset in the destination array
  3960. * @returns the current Vector3
  3961. */
  3962. fromArray(array: FloatArray, index?: number): Vector4;
  3963. /**
  3964. * Adds the given vector to the current Vector4.
  3965. * @param otherVector the vector to add
  3966. * @returns the updated Vector4.
  3967. */
  3968. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3969. /**
  3970. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3971. * @param otherVector the vector to add
  3972. * @returns the resulting vector
  3973. */
  3974. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3975. /**
  3976. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3977. * @param otherVector the vector to add
  3978. * @param result the vector to store the result
  3979. * @returns the current Vector4.
  3980. */
  3981. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3982. /**
  3983. * Subtract in place the given vector from the current Vector4.
  3984. * @param otherVector the vector to subtract
  3985. * @returns the updated Vector4.
  3986. */
  3987. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3988. /**
  3989. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3990. * @param otherVector the vector to add
  3991. * @returns the new vector with the result
  3992. */
  3993. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3994. /**
  3995. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3996. * @param otherVector the vector to subtract
  3997. * @param result the vector to store the result
  3998. * @returns the current Vector4.
  3999. */
  4000. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4001. /**
  4002. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4003. */
  4004. /**
  4005. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4006. * @param x value to subtract
  4007. * @param y value to subtract
  4008. * @param z value to subtract
  4009. * @param w value to subtract
  4010. * @returns new vector containing the result
  4011. */
  4012. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4013. /**
  4014. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4015. * @param x value to subtract
  4016. * @param y value to subtract
  4017. * @param z value to subtract
  4018. * @param w value to subtract
  4019. * @param result the vector to store the result in
  4020. * @returns the current Vector4.
  4021. */
  4022. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4023. /**
  4024. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4025. * @returns a new vector with the negated values
  4026. */
  4027. negate(): Vector4;
  4028. /**
  4029. * Negate this vector in place
  4030. * @returns this
  4031. */
  4032. negateInPlace(): Vector4;
  4033. /**
  4034. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4035. * @param result defines the Vector3 object where to store the result
  4036. * @returns the current Vector4
  4037. */
  4038. negateToRef(result: Vector4): Vector4;
  4039. /**
  4040. * Multiplies the current Vector4 coordinates by scale (float).
  4041. * @param scale the number to scale with
  4042. * @returns the updated Vector4.
  4043. */
  4044. scaleInPlace(scale: number): Vector4;
  4045. /**
  4046. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4047. * @param scale the number to scale with
  4048. * @returns a new vector with the result
  4049. */
  4050. scale(scale: number): Vector4;
  4051. /**
  4052. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4053. * @param scale the number to scale with
  4054. * @param result a vector to store the result in
  4055. * @returns the current Vector4.
  4056. */
  4057. scaleToRef(scale: number, result: Vector4): Vector4;
  4058. /**
  4059. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4060. * @param scale defines the scale factor
  4061. * @param result defines the Vector4 object where to store the result
  4062. * @returns the unmodified current Vector4
  4063. */
  4064. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4065. /**
  4066. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4067. * @param otherVector the vector to compare against
  4068. * @returns true if they are equal
  4069. */
  4070. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4071. /**
  4072. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4073. * @param otherVector vector to compare against
  4074. * @param epsilon (Default: very small number)
  4075. * @returns true if they are equal
  4076. */
  4077. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4078. /**
  4079. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4080. * @param x x value to compare against
  4081. * @param y y value to compare against
  4082. * @param z z value to compare against
  4083. * @param w w value to compare against
  4084. * @returns true if equal
  4085. */
  4086. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4087. /**
  4088. * Multiplies in place the current Vector4 by the given one.
  4089. * @param otherVector vector to multiple with
  4090. * @returns the updated Vector4.
  4091. */
  4092. multiplyInPlace(otherVector: Vector4): Vector4;
  4093. /**
  4094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4095. * @param otherVector vector to multiple with
  4096. * @returns resulting new vector
  4097. */
  4098. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4099. /**
  4100. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4101. * @param otherVector vector to multiple with
  4102. * @param result vector to store the result
  4103. * @returns the current Vector4.
  4104. */
  4105. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4106. /**
  4107. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4108. * @param x x value multiply with
  4109. * @param y y value multiply with
  4110. * @param z z value multiply with
  4111. * @param w w value multiply with
  4112. * @returns resulting new vector
  4113. */
  4114. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4115. /**
  4116. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4117. * @param otherVector vector to devide with
  4118. * @returns resulting new vector
  4119. */
  4120. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4121. /**
  4122. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4123. * @param otherVector vector to devide with
  4124. * @param result vector to store the result
  4125. * @returns the current Vector4.
  4126. */
  4127. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4128. /**
  4129. * Divides the current Vector3 coordinates by the given ones.
  4130. * @param otherVector vector to devide with
  4131. * @returns the updated Vector3.
  4132. */
  4133. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4134. /**
  4135. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4136. * @param other defines the second operand
  4137. * @returns the current updated Vector4
  4138. */
  4139. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4140. /**
  4141. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4142. * @param other defines the second operand
  4143. * @returns the current updated Vector4
  4144. */
  4145. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4146. /**
  4147. * Gets a new Vector4 from current Vector4 floored values
  4148. * @returns a new Vector4
  4149. */
  4150. floor(): Vector4;
  4151. /**
  4152. * Gets a new Vector4 from current Vector3 floored values
  4153. * @returns a new Vector4
  4154. */
  4155. fract(): Vector4;
  4156. /**
  4157. * Returns the Vector4 length (float).
  4158. * @returns the length
  4159. */
  4160. length(): number;
  4161. /**
  4162. * Returns the Vector4 squared length (float).
  4163. * @returns the length squared
  4164. */
  4165. lengthSquared(): number;
  4166. /**
  4167. * Normalizes in place the Vector4.
  4168. * @returns the updated Vector4.
  4169. */
  4170. normalize(): Vector4;
  4171. /**
  4172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4173. * @returns this converted to a new vector3
  4174. */
  4175. toVector3(): Vector3;
  4176. /**
  4177. * Returns a new Vector4 copied from the current one.
  4178. * @returns the new cloned vector
  4179. */
  4180. clone(): Vector4;
  4181. /**
  4182. * Updates the current Vector4 with the given one coordinates.
  4183. * @param source the source vector to copy from
  4184. * @returns the updated Vector4.
  4185. */
  4186. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4187. /**
  4188. * Updates the current Vector4 coordinates with the given floats.
  4189. * @param x float to copy from
  4190. * @param y float to copy from
  4191. * @param z float to copy from
  4192. * @param w float to copy from
  4193. * @returns the updated Vector4.
  4194. */
  4195. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4196. /**
  4197. * Updates the current Vector4 coordinates with the given floats.
  4198. * @param x float to set from
  4199. * @param y float to set from
  4200. * @param z float to set from
  4201. * @param w float to set from
  4202. * @returns the updated Vector4.
  4203. */
  4204. set(x: number, y: number, z: number, w: number): Vector4;
  4205. /**
  4206. * Copies the given float to the current Vector3 coordinates
  4207. * @param v defines the x, y, z and w coordinates of the operand
  4208. * @returns the current updated Vector3
  4209. */
  4210. setAll(v: number): Vector4;
  4211. /**
  4212. * Returns a new Vector4 set from the starting index of the given array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @returns the new vector
  4216. */
  4217. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4218. /**
  4219. * Updates the given vector "result" from the starting index of the given array.
  4220. * @param array the array to pull values from
  4221. * @param offset the offset into the array to start at
  4222. * @param result the vector to store the result in
  4223. */
  4224. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4225. /**
  4226. * Updates the given vector "result" from the starting index of the given Float32Array.
  4227. * @param array the array to pull values from
  4228. * @param offset the offset into the array to start at
  4229. * @param result the vector to store the result in
  4230. */
  4231. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4232. /**
  4233. * Updates the given vector "result" coordinates from the given floats.
  4234. * @param x float to set from
  4235. * @param y float to set from
  4236. * @param z float to set from
  4237. * @param w float to set from
  4238. * @param result the vector to the floats in
  4239. */
  4240. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4241. /**
  4242. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4243. * @returns the new vector
  4244. */
  4245. static Zero(): Vector4;
  4246. /**
  4247. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4248. * @returns the new vector
  4249. */
  4250. static One(): Vector4;
  4251. /**
  4252. * Returns a new normalized Vector4 from the given one.
  4253. * @param vector the vector to normalize
  4254. * @returns the vector
  4255. */
  4256. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4257. /**
  4258. * Updates the given vector "result" from the normalization of the given one.
  4259. * @param vector the vector to normalize
  4260. * @param result the vector to store the result in
  4261. */
  4262. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4263. /**
  4264. * Returns a vector with the minimum values from the left and right vectors
  4265. * @param left left vector to minimize
  4266. * @param right right vector to minimize
  4267. * @returns a new vector with the minimum of the left and right vector values
  4268. */
  4269. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4270. /**
  4271. * Returns a vector with the maximum values from the left and right vectors
  4272. * @param left left vector to maximize
  4273. * @param right right vector to maximize
  4274. * @returns a new vector with the maximum of the left and right vector values
  4275. */
  4276. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4277. /**
  4278. * Returns the distance (float) between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the distance between
  4280. * @param value2 value to calulate the distance between
  4281. * @return the distance between the two vectors
  4282. */
  4283. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4284. /**
  4285. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4286. * @param value1 value to calulate the distance between
  4287. * @param value2 value to calulate the distance between
  4288. * @return the distance between the two vectors squared
  4289. */
  4290. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4291. /**
  4292. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4293. * @param value1 value to calulate the center between
  4294. * @param value2 value to calulate the center between
  4295. * @return the center between the two vectors
  4296. */
  4297. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4298. /**
  4299. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4300. * @param value1 defines first vector
  4301. * @param value2 defines second vector
  4302. * @param ref defines third vector
  4303. * @returns ref
  4304. */
  4305. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4306. /**
  4307. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4308. * This methods computes transformed normalized direction vectors only.
  4309. * @param vector the vector to transform
  4310. * @param transformation the transformation matrix to apply
  4311. * @returns the new vector
  4312. */
  4313. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4314. /**
  4315. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4316. * This methods computes transformed normalized direction vectors only.
  4317. * @param vector the vector to transform
  4318. * @param transformation the transformation matrix to apply
  4319. * @param result the vector to store the result in
  4320. */
  4321. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4322. /**
  4323. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4324. * This methods computes transformed normalized direction vectors only.
  4325. * @param x value to transform
  4326. * @param y value to transform
  4327. * @param z value to transform
  4328. * @param w value to transform
  4329. * @param transformation the transformation matrix to apply
  4330. * @param result the vector to store the results in
  4331. */
  4332. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4333. /**
  4334. * Creates a new Vector4 from a Vector3
  4335. * @param source defines the source data
  4336. * @param w defines the 4th component (default is 0)
  4337. * @returns a new Vector4
  4338. */
  4339. static FromVector3(source: Vector3, w?: number): Vector4;
  4340. }
  4341. /**
  4342. * Class used to store quaternion data
  4343. * @see https://en.wikipedia.org/wiki/Quaternion
  4344. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4345. */
  4346. export class Quaternion {
  4347. /** @hidden */
  4348. _x: number;
  4349. /** @hidden */
  4350. _y: number;
  4351. /** @hidden */
  4352. _z: number;
  4353. /** @hidden */
  4354. _w: number;
  4355. /** @hidden */
  4356. _isDirty: boolean;
  4357. /** Gets or sets the x coordinate */
  4358. get x(): number;
  4359. set x(value: number);
  4360. /** Gets or sets the y coordinate */
  4361. get y(): number;
  4362. set y(value: number);
  4363. /** Gets or sets the z coordinate */
  4364. get z(): number;
  4365. set z(value: number);
  4366. /** Gets or sets the w coordinate */
  4367. get w(): number;
  4368. set w(value: number);
  4369. /**
  4370. * Creates a new Quaternion from the given floats
  4371. * @param x defines the first component (0 by default)
  4372. * @param y defines the second component (0 by default)
  4373. * @param z defines the third component (0 by default)
  4374. * @param w defines the fourth component (1.0 by default)
  4375. */
  4376. constructor(x?: number, y?: number, z?: number, w?: number);
  4377. /**
  4378. * Gets a string representation for the current quaternion
  4379. * @returns a string with the Quaternion coordinates
  4380. */
  4381. toString(): string;
  4382. /**
  4383. * Gets the class name of the quaternion
  4384. * @returns the string "Quaternion"
  4385. */
  4386. getClassName(): string;
  4387. /**
  4388. * Gets a hash code for this quaternion
  4389. * @returns the quaternion hash code
  4390. */
  4391. getHashCode(): number;
  4392. /**
  4393. * Copy the quaternion to an array
  4394. * @returns a new array populated with 4 elements from the quaternion coordinates
  4395. */
  4396. asArray(): number[];
  4397. /**
  4398. * Check if two quaternions are equals
  4399. * @param otherQuaternion defines the second operand
  4400. * @return true if the current quaternion and the given one coordinates are strictly equals
  4401. */
  4402. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4403. /**
  4404. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4405. * @param otherQuaternion defines the other quaternion
  4406. * @param epsilon defines the minimal distance to consider equality
  4407. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4408. */
  4409. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4410. /**
  4411. * Clone the current quaternion
  4412. * @returns a new quaternion copied from the current one
  4413. */
  4414. clone(): Quaternion;
  4415. /**
  4416. * Copy a quaternion to the current one
  4417. * @param other defines the other quaternion
  4418. * @returns the updated current quaternion
  4419. */
  4420. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4421. /**
  4422. * Updates the current quaternion with the given float coordinates
  4423. * @param x defines the x coordinate
  4424. * @param y defines the y coordinate
  4425. * @param z defines the z coordinate
  4426. * @param w defines the w coordinate
  4427. * @returns the updated current quaternion
  4428. */
  4429. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4430. /**
  4431. * Updates the current quaternion from the given float coordinates
  4432. * @param x defines the x coordinate
  4433. * @param y defines the y coordinate
  4434. * @param z defines the z coordinate
  4435. * @param w defines the w coordinate
  4436. * @returns the updated current quaternion
  4437. */
  4438. set(x: number, y: number, z: number, w: number): Quaternion;
  4439. /**
  4440. * Adds two quaternions
  4441. * @param other defines the second operand
  4442. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4443. */
  4444. add(other: DeepImmutable<Quaternion>): Quaternion;
  4445. /**
  4446. * Add a quaternion to the current one
  4447. * @param other defines the quaternion to add
  4448. * @returns the current quaternion
  4449. */
  4450. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4451. /**
  4452. * Subtract two quaternions
  4453. * @param other defines the second operand
  4454. * @returns a new quaternion as the subtraction result of the given one from the current one
  4455. */
  4456. subtract(other: Quaternion): Quaternion;
  4457. /**
  4458. * Multiplies the current quaternion by a scale factor
  4459. * @param value defines the scale factor
  4460. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4461. */
  4462. scale(value: number): Quaternion;
  4463. /**
  4464. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4465. * @param scale defines the scale factor
  4466. * @param result defines the Quaternion object where to store the result
  4467. * @returns the unmodified current quaternion
  4468. */
  4469. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4470. /**
  4471. * Multiplies in place the current quaternion by a scale factor
  4472. * @param value defines the scale factor
  4473. * @returns the current modified quaternion
  4474. */
  4475. scaleInPlace(value: number): Quaternion;
  4476. /**
  4477. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4478. * @param scale defines the scale factor
  4479. * @param result defines the Quaternion object where to store the result
  4480. * @returns the unmodified current quaternion
  4481. */
  4482. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4483. /**
  4484. * Multiplies two quaternions
  4485. * @param q1 defines the second operand
  4486. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4487. */
  4488. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4489. /**
  4490. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4491. * @param q1 defines the second operand
  4492. * @param result defines the target quaternion
  4493. * @returns the current quaternion
  4494. */
  4495. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4496. /**
  4497. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4498. * @param q1 defines the second operand
  4499. * @returns the currentupdated quaternion
  4500. */
  4501. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4502. /**
  4503. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4504. * @param ref defines the target quaternion
  4505. * @returns the current quaternion
  4506. */
  4507. conjugateToRef(ref: Quaternion): Quaternion;
  4508. /**
  4509. * Conjugates in place (1-q) the current quaternion
  4510. * @returns the current updated quaternion
  4511. */
  4512. conjugateInPlace(): Quaternion;
  4513. /**
  4514. * Conjugates in place (1-q) the current quaternion
  4515. * @returns a new quaternion
  4516. */
  4517. conjugate(): Quaternion;
  4518. /**
  4519. * Gets length of current quaternion
  4520. * @returns the quaternion length (float)
  4521. */
  4522. length(): number;
  4523. /**
  4524. * Normalize in place the current quaternion
  4525. * @returns the current updated quaternion
  4526. */
  4527. normalize(): Quaternion;
  4528. /**
  4529. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4530. * @param order is a reserved parameter and is ignored for now
  4531. * @returns a new Vector3 containing the Euler angles
  4532. */
  4533. toEulerAngles(order?: string): Vector3;
  4534. /**
  4535. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4536. * @param result defines the vector which will be filled with the Euler angles
  4537. * @returns the current unchanged quaternion
  4538. */
  4539. toEulerAnglesToRef(result: Vector3): Quaternion;
  4540. /**
  4541. * Updates the given rotation matrix with the current quaternion values
  4542. * @param result defines the target matrix
  4543. * @returns the current unchanged quaternion
  4544. */
  4545. toRotationMatrix(result: Matrix): Quaternion;
  4546. /**
  4547. * Updates the current quaternion from the given rotation matrix values
  4548. * @param matrix defines the source matrix
  4549. * @returns the current updated quaternion
  4550. */
  4551. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4552. /**
  4553. * Creates a new quaternion from a rotation matrix
  4554. * @param matrix defines the source matrix
  4555. * @returns a new quaternion created from the given rotation matrix values
  4556. */
  4557. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4558. /**
  4559. * Updates the given quaternion with the given rotation matrix values
  4560. * @param matrix defines the source matrix
  4561. * @param result defines the target quaternion
  4562. */
  4563. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4564. /**
  4565. * Returns the dot product (float) between the quaternions "left" and "right"
  4566. * @param left defines the left operand
  4567. * @param right defines the right operand
  4568. * @returns the dot product
  4569. */
  4570. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4571. /**
  4572. * Checks if the two quaternions are close to each other
  4573. * @param quat0 defines the first quaternion to check
  4574. * @param quat1 defines the second quaternion to check
  4575. * @returns true if the two quaternions are close to each other
  4576. */
  4577. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4578. /**
  4579. * Creates an empty quaternion
  4580. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4581. */
  4582. static Zero(): Quaternion;
  4583. /**
  4584. * Inverse a given quaternion
  4585. * @param q defines the source quaternion
  4586. * @returns a new quaternion as the inverted current quaternion
  4587. */
  4588. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4589. /**
  4590. * Inverse a given quaternion
  4591. * @param q defines the source quaternion
  4592. * @param result the quaternion the result will be stored in
  4593. * @returns the result quaternion
  4594. */
  4595. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4596. /**
  4597. * Creates an identity quaternion
  4598. * @returns the identity quaternion
  4599. */
  4600. static Identity(): Quaternion;
  4601. /**
  4602. * Gets a boolean indicating if the given quaternion is identity
  4603. * @param quaternion defines the quaternion to check
  4604. * @returns true if the quaternion is identity
  4605. */
  4606. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4607. /**
  4608. * Creates a quaternion from a rotation around an axis
  4609. * @param axis defines the axis to use
  4610. * @param angle defines the angle to use
  4611. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4612. */
  4613. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4614. /**
  4615. * Creates a rotation around an axis and stores it into the given quaternion
  4616. * @param axis defines the axis to use
  4617. * @param angle defines the angle to use
  4618. * @param result defines the target quaternion
  4619. * @returns the target quaternion
  4620. */
  4621. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4622. /**
  4623. * Creates a new quaternion from data stored into an array
  4624. * @param array defines the data source
  4625. * @param offset defines the offset in the source array where the data starts
  4626. * @returns a new quaternion
  4627. */
  4628. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4629. /**
  4630. * Updates the given quaternion "result" from the starting index of the given array.
  4631. * @param array the array to pull values from
  4632. * @param offset the offset into the array to start at
  4633. * @param result the quaternion to store the result in
  4634. */
  4635. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4636. /**
  4637. * Create a quaternion from Euler rotation angles
  4638. * @param x Pitch
  4639. * @param y Yaw
  4640. * @param z Roll
  4641. * @returns the new Quaternion
  4642. */
  4643. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4644. /**
  4645. * Updates a quaternion from Euler rotation angles
  4646. * @param x Pitch
  4647. * @param y Yaw
  4648. * @param z Roll
  4649. * @param result the quaternion to store the result
  4650. * @returns the updated quaternion
  4651. */
  4652. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4653. /**
  4654. * Create a quaternion from Euler rotation vector
  4655. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4656. * @returns the new Quaternion
  4657. */
  4658. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4659. /**
  4660. * Updates a quaternion from Euler rotation vector
  4661. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4662. * @param result the quaternion to store the result
  4663. * @returns the updated quaternion
  4664. */
  4665. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4666. /**
  4667. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  4668. * @param vecFrom defines the direction vector from which to rotate
  4669. * @param vecTo defines the direction vector to which to rotate
  4670. * @param result the quaternion to store the result
  4671. * @returns the updated quaternion
  4672. */
  4673. static FromUnitVectorsToRef(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4674. /**
  4675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4676. * @param yaw defines the rotation around Y axis
  4677. * @param pitch defines the rotation around X axis
  4678. * @param roll defines the rotation around Z axis
  4679. * @returns the new quaternion
  4680. */
  4681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4682. /**
  4683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4684. * @param yaw defines the rotation around Y axis
  4685. * @param pitch defines the rotation around X axis
  4686. * @param roll defines the rotation around Z axis
  4687. * @param result defines the target quaternion
  4688. */
  4689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4690. /**
  4691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4692. * @param alpha defines the rotation around first axis
  4693. * @param beta defines the rotation around second axis
  4694. * @param gamma defines the rotation around third axis
  4695. * @returns the new quaternion
  4696. */
  4697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4698. /**
  4699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4700. * @param alpha defines the rotation around first axis
  4701. * @param beta defines the rotation around second axis
  4702. * @param gamma defines the rotation around third axis
  4703. * @param result defines the target quaternion
  4704. */
  4705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4706. /**
  4707. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4708. * @param axis1 defines the first axis
  4709. * @param axis2 defines the second axis
  4710. * @param axis3 defines the third axis
  4711. * @returns the new quaternion
  4712. */
  4713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4714. /**
  4715. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4716. * @param axis1 defines the first axis
  4717. * @param axis2 defines the second axis
  4718. * @param axis3 defines the third axis
  4719. * @param ref defines the target quaternion
  4720. */
  4721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4722. /**
  4723. * Interpolates between two quaternions
  4724. * @param left defines first quaternion
  4725. * @param right defines second quaternion
  4726. * @param amount defines the gradient to use
  4727. * @returns the new interpolated quaternion
  4728. */
  4729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4730. /**
  4731. * Interpolates between two quaternions and stores it into a target quaternion
  4732. * @param left defines first quaternion
  4733. * @param right defines second quaternion
  4734. * @param amount defines the gradient to use
  4735. * @param result defines the target quaternion
  4736. */
  4737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4738. /**
  4739. * Interpolate between two quaternions using Hermite interpolation
  4740. * @param value1 defines first quaternion
  4741. * @param tangent1 defines the incoming tangent
  4742. * @param value2 defines second quaternion
  4743. * @param tangent2 defines the outgoing tangent
  4744. * @param amount defines the target quaternion
  4745. * @returns the new interpolated quaternion
  4746. */
  4747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4748. }
  4749. /**
  4750. * Class used to store matrix data (4x4)
  4751. */
  4752. export class Matrix {
  4753. /**
  4754. * Gets the precision of matrix computations
  4755. */
  4756. static get Use64Bits(): boolean;
  4757. private static _updateFlagSeed;
  4758. private static _identityReadOnly;
  4759. private _isIdentity;
  4760. private _isIdentityDirty;
  4761. private _isIdentity3x2;
  4762. private _isIdentity3x2Dirty;
  4763. /**
  4764. * Gets the update flag of the matrix which is an unique number for the matrix.
  4765. * It will be incremented every time the matrix data change.
  4766. * You can use it to speed the comparison between two versions of the same matrix.
  4767. */
  4768. updateFlag: number;
  4769. private readonly _m;
  4770. /**
  4771. * Gets the internal data of the matrix
  4772. */
  4773. get m(): DeepImmutable<Float32Array | Array<number>>;
  4774. /** @hidden */
  4775. _markAsUpdated(): void;
  4776. /** @hidden */
  4777. private _updateIdentityStatus;
  4778. /**
  4779. * Creates an empty matrix (filled with zeros)
  4780. */
  4781. constructor();
  4782. /**
  4783. * Check if the current matrix is identity
  4784. * @returns true is the matrix is the identity matrix
  4785. */
  4786. isIdentity(): boolean;
  4787. /**
  4788. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4789. * @returns true is the matrix is the identity matrix
  4790. */
  4791. isIdentityAs3x2(): boolean;
  4792. /**
  4793. * Gets the determinant of the matrix
  4794. * @returns the matrix determinant
  4795. */
  4796. determinant(): number;
  4797. /**
  4798. * Returns the matrix as a Float32Array or Array<number>
  4799. * @returns the matrix underlying array
  4800. */
  4801. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4802. /**
  4803. * Returns the matrix as a Float32Array or Array<number>
  4804. * @returns the matrix underlying array.
  4805. */
  4806. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4807. /**
  4808. * Inverts the current matrix in place
  4809. * @returns the current inverted matrix
  4810. */
  4811. invert(): Matrix;
  4812. /**
  4813. * Sets all the matrix elements to zero
  4814. * @returns the current matrix
  4815. */
  4816. reset(): Matrix;
  4817. /**
  4818. * Adds the current matrix with a second one
  4819. * @param other defines the matrix to add
  4820. * @returns a new matrix as the addition of the current matrix and the given one
  4821. */
  4822. add(other: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4825. * @param other defines the matrix to add
  4826. * @param result defines the target matrix
  4827. * @returns the current matrix
  4828. */
  4829. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4830. /**
  4831. * Adds in place the given matrix to the current matrix
  4832. * @param other defines the second operand
  4833. * @returns the current updated matrix
  4834. */
  4835. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4836. /**
  4837. * Sets the given matrix to the current inverted Matrix
  4838. * @param other defines the target matrix
  4839. * @returns the unmodified current matrix
  4840. */
  4841. invertToRef(other: Matrix): Matrix;
  4842. /**
  4843. * add a value at the specified position in the current Matrix
  4844. * @param index the index of the value within the matrix. between 0 and 15.
  4845. * @param value the value to be added
  4846. * @returns the current updated matrix
  4847. */
  4848. addAtIndex(index: number, value: number): Matrix;
  4849. /**
  4850. * mutiply the specified position in the current Matrix by a value
  4851. * @param index the index of the value within the matrix. between 0 and 15.
  4852. * @param value the value to be added
  4853. * @returns the current updated matrix
  4854. */
  4855. multiplyAtIndex(index: number, value: number): Matrix;
  4856. /**
  4857. * Inserts the translation vector (using 3 floats) in the current matrix
  4858. * @param x defines the 1st component of the translation
  4859. * @param y defines the 2nd component of the translation
  4860. * @param z defines the 3rd component of the translation
  4861. * @returns the current updated matrix
  4862. */
  4863. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4864. /**
  4865. * Adds the translation vector (using 3 floats) in the current matrix
  4866. * @param x defines the 1st component of the translation
  4867. * @param y defines the 2nd component of the translation
  4868. * @param z defines the 3rd component of the translation
  4869. * @returns the current updated matrix
  4870. */
  4871. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4872. /**
  4873. * Inserts the translation vector in the current matrix
  4874. * @param vector3 defines the translation to insert
  4875. * @returns the current updated matrix
  4876. */
  4877. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4878. /**
  4879. * Gets the translation value of the current matrix
  4880. * @returns a new Vector3 as the extracted translation from the matrix
  4881. */
  4882. getTranslation(): Vector3;
  4883. /**
  4884. * Fill a Vector3 with the extracted translation from the matrix
  4885. * @param result defines the Vector3 where to store the translation
  4886. * @returns the current matrix
  4887. */
  4888. getTranslationToRef(result: Vector3): Matrix;
  4889. /**
  4890. * Remove rotation and scaling part from the matrix
  4891. * @returns the updated matrix
  4892. */
  4893. removeRotationAndScaling(): Matrix;
  4894. /**
  4895. * Multiply two matrices
  4896. * @param other defines the second operand
  4897. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4898. */
  4899. multiply(other: DeepImmutable<Matrix>): Matrix;
  4900. /**
  4901. * Copy the current matrix from the given one
  4902. * @param other defines the source matrix
  4903. * @returns the current updated matrix
  4904. */
  4905. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4906. /**
  4907. * Populates the given array from the starting index with the current matrix values
  4908. * @param array defines the target array
  4909. * @param offset defines the offset in the target array where to start storing values
  4910. * @returns the current matrix
  4911. */
  4912. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4913. /**
  4914. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4915. * @param other defines the second operand
  4916. * @param result defines the matrix where to store the multiplication
  4917. * @returns the current matrix
  4918. */
  4919. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4920. /**
  4921. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4922. * @param other defines the second operand
  4923. * @param result defines the array where to store the multiplication
  4924. * @param offset defines the offset in the target array where to start storing values
  4925. * @returns the current matrix
  4926. */
  4927. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4928. /**
  4929. * Check equality between this matrix and a second one
  4930. * @param value defines the second matrix to compare
  4931. * @returns true is the current matrix and the given one values are strictly equal
  4932. */
  4933. equals(value: DeepImmutable<Matrix>): boolean;
  4934. /**
  4935. * Clone the current matrix
  4936. * @returns a new matrix from the current matrix
  4937. */
  4938. clone(): Matrix;
  4939. /**
  4940. * Returns the name of the current matrix class
  4941. * @returns the string "Matrix"
  4942. */
  4943. getClassName(): string;
  4944. /**
  4945. * Gets the hash code of the current matrix
  4946. * @returns the hash code
  4947. */
  4948. getHashCode(): number;
  4949. /**
  4950. * Decomposes the current Matrix into a translation, rotation and scaling components
  4951. * @param scale defines the scale vector3 given as a reference to update
  4952. * @param rotation defines the rotation quaternion given as a reference to update
  4953. * @param translation defines the translation vector3 given as a reference to update
  4954. * @returns true if operation was successful
  4955. */
  4956. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4957. /**
  4958. * Gets specific row of the matrix
  4959. * @param index defines the number of the row to get
  4960. * @returns the index-th row of the current matrix as a new Vector4
  4961. */
  4962. getRow(index: number): Nullable<Vector4>;
  4963. /**
  4964. * Sets the index-th row of the current matrix to the vector4 values
  4965. * @param index defines the number of the row to set
  4966. * @param row defines the target vector4
  4967. * @returns the updated current matrix
  4968. */
  4969. setRow(index: number, row: Vector4): Matrix;
  4970. /**
  4971. * Compute the transpose of the matrix
  4972. * @returns the new transposed matrix
  4973. */
  4974. transpose(): Matrix;
  4975. /**
  4976. * Compute the transpose of the matrix and store it in a given matrix
  4977. * @param result defines the target matrix
  4978. * @returns the current matrix
  4979. */
  4980. transposeToRef(result: Matrix): Matrix;
  4981. /**
  4982. * Sets the index-th row of the current matrix with the given 4 x float values
  4983. * @param index defines the row index
  4984. * @param x defines the x component to set
  4985. * @param y defines the y component to set
  4986. * @param z defines the z component to set
  4987. * @param w defines the w component to set
  4988. * @returns the updated current matrix
  4989. */
  4990. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4991. /**
  4992. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4993. * @param scale defines the scale factor
  4994. * @returns a new matrix
  4995. */
  4996. scale(scale: number): Matrix;
  4997. /**
  4998. * Scale the current matrix values by a factor to a given result matrix
  4999. * @param scale defines the scale factor
  5000. * @param result defines the matrix to store the result
  5001. * @returns the current matrix
  5002. */
  5003. scaleToRef(scale: number, result: Matrix): Matrix;
  5004. /**
  5005. * Scale the current matrix values by a factor and add the result to a given matrix
  5006. * @param scale defines the scale factor
  5007. * @param result defines the Matrix to store the result
  5008. * @returns the current matrix
  5009. */
  5010. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  5011. /**
  5012. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  5013. * @param ref matrix to store the result
  5014. */
  5015. toNormalMatrix(ref: Matrix): void;
  5016. /**
  5017. * Gets only rotation part of the current matrix
  5018. * @returns a new matrix sets to the extracted rotation matrix from the current one
  5019. */
  5020. getRotationMatrix(): Matrix;
  5021. /**
  5022. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5023. * @param result defines the target matrix to store data to
  5024. * @returns the current matrix
  5025. */
  5026. getRotationMatrixToRef(result: Matrix): Matrix;
  5027. /**
  5028. * Toggles model matrix from being right handed to left handed in place and vice versa
  5029. */
  5030. toggleModelMatrixHandInPlace(): void;
  5031. /**
  5032. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5033. */
  5034. toggleProjectionMatrixHandInPlace(): void;
  5035. /**
  5036. * Creates a matrix from an array
  5037. * @param array defines the source array
  5038. * @param offset defines an offset in the source array
  5039. * @returns a new Matrix set from the starting index of the given array
  5040. */
  5041. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5042. /**
  5043. * Copy the content of an array into a given matrix
  5044. * @param array defines the source array
  5045. * @param offset defines an offset in the source array
  5046. * @param result defines the target matrix
  5047. */
  5048. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5049. /**
  5050. * Stores an array into a matrix after having multiplied each component by a given factor
  5051. * @param array defines the source array
  5052. * @param offset defines the offset in the source array
  5053. * @param scale defines the scaling factor
  5054. * @param result defines the target matrix
  5055. */
  5056. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5057. /**
  5058. * Gets an identity matrix that must not be updated
  5059. */
  5060. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5061. /**
  5062. * Stores a list of values (16) inside a given matrix
  5063. * @param initialM11 defines 1st value of 1st row
  5064. * @param initialM12 defines 2nd value of 1st row
  5065. * @param initialM13 defines 3rd value of 1st row
  5066. * @param initialM14 defines 4th value of 1st row
  5067. * @param initialM21 defines 1st value of 2nd row
  5068. * @param initialM22 defines 2nd value of 2nd row
  5069. * @param initialM23 defines 3rd value of 2nd row
  5070. * @param initialM24 defines 4th value of 2nd row
  5071. * @param initialM31 defines 1st value of 3rd row
  5072. * @param initialM32 defines 2nd value of 3rd row
  5073. * @param initialM33 defines 3rd value of 3rd row
  5074. * @param initialM34 defines 4th value of 3rd row
  5075. * @param initialM41 defines 1st value of 4th row
  5076. * @param initialM42 defines 2nd value of 4th row
  5077. * @param initialM43 defines 3rd value of 4th row
  5078. * @param initialM44 defines 4th value of 4th row
  5079. * @param result defines the target matrix
  5080. */
  5081. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5082. /**
  5083. * Creates new matrix from a list of values (16)
  5084. * @param initialM11 defines 1st value of 1st row
  5085. * @param initialM12 defines 2nd value of 1st row
  5086. * @param initialM13 defines 3rd value of 1st row
  5087. * @param initialM14 defines 4th value of 1st row
  5088. * @param initialM21 defines 1st value of 2nd row
  5089. * @param initialM22 defines 2nd value of 2nd row
  5090. * @param initialM23 defines 3rd value of 2nd row
  5091. * @param initialM24 defines 4th value of 2nd row
  5092. * @param initialM31 defines 1st value of 3rd row
  5093. * @param initialM32 defines 2nd value of 3rd row
  5094. * @param initialM33 defines 3rd value of 3rd row
  5095. * @param initialM34 defines 4th value of 3rd row
  5096. * @param initialM41 defines 1st value of 4th row
  5097. * @param initialM42 defines 2nd value of 4th row
  5098. * @param initialM43 defines 3rd value of 4th row
  5099. * @param initialM44 defines 4th value of 4th row
  5100. * @returns the new matrix
  5101. */
  5102. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5103. /**
  5104. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5105. * @param scale defines the scale vector3
  5106. * @param rotation defines the rotation quaternion
  5107. * @param translation defines the translation vector3
  5108. * @returns a new matrix
  5109. */
  5110. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5111. /**
  5112. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5113. * @param scale defines the scale vector3
  5114. * @param rotation defines the rotation quaternion
  5115. * @param translation defines the translation vector3
  5116. * @param result defines the target matrix
  5117. */
  5118. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5119. /**
  5120. * Creates a new identity matrix
  5121. * @returns a new identity matrix
  5122. */
  5123. static Identity(): Matrix;
  5124. /**
  5125. * Creates a new identity matrix and stores the result in a given matrix
  5126. * @param result defines the target matrix
  5127. */
  5128. static IdentityToRef(result: Matrix): void;
  5129. /**
  5130. * Creates a new zero matrix
  5131. * @returns a new zero matrix
  5132. */
  5133. static Zero(): Matrix;
  5134. /**
  5135. * Creates a new rotation matrix for "angle" radians around the X axis
  5136. * @param angle defines the angle (in radians) to use
  5137. * @return the new matrix
  5138. */
  5139. static RotationX(angle: number): Matrix;
  5140. /**
  5141. * Creates a new matrix as the invert of a given matrix
  5142. * @param source defines the source matrix
  5143. * @returns the new matrix
  5144. */
  5145. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5146. /**
  5147. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5148. * @param angle defines the angle (in radians) to use
  5149. * @param result defines the target matrix
  5150. */
  5151. static RotationXToRef(angle: number, result: Matrix): void;
  5152. /**
  5153. * Creates a new rotation matrix for "angle" radians around the Y axis
  5154. * @param angle defines the angle (in radians) to use
  5155. * @return the new matrix
  5156. */
  5157. static RotationY(angle: number): Matrix;
  5158. /**
  5159. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5160. * @param angle defines the angle (in radians) to use
  5161. * @param result defines the target matrix
  5162. */
  5163. static RotationYToRef(angle: number, result: Matrix): void;
  5164. /**
  5165. * Creates a new rotation matrix for "angle" radians around the Z axis
  5166. * @param angle defines the angle (in radians) to use
  5167. * @return the new matrix
  5168. */
  5169. static RotationZ(angle: number): Matrix;
  5170. /**
  5171. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5172. * @param angle defines the angle (in radians) to use
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationZToRef(angle: number, result: Matrix): void;
  5176. /**
  5177. * Creates a new rotation matrix for "angle" radians around the given axis
  5178. * @param axis defines the axis to use
  5179. * @param angle defines the angle (in radians) to use
  5180. * @return the new matrix
  5181. */
  5182. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5183. /**
  5184. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5185. * @param axis defines the axis to use
  5186. * @param angle defines the angle (in radians) to use
  5187. * @param result defines the target matrix
  5188. */
  5189. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5190. /**
  5191. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5192. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5193. * @param from defines the vector to align
  5194. * @param to defines the vector to align to
  5195. * @param result defines the target matrix
  5196. */
  5197. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5198. /**
  5199. * Creates a rotation matrix
  5200. * @param yaw defines the yaw angle in radians (Y axis)
  5201. * @param pitch defines the pitch angle in radians (X axis)
  5202. * @param roll defines the roll angle in radians (Z axis)
  5203. * @returns the new rotation matrix
  5204. */
  5205. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5206. /**
  5207. * Creates a rotation matrix and stores it in a given matrix
  5208. * @param yaw defines the yaw angle in radians (Y axis)
  5209. * @param pitch defines the pitch angle in radians (X axis)
  5210. * @param roll defines the roll angle in radians (Z axis)
  5211. * @param result defines the target matrix
  5212. */
  5213. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5214. /**
  5215. * Creates a scaling matrix
  5216. * @param x defines the scale factor on X axis
  5217. * @param y defines the scale factor on Y axis
  5218. * @param z defines the scale factor on Z axis
  5219. * @returns the new matrix
  5220. */
  5221. static Scaling(x: number, y: number, z: number): Matrix;
  5222. /**
  5223. * Creates a scaling matrix and stores it in a given matrix
  5224. * @param x defines the scale factor on X axis
  5225. * @param y defines the scale factor on Y axis
  5226. * @param z defines the scale factor on Z axis
  5227. * @param result defines the target matrix
  5228. */
  5229. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5230. /**
  5231. * Creates a translation matrix
  5232. * @param x defines the translation on X axis
  5233. * @param y defines the translation on Y axis
  5234. * @param z defines the translationon Z axis
  5235. * @returns the new matrix
  5236. */
  5237. static Translation(x: number, y: number, z: number): Matrix;
  5238. /**
  5239. * Creates a translation matrix and stores it in a given matrix
  5240. * @param x defines the translation on X axis
  5241. * @param y defines the translation on Y axis
  5242. * @param z defines the translationon Z axis
  5243. * @param result defines the target matrix
  5244. */
  5245. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5246. /**
  5247. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5248. * @param startValue defines the start value
  5249. * @param endValue defines the end value
  5250. * @param gradient defines the gradient factor
  5251. * @returns the new matrix
  5252. */
  5253. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5254. /**
  5255. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5256. * @param startValue defines the start value
  5257. * @param endValue defines the end value
  5258. * @param gradient defines the gradient factor
  5259. * @param result defines the Matrix object where to store data
  5260. */
  5261. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Builds a new matrix whose values are computed by:
  5264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5267. * @param startValue defines the first matrix
  5268. * @param endValue defines the second matrix
  5269. * @param gradient defines the gradient between the two matrices
  5270. * @returns the new matrix
  5271. */
  5272. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5273. /**
  5274. * Update a matrix to values which are computed by:
  5275. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5276. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5277. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5278. * @param startValue defines the first matrix
  5279. * @param endValue defines the second matrix
  5280. * @param gradient defines the gradient between the two matrices
  5281. * @param result defines the target matrix
  5282. */
  5283. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5284. /**
  5285. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5286. * This function works in left handed mode
  5287. * @param eye defines the final position of the entity
  5288. * @param target defines where the entity should look at
  5289. * @param up defines the up vector for the entity
  5290. * @returns the new matrix
  5291. */
  5292. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5293. /**
  5294. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5295. * This function works in left handed mode
  5296. * @param eye defines the final position of the entity
  5297. * @param target defines where the entity should look at
  5298. * @param up defines the up vector for the entity
  5299. * @param result defines the target matrix
  5300. */
  5301. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5302. /**
  5303. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5304. * This function works in right handed mode
  5305. * @param eye defines the final position of the entity
  5306. * @param target defines where the entity should look at
  5307. * @param up defines the up vector for the entity
  5308. * @returns the new matrix
  5309. */
  5310. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5311. /**
  5312. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5313. * This function works in right handed mode
  5314. * @param eye defines the final position of the entity
  5315. * @param target defines where the entity should look at
  5316. * @param up defines the up vector for the entity
  5317. * @param result defines the target matrix
  5318. */
  5319. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5320. /**
  5321. * Create a left-handed orthographic projection matrix
  5322. * @param width defines the viewport width
  5323. * @param height defines the viewport height
  5324. * @param znear defines the near clip plane
  5325. * @param zfar defines the far clip plane
  5326. * @returns a new matrix as a left-handed orthographic projection matrix
  5327. */
  5328. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5329. /**
  5330. * Store a left-handed orthographic projection to a given matrix
  5331. * @param width defines the viewport width
  5332. * @param height defines the viewport height
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Create a left-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a left-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a left-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a right-handed orthographic projection matrix
  5362. * @param left defines the viewport left coordinate
  5363. * @param right defines the viewport right coordinate
  5364. * @param bottom defines the viewport bottom coordinate
  5365. * @param top defines the viewport top coordinate
  5366. * @param znear defines the near clip plane
  5367. * @param zfar defines the far clip plane
  5368. * @returns a new matrix as a right-handed orthographic projection matrix
  5369. */
  5370. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5371. /**
  5372. * Stores a right-handed orthographic projection into a given matrix
  5373. * @param left defines the viewport left coordinate
  5374. * @param right defines the viewport right coordinate
  5375. * @param bottom defines the viewport bottom coordinate
  5376. * @param top defines the viewport top coordinate
  5377. * @param znear defines the near clip plane
  5378. * @param zfar defines the far clip plane
  5379. * @param result defines the target matrix
  5380. */
  5381. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5382. /**
  5383. * Creates a left-handed perspective projection matrix
  5384. * @param width defines the viewport width
  5385. * @param height defines the viewport height
  5386. * @param znear defines the near clip plane
  5387. * @param zfar defines the far clip plane
  5388. * @returns a new matrix as a left-handed perspective projection matrix
  5389. */
  5390. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5391. /**
  5392. * Creates a left-handed perspective projection matrix
  5393. * @param fov defines the horizontal field of view
  5394. * @param aspect defines the aspect ratio
  5395. * @param znear defines the near clip plane
  5396. * @param zfar defines the far clip plane
  5397. * @returns a new matrix as a left-handed perspective projection matrix
  5398. */
  5399. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5400. /**
  5401. * Stores a left-handed perspective projection into a given matrix
  5402. * @param fov defines the horizontal field of view
  5403. * @param aspect defines the aspect ratio
  5404. * @param znear defines the near clip plane
  5405. * @param zfar defines the far clip plane
  5406. * @param result defines the target matrix
  5407. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5408. */
  5409. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5410. /**
  5411. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5412. * @param fov defines the horizontal field of view
  5413. * @param aspect defines the aspect ratio
  5414. * @param znear defines the near clip plane
  5415. * @param zfar not used as infinity is used as far clip
  5416. * @param result defines the target matrix
  5417. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5418. */
  5419. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5420. /**
  5421. * Creates a right-handed perspective projection matrix
  5422. * @param fov defines the horizontal field of view
  5423. * @param aspect defines the aspect ratio
  5424. * @param znear defines the near clip plane
  5425. * @param zfar defines the far clip plane
  5426. * @returns a new matrix as a right-handed perspective projection matrix
  5427. */
  5428. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5429. /**
  5430. * Stores a right-handed perspective projection into a given matrix
  5431. * @param fov defines the horizontal field of view
  5432. * @param aspect defines the aspect ratio
  5433. * @param znear defines the near clip plane
  5434. * @param zfar defines the far clip plane
  5435. * @param result defines the target matrix
  5436. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5437. */
  5438. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5439. /**
  5440. * Stores a right-handed perspective projection into a given matrix
  5441. * @param fov defines the horizontal field of view
  5442. * @param aspect defines the aspect ratio
  5443. * @param znear defines the near clip plane
  5444. * @param zfar not used as infinity is used as far clip
  5445. * @param result defines the target matrix
  5446. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5447. */
  5448. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5449. /**
  5450. * Stores a perspective projection for WebVR info a given matrix
  5451. * @param fov defines the field of view
  5452. * @param znear defines the near clip plane
  5453. * @param zfar defines the far clip plane
  5454. * @param result defines the target matrix
  5455. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5456. */
  5457. static PerspectiveFovWebVRToRef(fov: {
  5458. upDegrees: number;
  5459. downDegrees: number;
  5460. leftDegrees: number;
  5461. rightDegrees: number;
  5462. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5463. /**
  5464. * Computes a complete transformation matrix
  5465. * @param viewport defines the viewport to use
  5466. * @param world defines the world matrix
  5467. * @param view defines the view matrix
  5468. * @param projection defines the projection matrix
  5469. * @param zmin defines the near clip plane
  5470. * @param zmax defines the far clip plane
  5471. * @returns the transformation matrix
  5472. */
  5473. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5474. /**
  5475. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5476. * @param matrix defines the matrix to use
  5477. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5478. */
  5479. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5480. /**
  5481. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5482. * @param matrix defines the matrix to use
  5483. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5484. */
  5485. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5486. /**
  5487. * Compute the transpose of a given matrix
  5488. * @param matrix defines the matrix to transpose
  5489. * @returns the new matrix
  5490. */
  5491. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5492. /**
  5493. * Compute the transpose of a matrix and store it in a target matrix
  5494. * @param matrix defines the matrix to transpose
  5495. * @param result defines the target matrix
  5496. */
  5497. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5498. /**
  5499. * Computes a reflection matrix from a plane
  5500. * @param plane defines the reflection plane
  5501. * @returns a new matrix
  5502. */
  5503. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5504. /**
  5505. * Computes a reflection matrix from a plane
  5506. * @param plane defines the reflection plane
  5507. * @param result defines the target matrix
  5508. */
  5509. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5510. /**
  5511. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5512. * @param xaxis defines the value of the 1st axis
  5513. * @param yaxis defines the value of the 2nd axis
  5514. * @param zaxis defines the value of the 3rd axis
  5515. * @param result defines the target matrix
  5516. */
  5517. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5518. /**
  5519. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5520. * @param quat defines the quaternion to use
  5521. * @param result defines the target matrix
  5522. */
  5523. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5524. }
  5525. /**
  5526. * @hidden
  5527. */
  5528. export class TmpVectors {
  5529. static Vector2: Vector2[];
  5530. static Vector3: Vector3[];
  5531. static Vector4: Vector4[];
  5532. static Quaternion: Quaternion[];
  5533. static Matrix: Matrix[];
  5534. }
  5535. }
  5536. declare module BABYLON {
  5537. /**
  5538. * Defines potential orientation for back face culling
  5539. */
  5540. export enum Orientation {
  5541. /**
  5542. * Clockwise
  5543. */
  5544. CW = 0,
  5545. /** Counter clockwise */
  5546. CCW = 1
  5547. }
  5548. /** Class used to represent a Bezier curve */
  5549. export class BezierCurve {
  5550. /**
  5551. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5552. * @param t defines the time
  5553. * @param x1 defines the left coordinate on X axis
  5554. * @param y1 defines the left coordinate on Y axis
  5555. * @param x2 defines the right coordinate on X axis
  5556. * @param y2 defines the right coordinate on Y axis
  5557. * @returns the interpolated value
  5558. */
  5559. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5560. }
  5561. /**
  5562. * Defines angle representation
  5563. */
  5564. export class Angle {
  5565. private _radians;
  5566. /**
  5567. * Creates an Angle object of "radians" radians (float).
  5568. * @param radians the angle in radians
  5569. */
  5570. constructor(radians: number);
  5571. /**
  5572. * Get value in degrees
  5573. * @returns the Angle value in degrees (float)
  5574. */
  5575. degrees(): number;
  5576. /**
  5577. * Get value in radians
  5578. * @returns the Angle value in radians (float)
  5579. */
  5580. radians(): number;
  5581. /**
  5582. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5583. * @param a defines first point as the origin
  5584. * @param b defines point
  5585. * @returns a new Angle
  5586. */
  5587. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5588. /**
  5589. * Gets a new Angle object from the given float in radians
  5590. * @param radians defines the angle value in radians
  5591. * @returns a new Angle
  5592. */
  5593. static FromRadians(radians: number): Angle;
  5594. /**
  5595. * Gets a new Angle object from the given float in degrees
  5596. * @param degrees defines the angle value in degrees
  5597. * @returns a new Angle
  5598. */
  5599. static FromDegrees(degrees: number): Angle;
  5600. }
  5601. /**
  5602. * This represents an arc in a 2d space.
  5603. */
  5604. export class Arc2 {
  5605. /** Defines the start point of the arc */
  5606. startPoint: Vector2;
  5607. /** Defines the mid point of the arc */
  5608. midPoint: Vector2;
  5609. /** Defines the end point of the arc */
  5610. endPoint: Vector2;
  5611. /**
  5612. * Defines the center point of the arc.
  5613. */
  5614. centerPoint: Vector2;
  5615. /**
  5616. * Defines the radius of the arc.
  5617. */
  5618. radius: number;
  5619. /**
  5620. * Defines the angle of the arc (from mid point to end point).
  5621. */
  5622. angle: Angle;
  5623. /**
  5624. * Defines the start angle of the arc (from start point to middle point).
  5625. */
  5626. startAngle: Angle;
  5627. /**
  5628. * Defines the orientation of the arc (clock wise/counter clock wise).
  5629. */
  5630. orientation: Orientation;
  5631. /**
  5632. * Creates an Arc object from the three given points : start, middle and end.
  5633. * @param startPoint Defines the start point of the arc
  5634. * @param midPoint Defines the midlle point of the arc
  5635. * @param endPoint Defines the end point of the arc
  5636. */
  5637. constructor(
  5638. /** Defines the start point of the arc */
  5639. startPoint: Vector2,
  5640. /** Defines the mid point of the arc */
  5641. midPoint: Vector2,
  5642. /** Defines the end point of the arc */
  5643. endPoint: Vector2);
  5644. }
  5645. /**
  5646. * Represents a 2D path made up of multiple 2D points
  5647. */
  5648. export class Path2 {
  5649. private _points;
  5650. private _length;
  5651. /**
  5652. * If the path start and end point are the same
  5653. */
  5654. closed: boolean;
  5655. /**
  5656. * Creates a Path2 object from the starting 2D coordinates x and y.
  5657. * @param x the starting points x value
  5658. * @param y the starting points y value
  5659. */
  5660. constructor(x: number, y: number);
  5661. /**
  5662. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5663. * @param x the added points x value
  5664. * @param y the added points y value
  5665. * @returns the updated Path2.
  5666. */
  5667. addLineTo(x: number, y: number): Path2;
  5668. /**
  5669. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5670. * @param midX middle point x value
  5671. * @param midY middle point y value
  5672. * @param endX end point x value
  5673. * @param endY end point y value
  5674. * @param numberOfSegments (default: 36)
  5675. * @returns the updated Path2.
  5676. */
  5677. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5678. /**
  5679. * Closes the Path2.
  5680. * @returns the Path2.
  5681. */
  5682. close(): Path2;
  5683. /**
  5684. * Gets the sum of the distance between each sequential point in the path
  5685. * @returns the Path2 total length (float).
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Gets the points which construct the path
  5690. * @returns the Path2 internal array of points.
  5691. */
  5692. getPoints(): Vector2[];
  5693. /**
  5694. * Retreives the point at the distance aways from the starting point
  5695. * @param normalizedLengthPosition the length along the path to retreive the point from
  5696. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5697. */
  5698. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5699. /**
  5700. * Creates a new path starting from an x and y position
  5701. * @param x starting x value
  5702. * @param y starting y value
  5703. * @returns a new Path2 starting at the coordinates (x, y).
  5704. */
  5705. static StartingAt(x: number, y: number): Path2;
  5706. }
  5707. /**
  5708. * Represents a 3D path made up of multiple 3D points
  5709. */
  5710. export class Path3D {
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[];
  5715. private _curve;
  5716. private _distances;
  5717. private _tangents;
  5718. private _normals;
  5719. private _binormals;
  5720. private _raw;
  5721. private _alignTangentsWithPath;
  5722. private readonly _pointAtData;
  5723. /**
  5724. * new Path3D(path, normal, raw)
  5725. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5726. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5727. * @param path an array of Vector3, the curve axis of the Path3D
  5728. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5729. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5730. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5731. */
  5732. constructor(
  5733. /**
  5734. * an array of Vector3, the curve axis of the Path3D
  5735. */
  5736. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5737. /**
  5738. * Returns the Path3D array of successive Vector3 designing its curve.
  5739. * @returns the Path3D array of successive Vector3 designing its curve.
  5740. */
  5741. getCurve(): Vector3[];
  5742. /**
  5743. * Returns the Path3D array of successive Vector3 designing its curve.
  5744. * @returns the Path3D array of successive Vector3 designing its curve.
  5745. */
  5746. getPoints(): Vector3[];
  5747. /**
  5748. * @returns the computed length (float) of the path.
  5749. */
  5750. length(): number;
  5751. /**
  5752. * Returns an array populated with tangent vectors on each Path3D curve point.
  5753. * @returns an array populated with tangent vectors on each Path3D curve point.
  5754. */
  5755. getTangents(): Vector3[];
  5756. /**
  5757. * Returns an array populated with normal vectors on each Path3D curve point.
  5758. * @returns an array populated with normal vectors on each Path3D curve point.
  5759. */
  5760. getNormals(): Vector3[];
  5761. /**
  5762. * Returns an array populated with binormal vectors on each Path3D curve point.
  5763. * @returns an array populated with binormal vectors on each Path3D curve point.
  5764. */
  5765. getBinormals(): Vector3[];
  5766. /**
  5767. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5768. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5769. */
  5770. getDistances(): number[];
  5771. /**
  5772. * Returns an interpolated point along this path
  5773. * @param position the position of the point along this path, from 0.0 to 1.0
  5774. * @returns a new Vector3 as the point
  5775. */
  5776. getPointAt(position: number): Vector3;
  5777. /**
  5778. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5779. * @param position the position of the point along this path, from 0.0 to 1.0
  5780. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5781. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5782. */
  5783. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5784. /**
  5785. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5786. * @param position the position of the point along this path, from 0.0 to 1.0
  5787. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5788. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5789. */
  5790. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5791. /**
  5792. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5793. * @param position the position of the point along this path, from 0.0 to 1.0
  5794. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5795. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5796. */
  5797. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5798. /**
  5799. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5800. * @param position the position of the point along this path, from 0.0 to 1.0
  5801. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5802. */
  5803. getDistanceAt(position: number): number;
  5804. /**
  5805. * Returns the array index of the previous point of an interpolated point along this path
  5806. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5807. * @returns the array index
  5808. */
  5809. getPreviousPointIndexAt(position: number): number;
  5810. /**
  5811. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5812. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5813. * @returns the sub position
  5814. */
  5815. getSubPositionAt(position: number): number;
  5816. /**
  5817. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5818. * @param target the vector of which to get the closest position to
  5819. * @returns the position of the closest virtual point on this path to the target vector
  5820. */
  5821. getClosestPositionTo(target: Vector3): number;
  5822. /**
  5823. * Returns a sub path (slice) of this path
  5824. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5825. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5826. * @returns a sub path (slice) of this path
  5827. */
  5828. slice(start?: number, end?: number): Path3D;
  5829. /**
  5830. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5831. * @param path path which all values are copied into the curves points
  5832. * @param firstNormal which should be projected onto the curve
  5833. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5834. * @returns the same object updated.
  5835. */
  5836. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5837. private _compute;
  5838. private _getFirstNonNullVector;
  5839. private _getLastNonNullVector;
  5840. private _normalVector;
  5841. /**
  5842. * Updates the point at data for an interpolated point along this curve
  5843. * @param position the position of the point along this curve, from 0.0 to 1.0
  5844. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5845. * @returns the (updated) point at data
  5846. */
  5847. private _updatePointAtData;
  5848. /**
  5849. * Updates the point at data from the specified parameters
  5850. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5851. * @param point the interpolated point
  5852. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5853. */
  5854. private _setPointAtData;
  5855. /**
  5856. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5857. */
  5858. private _updateInterpolationMatrix;
  5859. }
  5860. /**
  5861. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5862. * A Curve3 is designed from a series of successive Vector3.
  5863. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5864. */
  5865. export class Curve3 {
  5866. private _points;
  5867. private _length;
  5868. /**
  5869. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5870. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5871. * @param v1 (Vector3) the control point
  5872. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5873. * @param nbPoints (integer) the wanted number of points in the curve
  5874. * @returns the created Curve3
  5875. */
  5876. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5877. /**
  5878. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5879. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5880. * @param v1 (Vector3) the first control point
  5881. * @param v2 (Vector3) the second control point
  5882. * @param v3 (Vector3) the end point of the Cubic Bezier
  5883. * @param nbPoints (integer) the wanted number of points in the curve
  5884. * @returns the created Curve3
  5885. */
  5886. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5887. /**
  5888. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5889. * @param p1 (Vector3) the origin point of the Hermite Spline
  5890. * @param t1 (Vector3) the tangent vector at the origin point
  5891. * @param p2 (Vector3) the end point of the Hermite Spline
  5892. * @param t2 (Vector3) the tangent vector at the end point
  5893. * @param nbPoints (integer) the wanted number of points in the curve
  5894. * @returns the created Curve3
  5895. */
  5896. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5897. /**
  5898. * Returns a Curve3 object along a CatmullRom Spline curve :
  5899. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5900. * @param nbPoints (integer) the wanted number of points between each curve control points
  5901. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5902. * @returns the created Curve3
  5903. */
  5904. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5905. /**
  5906. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5907. * A Curve3 is designed from a series of successive Vector3.
  5908. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5909. * @param points points which make up the curve
  5910. */
  5911. constructor(points: Vector3[]);
  5912. /**
  5913. * @returns the Curve3 stored array of successive Vector3
  5914. */
  5915. getPoints(): Vector3[];
  5916. /**
  5917. * @returns the computed length (float) of the curve.
  5918. */
  5919. length(): number;
  5920. /**
  5921. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5922. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5923. * curveA and curveB keep unchanged.
  5924. * @param curve the curve to continue from this curve
  5925. * @returns the newly constructed curve
  5926. */
  5927. continue(curve: DeepImmutable<Curve3>): Curve3;
  5928. private _computeLength;
  5929. }
  5930. }
  5931. declare module BABYLON {
  5932. /**
  5933. * This represents the main contract an easing function should follow.
  5934. * Easing functions are used throughout the animation system.
  5935. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5936. */
  5937. export interface IEasingFunction {
  5938. /**
  5939. * Given an input gradient between 0 and 1, this returns the corresponding value
  5940. * of the easing function.
  5941. * The link below provides some of the most common examples of easing functions.
  5942. * @see https://easings.net/
  5943. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5944. * @returns the corresponding value on the curve defined by the easing function
  5945. */
  5946. ease(gradient: number): number;
  5947. }
  5948. /**
  5949. * Base class used for every default easing function.
  5950. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5951. */
  5952. export class EasingFunction implements IEasingFunction {
  5953. /**
  5954. * Interpolation follows the mathematical formula associated with the easing function.
  5955. */
  5956. static readonly EASINGMODE_EASEIN: number;
  5957. /**
  5958. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5959. */
  5960. static readonly EASINGMODE_EASEOUT: number;
  5961. /**
  5962. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5963. */
  5964. static readonly EASINGMODE_EASEINOUT: number;
  5965. private _easingMode;
  5966. /**
  5967. * Sets the easing mode of the current function.
  5968. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5969. */
  5970. setEasingMode(easingMode: number): void;
  5971. /**
  5972. * Gets the current easing mode.
  5973. * @returns the easing mode
  5974. */
  5975. getEasingMode(): number;
  5976. /**
  5977. * @hidden
  5978. */
  5979. easeInCore(gradient: number): number;
  5980. /**
  5981. * Given an input gradient between 0 and 1, this returns the corresponding value
  5982. * of the easing function.
  5983. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5984. * @returns the corresponding value on the curve defined by the easing function
  5985. */
  5986. ease(gradient: number): number;
  5987. }
  5988. /**
  5989. * Easing function with a circle shape (see link below).
  5990. * @see https://easings.net/#easeInCirc
  5991. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5992. */
  5993. export class CircleEase extends EasingFunction implements IEasingFunction {
  5994. /** @hidden */
  5995. easeInCore(gradient: number): number;
  5996. }
  5997. /**
  5998. * Easing function with a ease back shape (see link below).
  5999. * @see https://easings.net/#easeInBack
  6000. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6001. */
  6002. export class BackEase extends EasingFunction implements IEasingFunction {
  6003. /** Defines the amplitude of the function */
  6004. amplitude: number;
  6005. /**
  6006. * Instantiates a back ease easing
  6007. * @see https://easings.net/#easeInBack
  6008. * @param amplitude Defines the amplitude of the function
  6009. */
  6010. constructor(
  6011. /** Defines the amplitude of the function */
  6012. amplitude?: number);
  6013. /** @hidden */
  6014. easeInCore(gradient: number): number;
  6015. }
  6016. /**
  6017. * Easing function with a bouncing shape (see link below).
  6018. * @see https://easings.net/#easeInBounce
  6019. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6020. */
  6021. export class BounceEase extends EasingFunction implements IEasingFunction {
  6022. /** Defines the number of bounces */
  6023. bounces: number;
  6024. /** Defines the amplitude of the bounce */
  6025. bounciness: number;
  6026. /**
  6027. * Instantiates a bounce easing
  6028. * @see https://easings.net/#easeInBounce
  6029. * @param bounces Defines the number of bounces
  6030. * @param bounciness Defines the amplitude of the bounce
  6031. */
  6032. constructor(
  6033. /** Defines the number of bounces */
  6034. bounces?: number,
  6035. /** Defines the amplitude of the bounce */
  6036. bounciness?: number);
  6037. /** @hidden */
  6038. easeInCore(gradient: number): number;
  6039. }
  6040. /**
  6041. * Easing function with a power of 3 shape (see link below).
  6042. * @see https://easings.net/#easeInCubic
  6043. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6044. */
  6045. export class CubicEase extends EasingFunction implements IEasingFunction {
  6046. /** @hidden */
  6047. easeInCore(gradient: number): number;
  6048. }
  6049. /**
  6050. * Easing function with an elastic shape (see link below).
  6051. * @see https://easings.net/#easeInElastic
  6052. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6053. */
  6054. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6055. /** Defines the number of oscillations*/
  6056. oscillations: number;
  6057. /** Defines the amplitude of the oscillations*/
  6058. springiness: number;
  6059. /**
  6060. * Instantiates an elastic easing function
  6061. * @see https://easings.net/#easeInElastic
  6062. * @param oscillations Defines the number of oscillations
  6063. * @param springiness Defines the amplitude of the oscillations
  6064. */
  6065. constructor(
  6066. /** Defines the number of oscillations*/
  6067. oscillations?: number,
  6068. /** Defines the amplitude of the oscillations*/
  6069. springiness?: number);
  6070. /** @hidden */
  6071. easeInCore(gradient: number): number;
  6072. }
  6073. /**
  6074. * Easing function with an exponential shape (see link below).
  6075. * @see https://easings.net/#easeInExpo
  6076. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6077. */
  6078. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6079. /** Defines the exponent of the function */
  6080. exponent: number;
  6081. /**
  6082. * Instantiates an exponential easing function
  6083. * @see https://easings.net/#easeInExpo
  6084. * @param exponent Defines the exponent of the function
  6085. */
  6086. constructor(
  6087. /** Defines the exponent of the function */
  6088. exponent?: number);
  6089. /** @hidden */
  6090. easeInCore(gradient: number): number;
  6091. }
  6092. /**
  6093. * Easing function with a power shape (see link below).
  6094. * @see https://easings.net/#easeInQuad
  6095. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6096. */
  6097. export class PowerEase extends EasingFunction implements IEasingFunction {
  6098. /** Defines the power of the function */
  6099. power: number;
  6100. /**
  6101. * Instantiates an power base easing function
  6102. * @see https://easings.net/#easeInQuad
  6103. * @param power Defines the power of the function
  6104. */
  6105. constructor(
  6106. /** Defines the power of the function */
  6107. power?: number);
  6108. /** @hidden */
  6109. easeInCore(gradient: number): number;
  6110. }
  6111. /**
  6112. * Easing function with a power of 2 shape (see link below).
  6113. * @see https://easings.net/#easeInQuad
  6114. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6117. /** @hidden */
  6118. easeInCore(gradient: number): number;
  6119. }
  6120. /**
  6121. * Easing function with a power of 4 shape (see link below).
  6122. * @see https://easings.net/#easeInQuart
  6123. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6124. */
  6125. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6126. /** @hidden */
  6127. easeInCore(gradient: number): number;
  6128. }
  6129. /**
  6130. * Easing function with a power of 5 shape (see link below).
  6131. * @see https://easings.net/#easeInQuint
  6132. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6133. */
  6134. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6135. /** @hidden */
  6136. easeInCore(gradient: number): number;
  6137. }
  6138. /**
  6139. * Easing function with a sin shape (see link below).
  6140. * @see https://easings.net/#easeInSine
  6141. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6142. */
  6143. export class SineEase extends EasingFunction implements IEasingFunction {
  6144. /** @hidden */
  6145. easeInCore(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a bezier shape (see link below).
  6149. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6150. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6153. /** Defines the x component of the start tangent in the bezier curve */
  6154. x1: number;
  6155. /** Defines the y component of the start tangent in the bezier curve */
  6156. y1: number;
  6157. /** Defines the x component of the end tangent in the bezier curve */
  6158. x2: number;
  6159. /** Defines the y component of the end tangent in the bezier curve */
  6160. y2: number;
  6161. /**
  6162. * Instantiates a bezier function
  6163. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6164. * @param x1 Defines the x component of the start tangent in the bezier curve
  6165. * @param y1 Defines the y component of the start tangent in the bezier curve
  6166. * @param x2 Defines the x component of the end tangent in the bezier curve
  6167. * @param y2 Defines the y component of the end tangent in the bezier curve
  6168. */
  6169. constructor(
  6170. /** Defines the x component of the start tangent in the bezier curve */
  6171. x1?: number,
  6172. /** Defines the y component of the start tangent in the bezier curve */
  6173. y1?: number,
  6174. /** Defines the x component of the end tangent in the bezier curve */
  6175. x2?: number,
  6176. /** Defines the y component of the end tangent in the bezier curve */
  6177. y2?: number);
  6178. /** @hidden */
  6179. easeInCore(gradient: number): number;
  6180. }
  6181. }
  6182. declare module BABYLON {
  6183. /**
  6184. * Class used to hold a RGB color
  6185. */
  6186. export class Color3 {
  6187. /**
  6188. * Defines the red component (between 0 and 1, default is 0)
  6189. */
  6190. r: number;
  6191. /**
  6192. * Defines the green component (between 0 and 1, default is 0)
  6193. */
  6194. g: number;
  6195. /**
  6196. * Defines the blue component (between 0 and 1, default is 0)
  6197. */
  6198. b: number;
  6199. /**
  6200. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6201. * @param r defines the red component (between 0 and 1, default is 0)
  6202. * @param g defines the green component (between 0 and 1, default is 0)
  6203. * @param b defines the blue component (between 0 and 1, default is 0)
  6204. */
  6205. constructor(
  6206. /**
  6207. * Defines the red component (between 0 and 1, default is 0)
  6208. */
  6209. r?: number,
  6210. /**
  6211. * Defines the green component (between 0 and 1, default is 0)
  6212. */
  6213. g?: number,
  6214. /**
  6215. * Defines the blue component (between 0 and 1, default is 0)
  6216. */
  6217. b?: number);
  6218. /**
  6219. * Creates a string with the Color3 current values
  6220. * @returns the string representation of the Color3 object
  6221. */
  6222. toString(): string;
  6223. /**
  6224. * Returns the string "Color3"
  6225. * @returns "Color3"
  6226. */
  6227. getClassName(): string;
  6228. /**
  6229. * Compute the Color3 hash code
  6230. * @returns an unique number that can be used to hash Color3 objects
  6231. */
  6232. getHashCode(): number;
  6233. /**
  6234. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6235. * @param array defines the array where to store the r,g,b components
  6236. * @param index defines an optional index in the target array to define where to start storing values
  6237. * @returns the current Color3 object
  6238. */
  6239. toArray(array: FloatArray, index?: number): Color3;
  6240. /**
  6241. * Update the current color with values stored in an array from the starting index of the given array
  6242. * @param array defines the source array
  6243. * @param offset defines an offset in the source array
  6244. * @returns the current Color3 object
  6245. */
  6246. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6247. /**
  6248. * Returns a new Color4 object from the current Color3 and the given alpha
  6249. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6250. * @returns a new Color4 object
  6251. */
  6252. toColor4(alpha?: number): Color4;
  6253. /**
  6254. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6255. * @returns the new array
  6256. */
  6257. asArray(): number[];
  6258. /**
  6259. * Returns the luminance value
  6260. * @returns a float value
  6261. */
  6262. toLuminance(): number;
  6263. /**
  6264. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6265. * @param otherColor defines the second operand
  6266. * @returns the new Color3 object
  6267. */
  6268. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6269. /**
  6270. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6271. * @param otherColor defines the second operand
  6272. * @param result defines the Color3 object where to store the result
  6273. * @returns the current Color3
  6274. */
  6275. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6276. /**
  6277. * Determines equality between Color3 objects
  6278. * @param otherColor defines the second operand
  6279. * @returns true if the rgb values are equal to the given ones
  6280. */
  6281. equals(otherColor: DeepImmutable<Color3>): boolean;
  6282. /**
  6283. * Determines equality between the current Color3 object and a set of r,b,g values
  6284. * @param r defines the red component to check
  6285. * @param g defines the green component to check
  6286. * @param b defines the blue component to check
  6287. * @returns true if the rgb values are equal to the given ones
  6288. */
  6289. equalsFloats(r: number, g: number, b: number): boolean;
  6290. /**
  6291. * Multiplies in place each rgb value by scale
  6292. * @param scale defines the scaling factor
  6293. * @returns the updated Color3
  6294. */
  6295. scale(scale: number): Color3;
  6296. /**
  6297. * Multiplies the rgb values by scale and stores the result into "result"
  6298. * @param scale defines the scaling factor
  6299. * @param result defines the Color3 object where to store the result
  6300. * @returns the unmodified current Color3
  6301. */
  6302. scaleToRef(scale: number, result: Color3): Color3;
  6303. /**
  6304. * Scale the current Color3 values by a factor and add the result to a given Color3
  6305. * @param scale defines the scale factor
  6306. * @param result defines color to store the result into
  6307. * @returns the unmodified current Color3
  6308. */
  6309. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6310. /**
  6311. * Clamps the rgb values by the min and max values and stores the result into "result"
  6312. * @param min defines minimum clamping value (default is 0)
  6313. * @param max defines maximum clamping value (default is 1)
  6314. * @param result defines color to store the result into
  6315. * @returns the original Color3
  6316. */
  6317. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6318. /**
  6319. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6320. * @param otherColor defines the second operand
  6321. * @returns the new Color3
  6322. */
  6323. add(otherColor: DeepImmutable<Color3>): Color3;
  6324. /**
  6325. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6326. * @param otherColor defines the second operand
  6327. * @param result defines Color3 object to store the result into
  6328. * @returns the unmodified current Color3
  6329. */
  6330. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6331. /**
  6332. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6333. * @param otherColor defines the second operand
  6334. * @returns the new Color3
  6335. */
  6336. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6337. /**
  6338. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6339. * @param otherColor defines the second operand
  6340. * @param result defines Color3 object to store the result into
  6341. * @returns the unmodified current Color3
  6342. */
  6343. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6344. /**
  6345. * Copy the current object
  6346. * @returns a new Color3 copied the current one
  6347. */
  6348. clone(): Color3;
  6349. /**
  6350. * Copies the rgb values from the source in the current Color3
  6351. * @param source defines the source Color3 object
  6352. * @returns the updated Color3 object
  6353. */
  6354. copyFrom(source: DeepImmutable<Color3>): Color3;
  6355. /**
  6356. * Updates the Color3 rgb values from the given floats
  6357. * @param r defines the red component to read from
  6358. * @param g defines the green component to read from
  6359. * @param b defines the blue component to read from
  6360. * @returns the current Color3 object
  6361. */
  6362. copyFromFloats(r: number, g: number, b: number): Color3;
  6363. /**
  6364. * Updates the Color3 rgb values from the given floats
  6365. * @param r defines the red component to read from
  6366. * @param g defines the green component to read from
  6367. * @param b defines the blue component to read from
  6368. * @returns the current Color3 object
  6369. */
  6370. set(r: number, g: number, b: number): Color3;
  6371. /**
  6372. * Compute the Color3 hexadecimal code as a string
  6373. * @returns a string containing the hexadecimal representation of the Color3 object
  6374. */
  6375. toHexString(): string;
  6376. /**
  6377. * Computes a new Color3 converted from the current one to linear space
  6378. * @returns a new Color3 object
  6379. */
  6380. toLinearSpace(): Color3;
  6381. /**
  6382. * Converts current color in rgb space to HSV values
  6383. * @returns a new color3 representing the HSV values
  6384. */
  6385. toHSV(): Color3;
  6386. /**
  6387. * Converts current color in rgb space to HSV values
  6388. * @param result defines the Color3 where to store the HSV values
  6389. */
  6390. toHSVToRef(result: Color3): void;
  6391. /**
  6392. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6393. * @param convertedColor defines the Color3 object where to store the linear space version
  6394. * @returns the unmodified Color3
  6395. */
  6396. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6397. /**
  6398. * Computes a new Color3 converted from the current one to gamma space
  6399. * @returns a new Color3 object
  6400. */
  6401. toGammaSpace(): Color3;
  6402. /**
  6403. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6404. * @param convertedColor defines the Color3 object where to store the gamma space version
  6405. * @returns the unmodified Color3
  6406. */
  6407. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6408. private static _BlackReadOnly;
  6409. /**
  6410. * Convert Hue, saturation and value to a Color3 (RGB)
  6411. * @param hue defines the hue
  6412. * @param saturation defines the saturation
  6413. * @param value defines the value
  6414. * @param result defines the Color3 where to store the RGB values
  6415. */
  6416. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6417. /**
  6418. * Creates a new Color3 from the string containing valid hexadecimal values
  6419. * @param hex defines a string containing valid hexadecimal values
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromHexString(hex: string): Color3;
  6423. /**
  6424. * Creates a new Color3 from the starting index of the given array
  6425. * @param array defines the source array
  6426. * @param offset defines an offset in the source array
  6427. * @returns a new Color3 object
  6428. */
  6429. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6430. /**
  6431. * Creates a new Color3 from the starting index element of the given array
  6432. * @param array defines the source array to read from
  6433. * @param offset defines the offset in the source array
  6434. * @param result defines the target Color3 object
  6435. */
  6436. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6437. /**
  6438. * Creates a new Color3 from integer values (< 256)
  6439. * @param r defines the red component to read from (value between 0 and 255)
  6440. * @param g defines the green component to read from (value between 0 and 255)
  6441. * @param b defines the blue component to read from (value between 0 and 255)
  6442. * @returns a new Color3 object
  6443. */
  6444. static FromInts(r: number, g: number, b: number): Color3;
  6445. /**
  6446. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6447. * @param start defines the start Color3 value
  6448. * @param end defines the end Color3 value
  6449. * @param amount defines the gradient value between start and end
  6450. * @returns a new Color3 object
  6451. */
  6452. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6453. /**
  6454. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6455. * @param left defines the start value
  6456. * @param right defines the end value
  6457. * @param amount defines the gradient factor
  6458. * @param result defines the Color3 object where to store the result
  6459. */
  6460. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6461. /**
  6462. * Returns a Color3 value containing a red color
  6463. * @returns a new Color3 object
  6464. */
  6465. static Red(): Color3;
  6466. /**
  6467. * Returns a Color3 value containing a green color
  6468. * @returns a new Color3 object
  6469. */
  6470. static Green(): Color3;
  6471. /**
  6472. * Returns a Color3 value containing a blue color
  6473. * @returns a new Color3 object
  6474. */
  6475. static Blue(): Color3;
  6476. /**
  6477. * Returns a Color3 value containing a black color
  6478. * @returns a new Color3 object
  6479. */
  6480. static Black(): Color3;
  6481. /**
  6482. * Gets a Color3 value containing a black color that must not be updated
  6483. */
  6484. static get BlackReadOnly(): DeepImmutable<Color3>;
  6485. /**
  6486. * Returns a Color3 value containing a white color
  6487. * @returns a new Color3 object
  6488. */
  6489. static White(): Color3;
  6490. /**
  6491. * Returns a Color3 value containing a purple color
  6492. * @returns a new Color3 object
  6493. */
  6494. static Purple(): Color3;
  6495. /**
  6496. * Returns a Color3 value containing a magenta color
  6497. * @returns a new Color3 object
  6498. */
  6499. static Magenta(): Color3;
  6500. /**
  6501. * Returns a Color3 value containing a yellow color
  6502. * @returns a new Color3 object
  6503. */
  6504. static Yellow(): Color3;
  6505. /**
  6506. * Returns a Color3 value containing a gray color
  6507. * @returns a new Color3 object
  6508. */
  6509. static Gray(): Color3;
  6510. /**
  6511. * Returns a Color3 value containing a teal color
  6512. * @returns a new Color3 object
  6513. */
  6514. static Teal(): Color3;
  6515. /**
  6516. * Returns a Color3 value containing a random color
  6517. * @returns a new Color3 object
  6518. */
  6519. static Random(): Color3;
  6520. }
  6521. /**
  6522. * Class used to hold a RBGA color
  6523. */
  6524. export class Color4 {
  6525. /**
  6526. * Defines the red component (between 0 and 1, default is 0)
  6527. */
  6528. r: number;
  6529. /**
  6530. * Defines the green component (between 0 and 1, default is 0)
  6531. */
  6532. g: number;
  6533. /**
  6534. * Defines the blue component (between 0 and 1, default is 0)
  6535. */
  6536. b: number;
  6537. /**
  6538. * Defines the alpha component (between 0 and 1, default is 1)
  6539. */
  6540. a: number;
  6541. /**
  6542. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6543. * @param r defines the red component (between 0 and 1, default is 0)
  6544. * @param g defines the green component (between 0 and 1, default is 0)
  6545. * @param b defines the blue component (between 0 and 1, default is 0)
  6546. * @param a defines the alpha component (between 0 and 1, default is 1)
  6547. */
  6548. constructor(
  6549. /**
  6550. * Defines the red component (between 0 and 1, default is 0)
  6551. */
  6552. r?: number,
  6553. /**
  6554. * Defines the green component (between 0 and 1, default is 0)
  6555. */
  6556. g?: number,
  6557. /**
  6558. * Defines the blue component (between 0 and 1, default is 0)
  6559. */
  6560. b?: number,
  6561. /**
  6562. * Defines the alpha component (between 0 and 1, default is 1)
  6563. */
  6564. a?: number);
  6565. /**
  6566. * Adds in place the given Color4 values to the current Color4 object
  6567. * @param right defines the second operand
  6568. * @returns the current updated Color4 object
  6569. */
  6570. addInPlace(right: DeepImmutable<Color4>): Color4;
  6571. /**
  6572. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6573. * @returns the new array
  6574. */
  6575. asArray(): number[];
  6576. /**
  6577. * Stores from the starting index in the given array the Color4 successive values
  6578. * @param array defines the array where to store the r,g,b components
  6579. * @param index defines an optional index in the target array to define where to start storing values
  6580. * @returns the current Color4 object
  6581. */
  6582. toArray(array: number[], index?: number): Color4;
  6583. /**
  6584. * Update the current color with values stored in an array from the starting index of the given array
  6585. * @param array defines the source array
  6586. * @param offset defines an offset in the source array
  6587. * @returns the current Color4 object
  6588. */
  6589. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6590. /**
  6591. * Determines equality between Color4 objects
  6592. * @param otherColor defines the second operand
  6593. * @returns true if the rgba values are equal to the given ones
  6594. */
  6595. equals(otherColor: DeepImmutable<Color4>): boolean;
  6596. /**
  6597. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6598. * @param right defines the second operand
  6599. * @returns a new Color4 object
  6600. */
  6601. add(right: DeepImmutable<Color4>): Color4;
  6602. /**
  6603. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6604. * @param right defines the second operand
  6605. * @returns a new Color4 object
  6606. */
  6607. subtract(right: DeepImmutable<Color4>): Color4;
  6608. /**
  6609. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6610. * @param right defines the second operand
  6611. * @param result defines the Color4 object where to store the result
  6612. * @returns the current Color4 object
  6613. */
  6614. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6615. /**
  6616. * Creates a new Color4 with the current Color4 values multiplied by scale
  6617. * @param scale defines the scaling factor to apply
  6618. * @returns a new Color4 object
  6619. */
  6620. scale(scale: number): Color4;
  6621. /**
  6622. * Multiplies the current Color4 values by scale and stores the result in "result"
  6623. * @param scale defines the scaling factor to apply
  6624. * @param result defines the Color4 object where to store the result
  6625. * @returns the current unmodified Color4
  6626. */
  6627. scaleToRef(scale: number, result: Color4): Color4;
  6628. /**
  6629. * Scale the current Color4 values by a factor and add the result to a given Color4
  6630. * @param scale defines the scale factor
  6631. * @param result defines the Color4 object where to store the result
  6632. * @returns the unmodified current Color4
  6633. */
  6634. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6635. /**
  6636. * Clamps the rgb values by the min and max values and stores the result into "result"
  6637. * @param min defines minimum clamping value (default is 0)
  6638. * @param max defines maximum clamping value (default is 1)
  6639. * @param result defines color to store the result into.
  6640. * @returns the cuurent Color4
  6641. */
  6642. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6643. /**
  6644. * Multipy an Color4 value by another and return a new Color4 object
  6645. * @param color defines the Color4 value to multiply by
  6646. * @returns a new Color4 object
  6647. */
  6648. multiply(color: Color4): Color4;
  6649. /**
  6650. * Multipy a Color4 value by another and push the result in a reference value
  6651. * @param color defines the Color4 value to multiply by
  6652. * @param result defines the Color4 to fill the result in
  6653. * @returns the result Color4
  6654. */
  6655. multiplyToRef(color: Color4, result: Color4): Color4;
  6656. /**
  6657. * Creates a string with the Color4 current values
  6658. * @returns the string representation of the Color4 object
  6659. */
  6660. toString(): string;
  6661. /**
  6662. * Returns the string "Color4"
  6663. * @returns "Color4"
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Compute the Color4 hash code
  6668. * @returns an unique number that can be used to hash Color4 objects
  6669. */
  6670. getHashCode(): number;
  6671. /**
  6672. * Creates a new Color4 copied from the current one
  6673. * @returns a new Color4 object
  6674. */
  6675. clone(): Color4;
  6676. /**
  6677. * Copies the given Color4 values into the current one
  6678. * @param source defines the source Color4 object
  6679. * @returns the current updated Color4 object
  6680. */
  6681. copyFrom(source: Color4): Color4;
  6682. /**
  6683. * Copies the given float values into the current one
  6684. * @param r defines the red component to read from
  6685. * @param g defines the green component to read from
  6686. * @param b defines the blue component to read from
  6687. * @param a defines the alpha component to read from
  6688. * @returns the current updated Color4 object
  6689. */
  6690. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6691. /**
  6692. * Copies the given float values into the current one
  6693. * @param r defines the red component to read from
  6694. * @param g defines the green component to read from
  6695. * @param b defines the blue component to read from
  6696. * @param a defines the alpha component to read from
  6697. * @returns the current updated Color4 object
  6698. */
  6699. set(r: number, g: number, b: number, a: number): Color4;
  6700. /**
  6701. * Compute the Color4 hexadecimal code as a string
  6702. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6703. * @returns a string containing the hexadecimal representation of the Color4 object
  6704. */
  6705. toHexString(returnAsColor3?: boolean): string;
  6706. /**
  6707. * Computes a new Color4 converted from the current one to linear space
  6708. * @returns a new Color4 object
  6709. */
  6710. toLinearSpace(): Color4;
  6711. /**
  6712. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6713. * @param convertedColor defines the Color4 object where to store the linear space version
  6714. * @returns the unmodified Color4
  6715. */
  6716. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6717. /**
  6718. * Computes a new Color4 converted from the current one to gamma space
  6719. * @returns a new Color4 object
  6720. */
  6721. toGammaSpace(): Color4;
  6722. /**
  6723. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6724. * @param convertedColor defines the Color4 object where to store the gamma space version
  6725. * @returns the unmodified Color4
  6726. */
  6727. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6728. /**
  6729. * Creates a new Color4 from the string containing valid hexadecimal values
  6730. * @param hex defines a string containing valid hexadecimal values
  6731. * @returns a new Color4 object
  6732. */
  6733. static FromHexString(hex: string): Color4;
  6734. /**
  6735. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6736. * @param left defines the start value
  6737. * @param right defines the end value
  6738. * @param amount defines the gradient factor
  6739. * @returns a new Color4 object
  6740. */
  6741. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6742. /**
  6743. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6744. * @param left defines the start value
  6745. * @param right defines the end value
  6746. * @param amount defines the gradient factor
  6747. * @param result defines the Color4 object where to store data
  6748. */
  6749. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6750. /**
  6751. * Creates a new Color4 from a Color3 and an alpha value
  6752. * @param color3 defines the source Color3 to read from
  6753. * @param alpha defines the alpha component (1.0 by default)
  6754. * @returns a new Color4 object
  6755. */
  6756. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6757. /**
  6758. * Creates a new Color4 from the starting index element of the given array
  6759. * @param array defines the source array to read from
  6760. * @param offset defines the offset in the source array
  6761. * @returns a new Color4 object
  6762. */
  6763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6764. /**
  6765. * Creates a new Color4 from the starting index element of the given array
  6766. * @param array defines the source array to read from
  6767. * @param offset defines the offset in the source array
  6768. * @param result defines the target Color4 object
  6769. */
  6770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6771. /**
  6772. * Creates a new Color3 from integer values (< 256)
  6773. * @param r defines the red component to read from (value between 0 and 255)
  6774. * @param g defines the green component to read from (value between 0 and 255)
  6775. * @param b defines the blue component to read from (value between 0 and 255)
  6776. * @param a defines the alpha component to read from (value between 0 and 255)
  6777. * @returns a new Color3 object
  6778. */
  6779. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6780. /**
  6781. * Check the content of a given array and convert it to an array containing RGBA data
  6782. * If the original array was already containing count * 4 values then it is returned directly
  6783. * @param colors defines the array to check
  6784. * @param count defines the number of RGBA data to expect
  6785. * @returns an array containing count * 4 values (RGBA)
  6786. */
  6787. static CheckColors4(colors: number[], count: number): number[];
  6788. }
  6789. /**
  6790. * @hidden
  6791. */
  6792. export class TmpColors {
  6793. static Color3: Color3[];
  6794. static Color4: Color4[];
  6795. }
  6796. }
  6797. declare module BABYLON {
  6798. /**
  6799. * Defines an interface which represents an animation key frame
  6800. */
  6801. export interface IAnimationKey {
  6802. /**
  6803. * Frame of the key frame
  6804. */
  6805. frame: number;
  6806. /**
  6807. * Value at the specifies key frame
  6808. */
  6809. value: any;
  6810. /**
  6811. * The input tangent for the cubic hermite spline
  6812. */
  6813. inTangent?: any;
  6814. /**
  6815. * The output tangent for the cubic hermite spline
  6816. */
  6817. outTangent?: any;
  6818. /**
  6819. * The animation interpolation type
  6820. */
  6821. interpolation?: AnimationKeyInterpolation;
  6822. }
  6823. /**
  6824. * Enum for the animation key frame interpolation type
  6825. */
  6826. export enum AnimationKeyInterpolation {
  6827. /**
  6828. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6829. */
  6830. STEP = 1
  6831. }
  6832. }
  6833. declare module BABYLON {
  6834. /**
  6835. * Represents the range of an animation
  6836. */
  6837. export class AnimationRange {
  6838. /**The name of the animation range**/
  6839. name: string;
  6840. /**The starting frame of the animation */
  6841. from: number;
  6842. /**The ending frame of the animation*/
  6843. to: number;
  6844. /**
  6845. * Initializes the range of an animation
  6846. * @param name The name of the animation range
  6847. * @param from The starting frame of the animation
  6848. * @param to The ending frame of the animation
  6849. */
  6850. constructor(
  6851. /**The name of the animation range**/
  6852. name: string,
  6853. /**The starting frame of the animation */
  6854. from: number,
  6855. /**The ending frame of the animation*/
  6856. to: number);
  6857. /**
  6858. * Makes a copy of the animation range
  6859. * @returns A copy of the animation range
  6860. */
  6861. clone(): AnimationRange;
  6862. }
  6863. }
  6864. declare module BABYLON {
  6865. /**
  6866. * Composed of a frame, and an action function
  6867. */
  6868. export class AnimationEvent {
  6869. /** The frame for which the event is triggered **/
  6870. frame: number;
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void;
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined;
  6875. /**
  6876. * Specifies if the animation event is done
  6877. */
  6878. isDone: boolean;
  6879. /**
  6880. * Initializes the animation event
  6881. * @param frame The frame for which the event is triggered
  6882. * @param action The event to perform when triggered
  6883. * @param onlyOnce Specifies if the event should be triggered only once
  6884. */
  6885. constructor(
  6886. /** The frame for which the event is triggered **/
  6887. frame: number,
  6888. /** The event to perform when triggered **/
  6889. action: (currentFrame: number) => void,
  6890. /** Specifies if the event should be triggered only once**/
  6891. onlyOnce?: boolean | undefined);
  6892. /** @hidden */
  6893. _clone(): AnimationEvent;
  6894. }
  6895. }
  6896. declare module BABYLON {
  6897. /**
  6898. * Interface used to define a behavior
  6899. */
  6900. export interface Behavior<T> {
  6901. /** gets or sets behavior's name */
  6902. name: string;
  6903. /**
  6904. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6905. */
  6906. init(): void;
  6907. /**
  6908. * Called when the behavior is attached to a target
  6909. * @param target defines the target where the behavior is attached to
  6910. */
  6911. attach(target: T): void;
  6912. /**
  6913. * Called when the behavior is detached from its target
  6914. */
  6915. detach(): void;
  6916. }
  6917. /**
  6918. * Interface implemented by classes supporting behaviors
  6919. */
  6920. export interface IBehaviorAware<T> {
  6921. /**
  6922. * Attach a behavior
  6923. * @param behavior defines the behavior to attach
  6924. * @returns the current host
  6925. */
  6926. addBehavior(behavior: Behavior<T>): T;
  6927. /**
  6928. * Remove a behavior from the current object
  6929. * @param behavior defines the behavior to detach
  6930. * @returns the current host
  6931. */
  6932. removeBehavior(behavior: Behavior<T>): T;
  6933. /**
  6934. * Gets a behavior using its name to search
  6935. * @param name defines the name to search
  6936. * @returns the behavior or null if not found
  6937. */
  6938. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6939. }
  6940. }
  6941. declare module BABYLON {
  6942. /**
  6943. * Class used to provide helpers for slicing
  6944. */
  6945. export class SliceTools {
  6946. /**
  6947. * Provides a slice function that will work even on IE
  6948. * @param data defines the array to slice
  6949. * @param start defines the start of the data (optional)
  6950. * @param end defines the end of the data (optional)
  6951. * @returns the new sliced array
  6952. */
  6953. static Slice<T>(data: T, start?: number, end?: number): T;
  6954. /**
  6955. * Provides a slice function that will work even on IE
  6956. * The difference between this and Slice is that this will force-convert to array
  6957. * @param data defines the array to slice
  6958. * @param start defines the start of the data (optional)
  6959. * @param end defines the end of the data (optional)
  6960. * @returns the new sliced array
  6961. */
  6962. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  6963. }
  6964. }
  6965. declare module BABYLON {
  6966. /**
  6967. * Class used to store data that will be store in GPU memory
  6968. */
  6969. export class Buffer {
  6970. private _engine;
  6971. private _buffer;
  6972. /** @hidden */
  6973. _data: Nullable<DataArray>;
  6974. private _updatable;
  6975. private _instanced;
  6976. private _divisor;
  6977. private _isAlreadyOwned;
  6978. /**
  6979. * Gets the byte stride.
  6980. */
  6981. readonly byteStride: number;
  6982. /**
  6983. * Constructor
  6984. * @param engine the engine
  6985. * @param data the data to use for this buffer
  6986. * @param updatable whether the data is updatable
  6987. * @param stride the stride (optional)
  6988. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6989. * @param instanced whether the buffer is instanced (optional)
  6990. * @param useBytes set to true if the stride in in bytes (optional)
  6991. * @param divisor sets an optional divisor for instances (1 by default)
  6992. */
  6993. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6994. /**
  6995. * Create a new VertexBuffer based on the current buffer
  6996. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6997. * @param offset defines offset in the buffer (0 by default)
  6998. * @param size defines the size in floats of attributes (position is 3 for instance)
  6999. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  7000. * @param instanced defines if the vertex buffer contains indexed data
  7001. * @param useBytes defines if the offset and stride are in bytes *
  7002. * @param divisor sets an optional divisor for instances (1 by default)
  7003. * @returns the new vertex buffer
  7004. */
  7005. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  7006. /**
  7007. * Gets a boolean indicating if the Buffer is updatable?
  7008. * @returns true if the buffer is updatable
  7009. */
  7010. isUpdatable(): boolean;
  7011. /**
  7012. * Gets current buffer's data
  7013. * @returns a DataArray or null
  7014. */
  7015. getData(): Nullable<DataArray>;
  7016. /**
  7017. * Gets underlying native buffer
  7018. * @returns underlying native buffer
  7019. */
  7020. getBuffer(): Nullable<DataBuffer>;
  7021. /**
  7022. * Gets the stride in float32 units (i.e. byte stride / 4).
  7023. * May not be an integer if the byte stride is not divisible by 4.
  7024. * @returns the stride in float32 units
  7025. * @deprecated Please use byteStride instead.
  7026. */
  7027. getStrideSize(): number;
  7028. /**
  7029. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7030. * @param data defines the data to store
  7031. */
  7032. create(data?: Nullable<DataArray>): void;
  7033. /** @hidden */
  7034. _rebuild(): void;
  7035. /**
  7036. * Update current buffer data
  7037. * @param data defines the data to store
  7038. */
  7039. update(data: DataArray): void;
  7040. /**
  7041. * Updates the data directly.
  7042. * @param data the new data
  7043. * @param offset the new offset
  7044. * @param vertexCount the vertex count (optional)
  7045. * @param useBytes set to true if the offset is in bytes
  7046. */
  7047. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7048. /** @hidden */
  7049. _increaseReferences(): void;
  7050. /**
  7051. * Release all resources
  7052. */
  7053. dispose(): void;
  7054. }
  7055. /**
  7056. * Specialized buffer used to store vertex data
  7057. */
  7058. export class VertexBuffer {
  7059. private static _Counter;
  7060. /** @hidden */
  7061. _buffer: Buffer;
  7062. private _kind;
  7063. private _size;
  7064. private _ownsBuffer;
  7065. private _instanced;
  7066. private _instanceDivisor;
  7067. /**
  7068. * The byte type.
  7069. */
  7070. static readonly BYTE: number;
  7071. /**
  7072. * The unsigned byte type.
  7073. */
  7074. static readonly UNSIGNED_BYTE: number;
  7075. /**
  7076. * The short type.
  7077. */
  7078. static readonly SHORT: number;
  7079. /**
  7080. * The unsigned short type.
  7081. */
  7082. static readonly UNSIGNED_SHORT: number;
  7083. /**
  7084. * The integer type.
  7085. */
  7086. static readonly INT: number;
  7087. /**
  7088. * The unsigned integer type.
  7089. */
  7090. static readonly UNSIGNED_INT: number;
  7091. /**
  7092. * The float type.
  7093. */
  7094. static readonly FLOAT: number;
  7095. /**
  7096. * Gets or sets the instance divisor when in instanced mode
  7097. */
  7098. get instanceDivisor(): number;
  7099. set instanceDivisor(value: number);
  7100. /**
  7101. * Gets the byte stride.
  7102. */
  7103. readonly byteStride: number;
  7104. /**
  7105. * Gets the byte offset.
  7106. */
  7107. readonly byteOffset: number;
  7108. /**
  7109. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7110. */
  7111. readonly normalized: boolean;
  7112. /**
  7113. * Gets the data type of each component in the array.
  7114. */
  7115. readonly type: number;
  7116. /**
  7117. * Gets the unique id of this vertex buffer
  7118. */
  7119. readonly uniqueId: number;
  7120. /**
  7121. * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer
  7122. * All buffers with the same format will have the same hash code
  7123. */
  7124. readonly hashCode: number;
  7125. /**
  7126. * Constructor
  7127. * @param engine the engine
  7128. * @param data the data to use for this vertex buffer
  7129. * @param kind the vertex buffer kind
  7130. * @param updatable whether the data is updatable
  7131. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7132. * @param stride the stride (optional)
  7133. * @param instanced whether the buffer is instanced (optional)
  7134. * @param offset the offset of the data (optional)
  7135. * @param size the number of components (optional)
  7136. * @param type the type of the component (optional)
  7137. * @param normalized whether the data contains normalized data (optional)
  7138. * @param useBytes set to true if stride and offset are in bytes (optional)
  7139. * @param divisor defines the instance divisor to use (1 by default)
  7140. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7141. */
  7142. 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);
  7143. private _computeHashCode;
  7144. /** @hidden */
  7145. _rebuild(): void;
  7146. /**
  7147. * Returns the kind of the VertexBuffer (string)
  7148. * @returns a string
  7149. */
  7150. getKind(): string;
  7151. /**
  7152. * Gets a boolean indicating if the VertexBuffer is updatable?
  7153. * @returns true if the buffer is updatable
  7154. */
  7155. isUpdatable(): boolean;
  7156. /**
  7157. * Gets current buffer's data
  7158. * @returns a DataArray or null
  7159. */
  7160. getData(): Nullable<DataArray>;
  7161. /**
  7162. * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.
  7163. * @param totalVertices number of vertices in the buffer to take into account
  7164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  7165. * @returns a float array containing vertex data
  7166. */
  7167. getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray>;
  7168. /**
  7169. * Gets underlying native buffer
  7170. * @returns underlying native buffer
  7171. */
  7172. getBuffer(): Nullable<DataBuffer>;
  7173. /**
  7174. * Gets the stride in float32 units (i.e. byte stride / 4).
  7175. * May not be an integer if the byte stride is not divisible by 4.
  7176. * @returns the stride in float32 units
  7177. * @deprecated Please use byteStride instead.
  7178. */
  7179. getStrideSize(): number;
  7180. /**
  7181. * Returns the offset as a multiple of the type byte length.
  7182. * @returns the offset in bytes
  7183. * @deprecated Please use byteOffset instead.
  7184. */
  7185. getOffset(): number;
  7186. /**
  7187. * Returns the number of components per vertex attribute (integer)
  7188. * @returns the size in float
  7189. */
  7190. getSize(): number;
  7191. /**
  7192. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7193. * @returns true if this buffer is instanced
  7194. */
  7195. getIsInstanced(): boolean;
  7196. /**
  7197. * Returns the instancing divisor, zero for non-instanced (integer).
  7198. * @returns a number
  7199. */
  7200. getInstanceDivisor(): number;
  7201. /**
  7202. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7203. * @param data defines the data to store
  7204. */
  7205. create(data?: DataArray): void;
  7206. /**
  7207. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7208. * This function will create a new buffer if the current one is not updatable
  7209. * @param data defines the data to store
  7210. */
  7211. update(data: DataArray): void;
  7212. /**
  7213. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7214. * Returns the directly updated WebGLBuffer.
  7215. * @param data the new data
  7216. * @param offset the new offset
  7217. * @param useBytes set to true if the offset is in bytes
  7218. */
  7219. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7220. /**
  7221. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7222. */
  7223. dispose(): void;
  7224. /**
  7225. * Enumerates each value of this vertex buffer as numbers.
  7226. * @param count the number of values to enumerate
  7227. * @param callback the callback function called for each value
  7228. */
  7229. forEach(count: number, callback: (value: number, index: number) => void): void;
  7230. /**
  7231. * Positions
  7232. */
  7233. static readonly PositionKind: string;
  7234. /**
  7235. * Normals
  7236. */
  7237. static readonly NormalKind: string;
  7238. /**
  7239. * Tangents
  7240. */
  7241. static readonly TangentKind: string;
  7242. /**
  7243. * Texture coordinates
  7244. */
  7245. static readonly UVKind: string;
  7246. /**
  7247. * Texture coordinates 2
  7248. */
  7249. static readonly UV2Kind: string;
  7250. /**
  7251. * Texture coordinates 3
  7252. */
  7253. static readonly UV3Kind: string;
  7254. /**
  7255. * Texture coordinates 4
  7256. */
  7257. static readonly UV4Kind: string;
  7258. /**
  7259. * Texture coordinates 5
  7260. */
  7261. static readonly UV5Kind: string;
  7262. /**
  7263. * Texture coordinates 6
  7264. */
  7265. static readonly UV6Kind: string;
  7266. /**
  7267. * Colors
  7268. */
  7269. static readonly ColorKind: string;
  7270. /**
  7271. * Matrix indices (for bones)
  7272. */
  7273. static readonly MatricesIndicesKind: string;
  7274. /**
  7275. * Matrix weights (for bones)
  7276. */
  7277. static readonly MatricesWeightsKind: string;
  7278. /**
  7279. * Additional matrix indices (for bones)
  7280. */
  7281. static readonly MatricesIndicesExtraKind: string;
  7282. /**
  7283. * Additional matrix weights (for bones)
  7284. */
  7285. static readonly MatricesWeightsExtraKind: string;
  7286. /**
  7287. * Deduces the stride given a kind.
  7288. * @param kind The kind string to deduce
  7289. * @returns The deduced stride
  7290. */
  7291. static DeduceStride(kind: string): number;
  7292. /**
  7293. * Gets the byte length of the given type.
  7294. * @param type the type
  7295. * @returns the number of bytes
  7296. */
  7297. static GetTypeByteLength(type: number): number;
  7298. /**
  7299. * Enumerates each value of the given parameters as numbers.
  7300. * @param data the data to enumerate
  7301. * @param byteOffset the byte offset of the data
  7302. * @param byteStride the byte stride of the data
  7303. * @param componentCount the number of components per element
  7304. * @param componentType the type of the component
  7305. * @param count the number of values to enumerate
  7306. * @param normalized whether the data is normalized
  7307. * @param callback the callback function called for each value
  7308. */
  7309. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7310. private static _GetFloatValue;
  7311. }
  7312. }
  7313. declare module BABYLON {
  7314. /**
  7315. * @hidden
  7316. */
  7317. export class IntersectionInfo {
  7318. bu: Nullable<number>;
  7319. bv: Nullable<number>;
  7320. distance: number;
  7321. faceId: number;
  7322. subMeshId: number;
  7323. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7324. }
  7325. }
  7326. declare module BABYLON {
  7327. /**
  7328. * Class used to store bounding sphere information
  7329. */
  7330. export class BoundingSphere {
  7331. /**
  7332. * Gets the center of the bounding sphere in local space
  7333. */
  7334. readonly center: Vector3;
  7335. /**
  7336. * Radius of the bounding sphere in local space
  7337. */
  7338. radius: number;
  7339. /**
  7340. * Gets the center of the bounding sphere in world space
  7341. */
  7342. readonly centerWorld: Vector3;
  7343. /**
  7344. * Radius of the bounding sphere in world space
  7345. */
  7346. radiusWorld: number;
  7347. /**
  7348. * Gets the minimum vector in local space
  7349. */
  7350. readonly minimum: Vector3;
  7351. /**
  7352. * Gets the maximum vector in local space
  7353. */
  7354. readonly maximum: Vector3;
  7355. private _worldMatrix;
  7356. private static readonly TmpVector3;
  7357. /**
  7358. * Creates a new bounding sphere
  7359. * @param min defines the minimum vector (in local space)
  7360. * @param max defines the maximum vector (in local space)
  7361. * @param worldMatrix defines the new world matrix
  7362. */
  7363. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7364. /**
  7365. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7366. * @param min defines the new minimum vector (in local space)
  7367. * @param max defines the new maximum vector (in local space)
  7368. * @param worldMatrix defines the new world matrix
  7369. */
  7370. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7371. /**
  7372. * Scale the current bounding sphere by applying a scale factor
  7373. * @param factor defines the scale factor to apply
  7374. * @returns the current bounding box
  7375. */
  7376. scale(factor: number): BoundingSphere;
  7377. /**
  7378. * Gets the world matrix of the bounding box
  7379. * @returns a matrix
  7380. */
  7381. getWorldMatrix(): DeepImmutable<Matrix>;
  7382. /** @hidden */
  7383. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7384. /**
  7385. * Tests if the bounding sphere is intersecting the frustum planes
  7386. * @param frustumPlanes defines the frustum planes to test
  7387. * @returns true if there is an intersection
  7388. */
  7389. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7390. /**
  7391. * Tests if the bounding sphere center is in between the frustum planes.
  7392. * Used for optimistic fast inclusion.
  7393. * @param frustumPlanes defines the frustum planes to test
  7394. * @returns true if the sphere center is in between the frustum planes
  7395. */
  7396. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7397. /**
  7398. * Tests if a point is inside the bounding sphere
  7399. * @param point defines the point to test
  7400. * @returns true if the point is inside the bounding sphere
  7401. */
  7402. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7403. /**
  7404. * Checks if two sphere intersect
  7405. * @param sphere0 sphere 0
  7406. * @param sphere1 sphere 1
  7407. * @returns true if the spheres intersect
  7408. */
  7409. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7410. }
  7411. }
  7412. declare module BABYLON {
  7413. /**
  7414. * Class used to store bounding box information
  7415. */
  7416. export class BoundingBox implements ICullable {
  7417. /**
  7418. * Gets the 8 vectors representing the bounding box in local space
  7419. */
  7420. readonly vectors: Vector3[];
  7421. /**
  7422. * Gets the center of the bounding box in local space
  7423. */
  7424. readonly center: Vector3;
  7425. /**
  7426. * Gets the center of the bounding box in world space
  7427. */
  7428. readonly centerWorld: Vector3;
  7429. /**
  7430. * Gets the extend size in local space
  7431. */
  7432. readonly extendSize: Vector3;
  7433. /**
  7434. * Gets the extend size in world space
  7435. */
  7436. readonly extendSizeWorld: Vector3;
  7437. /**
  7438. * Gets the OBB (object bounding box) directions
  7439. */
  7440. readonly directions: Vector3[];
  7441. /**
  7442. * Gets the 8 vectors representing the bounding box in world space
  7443. */
  7444. readonly vectorsWorld: Vector3[];
  7445. /**
  7446. * Gets the minimum vector in world space
  7447. */
  7448. readonly minimumWorld: Vector3;
  7449. /**
  7450. * Gets the maximum vector in world space
  7451. */
  7452. readonly maximumWorld: Vector3;
  7453. /**
  7454. * Gets the minimum vector in local space
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * Gets the maximum vector in local space
  7459. */
  7460. readonly maximum: Vector3;
  7461. private _worldMatrix;
  7462. private static readonly TmpVector3;
  7463. /**
  7464. * @hidden
  7465. */
  7466. _tag: number;
  7467. /**
  7468. * Creates a new bounding box
  7469. * @param min defines the minimum vector (in local space)
  7470. * @param max defines the maximum vector (in local space)
  7471. * @param worldMatrix defines the new world matrix
  7472. */
  7473. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7474. /**
  7475. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7476. * @param min defines the new minimum vector (in local space)
  7477. * @param max defines the new maximum vector (in local space)
  7478. * @param worldMatrix defines the new world matrix
  7479. */
  7480. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7481. /**
  7482. * Scale the current bounding box by applying a scale factor
  7483. * @param factor defines the scale factor to apply
  7484. * @returns the current bounding box
  7485. */
  7486. scale(factor: number): BoundingBox;
  7487. /**
  7488. * Gets the world matrix of the bounding box
  7489. * @returns a matrix
  7490. */
  7491. getWorldMatrix(): DeepImmutable<Matrix>;
  7492. /** @hidden */
  7493. _update(world: DeepImmutable<Matrix>): void;
  7494. /**
  7495. * Tests if the bounding box is intersecting the frustum planes
  7496. * @param frustumPlanes defines the frustum planes to test
  7497. * @returns true if there is an intersection
  7498. */
  7499. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7500. /**
  7501. * Tests if the bounding box is entirely inside the frustum planes
  7502. * @param frustumPlanes defines the frustum planes to test
  7503. * @returns true if there is an inclusion
  7504. */
  7505. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7506. /**
  7507. * Tests if a point is inside the bounding box
  7508. * @param point defines the point to test
  7509. * @returns true if the point is inside the bounding box
  7510. */
  7511. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7512. /**
  7513. * Tests if the bounding box intersects with a bounding sphere
  7514. * @param sphere defines the sphere to test
  7515. * @returns true if there is an intersection
  7516. */
  7517. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7518. /**
  7519. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7520. * @param min defines the min vector to use
  7521. * @param max defines the max vector to use
  7522. * @returns true if there is an intersection
  7523. */
  7524. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7525. /**
  7526. * Tests if two bounding boxes are intersections
  7527. * @param box0 defines the first box to test
  7528. * @param box1 defines the second box to test
  7529. * @returns true if there is an intersection
  7530. */
  7531. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7532. /**
  7533. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7534. * @param minPoint defines the minimum vector of the bounding box
  7535. * @param maxPoint defines the maximum vector of the bounding box
  7536. * @param sphereCenter defines the sphere center
  7537. * @param sphereRadius defines the sphere radius
  7538. * @returns true if there is an intersection
  7539. */
  7540. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7541. /**
  7542. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7543. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7544. * @param frustumPlanes defines the frustum planes to test
  7545. * @return true if there is an inclusion
  7546. */
  7547. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7548. /**
  7549. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7550. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7551. * @param frustumPlanes defines the frustum planes to test
  7552. * @return true if there is an intersection
  7553. */
  7554. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /** @hidden */
  7559. export class Collider {
  7560. /** Define if a collision was found */
  7561. collisionFound: boolean;
  7562. /**
  7563. * Define last intersection point in local space
  7564. */
  7565. intersectionPoint: Vector3;
  7566. /**
  7567. * Define last collided mesh
  7568. */
  7569. collidedMesh: Nullable<AbstractMesh>;
  7570. private _collisionPoint;
  7571. private _planeIntersectionPoint;
  7572. private _tempVector;
  7573. private _tempVector2;
  7574. private _tempVector3;
  7575. private _tempVector4;
  7576. private _edge;
  7577. private _baseToVertex;
  7578. private _destinationPoint;
  7579. private _slidePlaneNormal;
  7580. private _displacementVector;
  7581. /** @hidden */
  7582. _radius: Vector3;
  7583. /** @hidden */
  7584. _retry: number;
  7585. private _velocity;
  7586. private _basePoint;
  7587. private _epsilon;
  7588. /** @hidden */
  7589. _velocityWorldLength: number;
  7590. /** @hidden */
  7591. _basePointWorld: Vector3;
  7592. private _velocityWorld;
  7593. private _normalizedVelocity;
  7594. /** @hidden */
  7595. _initialVelocity: Vector3;
  7596. /** @hidden */
  7597. _initialPosition: Vector3;
  7598. private _nearestDistance;
  7599. private _collisionMask;
  7600. get collisionMask(): number;
  7601. set collisionMask(mask: number);
  7602. /**
  7603. * Gets the plane normal used to compute the sliding response (in local space)
  7604. */
  7605. get slidePlaneNormal(): Vector3;
  7606. /** @hidden */
  7607. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7608. /** @hidden */
  7609. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7610. /** @hidden */
  7611. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7612. /** @hidden */
  7613. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7614. /** @hidden */
  7615. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7616. /** @hidden */
  7617. _getResponse(pos: Vector3, vel: Vector3): void;
  7618. }
  7619. }
  7620. declare module BABYLON {
  7621. /**
  7622. * Interface for cullable objects
  7623. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7624. */
  7625. export interface ICullable {
  7626. /**
  7627. * Checks if the object or part of the object is in the frustum
  7628. * @param frustumPlanes Camera near/planes
  7629. * @returns true if the object is in frustum otherwise false
  7630. */
  7631. isInFrustum(frustumPlanes: Plane[]): boolean;
  7632. /**
  7633. * Checks if a cullable object (mesh...) is in the camera frustum
  7634. * Unlike isInFrustum this checks the full bounding box
  7635. * @param frustumPlanes Camera near/planes
  7636. * @returns true if the object is in frustum otherwise false
  7637. */
  7638. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7639. }
  7640. /**
  7641. * Info for a bounding data of a mesh
  7642. */
  7643. export class BoundingInfo implements ICullable {
  7644. /**
  7645. * Bounding box for the mesh
  7646. */
  7647. readonly boundingBox: BoundingBox;
  7648. /**
  7649. * Bounding sphere for the mesh
  7650. */
  7651. readonly boundingSphere: BoundingSphere;
  7652. private _isLocked;
  7653. private static readonly TmpVector3;
  7654. /**
  7655. * Constructs bounding info
  7656. * @param minimum min vector of the bounding box/sphere
  7657. * @param maximum max vector of the bounding box/sphere
  7658. * @param worldMatrix defines the new world matrix
  7659. */
  7660. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7661. /**
  7662. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7663. * @param min defines the new minimum vector (in local space)
  7664. * @param max defines the new maximum vector (in local space)
  7665. * @param worldMatrix defines the new world matrix
  7666. */
  7667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7668. /**
  7669. * min vector of the bounding box/sphere
  7670. */
  7671. get minimum(): Vector3;
  7672. /**
  7673. * max vector of the bounding box/sphere
  7674. */
  7675. get maximum(): Vector3;
  7676. /**
  7677. * If the info is locked and won't be updated to avoid perf overhead
  7678. */
  7679. get isLocked(): boolean;
  7680. set isLocked(value: boolean);
  7681. /**
  7682. * Updates the bounding sphere and box
  7683. * @param world world matrix to be used to update
  7684. */
  7685. update(world: DeepImmutable<Matrix>): void;
  7686. /**
  7687. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7688. * @param center New center of the bounding info
  7689. * @param extend New extend of the bounding info
  7690. * @returns the current bounding info
  7691. */
  7692. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7693. /**
  7694. * Grows the bounding info to include the given point.
  7695. * @param point The point that will be included in the current bounding info
  7696. * @returns the current bounding info
  7697. */
  7698. encapsulate(point: Vector3): BoundingInfo;
  7699. /**
  7700. * Grows the bounding info to encapsulate the given bounding info.
  7701. * @param toEncapsulate The bounding info that will be encapsulated in the current bounding info
  7702. * @returns the current bounding info
  7703. */
  7704. encapsulateBoundingInfo(toEncapsulate: BoundingInfo): BoundingInfo;
  7705. /**
  7706. * Scale the current bounding info by applying a scale factor
  7707. * @param factor defines the scale factor to apply
  7708. * @returns the current bounding info
  7709. */
  7710. scale(factor: number): BoundingInfo;
  7711. /**
  7712. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7713. * @param frustumPlanes defines the frustum to test
  7714. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7715. * @returns true if the bounding info is in the frustum planes
  7716. */
  7717. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7718. /**
  7719. * Gets the world distance between the min and max points of the bounding box
  7720. */
  7721. get diagonalLength(): number;
  7722. /**
  7723. * Checks if a cullable object (mesh...) is in the camera frustum
  7724. * Unlike isInFrustum this checks the full bounding box
  7725. * @param frustumPlanes Camera near/planes
  7726. * @returns true if the object is in frustum otherwise false
  7727. */
  7728. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7729. /** @hidden */
  7730. _checkCollision(collider: Collider): boolean;
  7731. /**
  7732. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7733. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7734. * @param point the point to check intersection with
  7735. * @returns if the point intersects
  7736. */
  7737. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7738. /**
  7739. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7740. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7741. * @param boundingInfo the bounding info to check intersection with
  7742. * @param precise if the intersection should be done using OBB
  7743. * @returns if the bounding info intersects
  7744. */
  7745. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Extracts minimum and maximum values from a list of indexed positions
  7751. * @param positions defines the positions to use
  7752. * @param indices defines the indices to the positions
  7753. * @param indexStart defines the start index
  7754. * @param indexCount defines the end index
  7755. * @param bias defines bias value to add to the result
  7756. * @return minimum and maximum values
  7757. */
  7758. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7759. minimum: Vector3;
  7760. maximum: Vector3;
  7761. };
  7762. /**
  7763. * Extracts minimum and maximum values from a list of positions
  7764. * @param positions defines the positions to use
  7765. * @param start defines the start index in the positions array
  7766. * @param count defines the number of positions to handle
  7767. * @param bias defines bias value to add to the result
  7768. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7769. * @return minimum and maximum values
  7770. */
  7771. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7772. minimum: Vector3;
  7773. maximum: Vector3;
  7774. };
  7775. }
  7776. declare module BABYLON {
  7777. /**
  7778. * Class used to manipulate GUIDs
  7779. */
  7780. export class GUID {
  7781. /**
  7782. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7783. * Be aware Math.random() could cause collisions, but:
  7784. * "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"
  7785. * @returns a pseudo random id
  7786. */
  7787. static RandomId(): string;
  7788. }
  7789. }
  7790. declare module BABYLON {
  7791. /**
  7792. * Base class of all the textures in babylon.
  7793. * It groups all the common properties the materials, post process, lights... might need
  7794. * in order to make a correct use of the texture.
  7795. */
  7796. export class BaseTexture extends ThinTexture implements IAnimatable {
  7797. /**
  7798. * Default anisotropic filtering level for the application.
  7799. * It is set to 4 as a good tradeoff between perf and quality.
  7800. */
  7801. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7802. /**
  7803. * Gets or sets the unique id of the texture
  7804. */
  7805. uniqueId: number;
  7806. /**
  7807. * Define the name of the texture.
  7808. */
  7809. name: string;
  7810. /**
  7811. * Gets or sets an object used to store user defined information.
  7812. */
  7813. metadata: any;
  7814. /**
  7815. * For internal use only. Please do not use.
  7816. */
  7817. reservedDataStore: any;
  7818. private _hasAlpha;
  7819. /**
  7820. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7821. */
  7822. set hasAlpha(value: boolean);
  7823. get hasAlpha(): boolean;
  7824. /**
  7825. * Defines if the alpha value should be determined via the rgb values.
  7826. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7827. */
  7828. getAlphaFromRGB: boolean;
  7829. /**
  7830. * Intensity or strength of the texture.
  7831. * It is commonly used by materials to fine tune the intensity of the texture
  7832. */
  7833. level: number;
  7834. /**
  7835. * Define the UV channel to use starting from 0 and defaulting to 0.
  7836. * This is part of the texture as textures usually maps to one uv set.
  7837. */
  7838. coordinatesIndex: number;
  7839. protected _coordinatesMode: number;
  7840. /**
  7841. * How a texture is mapped.
  7842. *
  7843. * | Value | Type | Description |
  7844. * | ----- | ----------------------------------- | ----------- |
  7845. * | 0 | EXPLICIT_MODE | |
  7846. * | 1 | SPHERICAL_MODE | |
  7847. * | 2 | PLANAR_MODE | |
  7848. * | 3 | CUBIC_MODE | |
  7849. * | 4 | PROJECTION_MODE | |
  7850. * | 5 | SKYBOX_MODE | |
  7851. * | 6 | INVCUBIC_MODE | |
  7852. * | 7 | EQUIRECTANGULAR_MODE | |
  7853. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7854. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7855. */
  7856. set coordinatesMode(value: number);
  7857. get coordinatesMode(): number;
  7858. /**
  7859. * | Value | Type | Description |
  7860. * | ----- | ------------------ | ----------- |
  7861. * | 0 | CLAMP_ADDRESSMODE | |
  7862. * | 1 | WRAP_ADDRESSMODE | |
  7863. * | 2 | MIRROR_ADDRESSMODE | |
  7864. */
  7865. get wrapU(): number;
  7866. set wrapU(value: number);
  7867. /**
  7868. * | Value | Type | Description |
  7869. * | ----- | ------------------ | ----------- |
  7870. * | 0 | CLAMP_ADDRESSMODE | |
  7871. * | 1 | WRAP_ADDRESSMODE | |
  7872. * | 2 | MIRROR_ADDRESSMODE | |
  7873. */
  7874. get wrapV(): number;
  7875. set wrapV(value: number);
  7876. /**
  7877. * | Value | Type | Description |
  7878. * | ----- | ------------------ | ----------- |
  7879. * | 0 | CLAMP_ADDRESSMODE | |
  7880. * | 1 | WRAP_ADDRESSMODE | |
  7881. * | 2 | MIRROR_ADDRESSMODE | |
  7882. */
  7883. wrapR: number;
  7884. /**
  7885. * With compliant hardware and browser (supporting anisotropic filtering)
  7886. * this defines the level of anisotropic filtering in the texture.
  7887. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7888. */
  7889. anisotropicFilteringLevel: number;
  7890. private _isCube;
  7891. /**
  7892. * Define if the texture is a cube texture or if false a 2d texture.
  7893. */
  7894. get isCube(): boolean;
  7895. set isCube(value: boolean);
  7896. /**
  7897. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7898. */
  7899. get is3D(): boolean;
  7900. set is3D(value: boolean);
  7901. /**
  7902. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7903. */
  7904. get is2DArray(): boolean;
  7905. set is2DArray(value: boolean);
  7906. private _gammaSpace;
  7907. /**
  7908. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7909. * HDR texture are usually stored in linear space.
  7910. * This only impacts the PBR and Background materials
  7911. */
  7912. get gammaSpace(): boolean;
  7913. set gammaSpace(gamma: boolean);
  7914. /**
  7915. * Gets or sets whether or not the texture contains RGBD data.
  7916. */
  7917. get isRGBD(): boolean;
  7918. set isRGBD(value: boolean);
  7919. /**
  7920. * Is Z inverted in the texture (useful in a cube texture).
  7921. */
  7922. invertZ: boolean;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. /**
  7928. * @hidden
  7929. */
  7930. lodLevelInAlpha: boolean;
  7931. /**
  7932. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7933. */
  7934. get lodGenerationOffset(): number;
  7935. set lodGenerationOffset(value: number);
  7936. /**
  7937. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7938. */
  7939. get lodGenerationScale(): number;
  7940. set lodGenerationScale(value: number);
  7941. /**
  7942. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7943. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7944. * average roughness values.
  7945. */
  7946. get linearSpecularLOD(): boolean;
  7947. set linearSpecularLOD(value: boolean);
  7948. /**
  7949. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7950. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7951. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7952. */
  7953. get irradianceTexture(): Nullable<BaseTexture>;
  7954. set irradianceTexture(value: Nullable<BaseTexture>);
  7955. /**
  7956. * Define if the texture is a render target.
  7957. */
  7958. isRenderTarget: boolean;
  7959. /**
  7960. * Define the unique id of the texture in the scene.
  7961. */
  7962. get uid(): string;
  7963. /** @hidden */
  7964. _prefiltered: boolean;
  7965. /**
  7966. * Return a string representation of the texture.
  7967. * @returns the texture as a string
  7968. */
  7969. toString(): string;
  7970. /**
  7971. * Get the class name of the texture.
  7972. * @returns "BaseTexture"
  7973. */
  7974. getClassName(): string;
  7975. /**
  7976. * Define the list of animation attached to the texture.
  7977. */
  7978. animations: Animation[];
  7979. /**
  7980. * An event triggered when the texture is disposed.
  7981. */
  7982. onDisposeObservable: Observable<BaseTexture>;
  7983. private _onDisposeObserver;
  7984. /**
  7985. * Callback triggered when the texture has been disposed.
  7986. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7987. */
  7988. set onDispose(callback: () => void);
  7989. protected _scene: Nullable<Scene>;
  7990. /** @hidden */
  7991. _texture: Nullable<InternalTexture>;
  7992. private _uid;
  7993. /**
  7994. * Define if the texture is preventing a material to render or not.
  7995. * If not and the texture is not ready, the engine will use a default black texture instead.
  7996. */
  7997. get isBlocking(): boolean;
  7998. /**
  7999. * Instantiates a new BaseTexture.
  8000. * Base class of all the textures in babylon.
  8001. * It groups all the common properties the materials, post process, lights... might need
  8002. * in order to make a correct use of the texture.
  8003. * @param sceneOrEngine Define the scene or engine the texture belongs to
  8004. */
  8005. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  8006. /**
  8007. * Get the scene the texture belongs to.
  8008. * @returns the scene or null if undefined
  8009. */
  8010. getScene(): Nullable<Scene>;
  8011. /** @hidden */
  8012. protected _getEngine(): Nullable<ThinEngine>;
  8013. /**
  8014. * Checks if the texture has the same transform matrix than another texture
  8015. * @param texture texture to check against
  8016. * @returns true if the transforms are the same, else false
  8017. */
  8018. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  8019. /**
  8020. * Get the texture transform matrix used to offset tile the texture for instance.
  8021. * @returns the transformation matrix
  8022. */
  8023. getTextureMatrix(): Matrix;
  8024. /**
  8025. * Get the texture reflection matrix used to rotate/transform the reflection.
  8026. * @returns the reflection matrix
  8027. */
  8028. getReflectionTextureMatrix(): Matrix;
  8029. /**
  8030. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  8031. * @returns true if ready or not blocking
  8032. */
  8033. isReadyOrNotBlocking(): boolean;
  8034. /**
  8035. * Scales the texture if is `canRescale()`
  8036. * @param ratio the resize factor we want to use to rescale
  8037. */
  8038. scale(ratio: number): void;
  8039. /**
  8040. * Get if the texture can rescale.
  8041. */
  8042. get canRescale(): boolean;
  8043. /** @hidden */
  8044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  8045. /** @hidden */
  8046. _rebuild(): void;
  8047. /**
  8048. * Clones the texture.
  8049. * @returns the cloned texture
  8050. */
  8051. clone(): Nullable<BaseTexture>;
  8052. /**
  8053. * Get the texture underlying type (INT, FLOAT...)
  8054. */
  8055. get textureType(): number;
  8056. /**
  8057. * Get the texture underlying format (RGB, RGBA...)
  8058. */
  8059. get textureFormat(): number;
  8060. /**
  8061. * Indicates that textures need to be re-calculated for all materials
  8062. */
  8063. protected _markAllSubMeshesAsTexturesDirty(): void;
  8064. /**
  8065. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  8066. * This will returns an RGBA array buffer containing either in values (0-255) or
  8067. * float values (0-1) depending of the underlying buffer type.
  8068. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  8069. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  8070. * @param buffer defines a user defined buffer to fill with data (can be null)
  8071. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  8072. * @returns The Array buffer promise containing the pixels data.
  8073. */
  8074. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  8075. /** @hidden */
  8076. _readPixelsSync(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<ArrayBufferView>;
  8077. /** @hidden */
  8078. get _lodTextureHigh(): Nullable<BaseTexture>;
  8079. /** @hidden */
  8080. get _lodTextureMid(): Nullable<BaseTexture>;
  8081. /** @hidden */
  8082. get _lodTextureLow(): Nullable<BaseTexture>;
  8083. /**
  8084. * Dispose the texture and release its associated resources.
  8085. */
  8086. dispose(): void;
  8087. /**
  8088. * Serialize the texture into a JSON representation that can be parsed later on.
  8089. * @returns the JSON representation of the texture
  8090. */
  8091. serialize(): any;
  8092. /**
  8093. * Helper function to be called back once a list of texture contains only ready textures.
  8094. * @param textures Define the list of textures to wait for
  8095. * @param callback Define the callback triggered once the entire list will be ready
  8096. */
  8097. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8098. private static _isScene;
  8099. }
  8100. }
  8101. declare module BABYLON {
  8102. /** @hidden */
  8103. export class WebGLDataBuffer extends DataBuffer {
  8104. private _buffer;
  8105. constructor(resource: WebGLBuffer);
  8106. get underlyingResource(): any;
  8107. }
  8108. }
  8109. declare module BABYLON {
  8110. /** @hidden */
  8111. export class WebGLPipelineContext implements IPipelineContext {
  8112. private _valueCache;
  8113. private _uniforms;
  8114. engine: ThinEngine;
  8115. program: Nullable<WebGLProgram>;
  8116. context?: WebGLRenderingContext;
  8117. vertexShader?: WebGLShader;
  8118. fragmentShader?: WebGLShader;
  8119. isParallelCompiled: boolean;
  8120. onCompiled?: () => void;
  8121. transformFeedback?: WebGLTransformFeedback | null;
  8122. vertexCompilationError: Nullable<string>;
  8123. fragmentCompilationError: Nullable<string>;
  8124. programLinkError: Nullable<string>;
  8125. programValidationError: Nullable<string>;
  8126. get isAsync(): boolean;
  8127. get isReady(): boolean;
  8128. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8129. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8130. [key: string]: number;
  8131. }, uniformsNames: string[], uniforms: {
  8132. [key: string]: Nullable<WebGLUniformLocation>;
  8133. }, samplerList: string[], samplers: {
  8134. [key: string]: number;
  8135. }, attributesNames: string[], attributes: number[]): void;
  8136. /**
  8137. * Release all associated resources.
  8138. **/
  8139. dispose(): void;
  8140. /** @hidden */
  8141. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8142. /** @hidden */
  8143. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8144. /** @hidden */
  8145. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8146. /** @hidden */
  8147. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8148. /**
  8149. * Sets an integer value on a uniform variable.
  8150. * @param uniformName Name of the variable.
  8151. * @param value Value to be set.
  8152. */
  8153. setInt(uniformName: string, value: number): void;
  8154. /**
  8155. * Sets a int2 on a uniform variable.
  8156. * @param uniformName Name of the variable.
  8157. * @param x First int in int2.
  8158. * @param y Second int in int2.
  8159. */
  8160. setInt2(uniformName: string, x: number, y: number): void;
  8161. /**
  8162. * Sets a int3 on a uniform variable.
  8163. * @param uniformName Name of the variable.
  8164. * @param x First int in int3.
  8165. * @param y Second int in int3.
  8166. * @param y Third int in int3.
  8167. */
  8168. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8169. /**
  8170. * Sets a int4 on a uniform variable.
  8171. * @param uniformName Name of the variable.
  8172. * @param x First int in int4.
  8173. * @param y Second int in int4.
  8174. * @param y Third int in int4.
  8175. * @param w Fourth int in int4.
  8176. */
  8177. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8178. /**
  8179. * Sets an int array on a uniform variable.
  8180. * @param uniformName Name of the variable.
  8181. * @param array array to be set.
  8182. */
  8183. setIntArray(uniformName: string, array: Int32Array): void;
  8184. /**
  8185. * 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)
  8186. * @param uniformName Name of the variable.
  8187. * @param array array to be set.
  8188. */
  8189. setIntArray2(uniformName: string, array: Int32Array): void;
  8190. /**
  8191. * 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)
  8192. * @param uniformName Name of the variable.
  8193. * @param array array to be set.
  8194. */
  8195. setIntArray3(uniformName: string, array: Int32Array): void;
  8196. /**
  8197. * 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)
  8198. * @param uniformName Name of the variable.
  8199. * @param array array to be set.
  8200. */
  8201. setIntArray4(uniformName: string, array: Int32Array): void;
  8202. /**
  8203. * Sets an array on a uniform variable.
  8204. * @param uniformName Name of the variable.
  8205. * @param array array to be set.
  8206. */
  8207. setArray(uniformName: string, array: number[]): void;
  8208. /**
  8209. * 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)
  8210. * @param uniformName Name of the variable.
  8211. * @param array array to be set.
  8212. */
  8213. setArray2(uniformName: string, array: number[]): void;
  8214. /**
  8215. * 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)
  8216. * @param uniformName Name of the variable.
  8217. * @param array array to be set.
  8218. * @returns this effect.
  8219. */
  8220. setArray3(uniformName: string, array: number[]): void;
  8221. /**
  8222. * 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)
  8223. * @param uniformName Name of the variable.
  8224. * @param array array to be set.
  8225. */
  8226. setArray4(uniformName: string, array: number[]): void;
  8227. /**
  8228. * Sets matrices on a uniform variable.
  8229. * @param uniformName Name of the variable.
  8230. * @param matrices matrices to be set.
  8231. */
  8232. setMatrices(uniformName: string, matrices: Float32Array): void;
  8233. /**
  8234. * Sets matrix on a uniform variable.
  8235. * @param uniformName Name of the variable.
  8236. * @param matrix matrix to be set.
  8237. */
  8238. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8239. /**
  8240. * 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)
  8241. * @param uniformName Name of the variable.
  8242. * @param matrix matrix to be set.
  8243. */
  8244. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8245. /**
  8246. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8247. * @param uniformName Name of the variable.
  8248. * @param matrix matrix to be set.
  8249. */
  8250. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8251. /**
  8252. * Sets a float on a uniform variable.
  8253. * @param uniformName Name of the variable.
  8254. * @param value value to be set.
  8255. * @returns this effect.
  8256. */
  8257. setFloat(uniformName: string, value: number): void;
  8258. /**
  8259. * Sets a Vector2 on a uniform variable.
  8260. * @param uniformName Name of the variable.
  8261. * @param vector2 vector2 to be set.
  8262. */
  8263. setVector2(uniformName: string, vector2: IVector2Like): void;
  8264. /**
  8265. * Sets a float2 on a uniform variable.
  8266. * @param uniformName Name of the variable.
  8267. * @param x First float in float2.
  8268. * @param y Second float in float2.
  8269. */
  8270. setFloat2(uniformName: string, x: number, y: number): void;
  8271. /**
  8272. * Sets a Vector3 on a uniform variable.
  8273. * @param uniformName Name of the variable.
  8274. * @param vector3 Value to be set.
  8275. */
  8276. setVector3(uniformName: string, vector3: IVector3Like): void;
  8277. /**
  8278. * Sets a float3 on a uniform variable.
  8279. * @param uniformName Name of the variable.
  8280. * @param x First float in float3.
  8281. * @param y Second float in float3.
  8282. * @param z Third float in float3.
  8283. */
  8284. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8285. /**
  8286. * Sets a Vector4 on a uniform variable.
  8287. * @param uniformName Name of the variable.
  8288. * @param vector4 Value to be set.
  8289. */
  8290. setVector4(uniformName: string, vector4: IVector4Like): void;
  8291. /**
  8292. * Sets a float4 on a uniform variable.
  8293. * @param uniformName Name of the variable.
  8294. * @param x First float in float4.
  8295. * @param y Second float in float4.
  8296. * @param z Third float in float4.
  8297. * @param w Fourth float in float4.
  8298. * @returns this effect.
  8299. */
  8300. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8301. /**
  8302. * Sets a Color3 on a uniform variable.
  8303. * @param uniformName Name of the variable.
  8304. * @param color3 Value to be set.
  8305. */
  8306. setColor3(uniformName: string, color3: IColor3Like): void;
  8307. /**
  8308. * Sets a Color4 on a uniform variable.
  8309. * @param uniformName Name of the variable.
  8310. * @param color3 Value to be set.
  8311. * @param alpha Alpha value to be set.
  8312. */
  8313. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8314. /**
  8315. * Sets a Color4 on a uniform variable
  8316. * @param uniformName defines the name of the variable
  8317. * @param color4 defines the value to be set
  8318. */
  8319. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8320. _getVertexShaderCode(): string | null;
  8321. _getFragmentShaderCode(): string | null;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. interface ThinEngine {
  8326. /**
  8327. * Create an uniform buffer
  8328. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8329. * @param elements defines the content of the uniform buffer
  8330. * @returns the webGL uniform buffer
  8331. */
  8332. createUniformBuffer(elements: FloatArray): DataBuffer;
  8333. /**
  8334. * Create a dynamic uniform buffer
  8335. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8336. * @param elements defines the content of the uniform buffer
  8337. * @returns the webGL uniform buffer
  8338. */
  8339. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8340. /**
  8341. * Update an existing uniform buffer
  8342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8343. * @param uniformBuffer defines the target uniform buffer
  8344. * @param elements defines the content to update
  8345. * @param offset defines the offset in the uniform buffer where update should start
  8346. * @param count defines the size of the data to update
  8347. */
  8348. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8349. /**
  8350. * Bind an uniform buffer to the current webGL context
  8351. * @param buffer defines the buffer to bind
  8352. */
  8353. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8354. /**
  8355. * Bind a buffer to the current webGL context at a given location
  8356. * @param buffer defines the buffer to bind
  8357. * @param location defines the index where to bind the buffer
  8358. * @param name Name of the uniform variable to bind
  8359. */
  8360. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8361. /**
  8362. * Bind a specific block at a given index in a specific shader program
  8363. * @param pipelineContext defines the pipeline context to use
  8364. * @param blockName defines the block name
  8365. * @param index defines the index where to bind the block
  8366. */
  8367. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8368. }
  8369. }
  8370. declare module BABYLON {
  8371. /**
  8372. * Uniform buffer objects.
  8373. *
  8374. * Handles blocks of uniform on the GPU.
  8375. *
  8376. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8377. *
  8378. * For more information, please refer to :
  8379. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8380. */
  8381. export class UniformBuffer {
  8382. /** @hidden */
  8383. static _updatedUbosInFrame: {
  8384. [name: string]: number;
  8385. };
  8386. private _engine;
  8387. private _buffer;
  8388. private _buffers;
  8389. private _bufferIndex;
  8390. private _createBufferOnWrite;
  8391. private _data;
  8392. private _bufferData;
  8393. private _dynamic?;
  8394. private _uniformLocations;
  8395. private _uniformSizes;
  8396. private _uniformArraySizes;
  8397. private _uniformLocationPointer;
  8398. private _needSync;
  8399. private _noUBO;
  8400. private _currentEffect;
  8401. private _currentEffectName;
  8402. private _name;
  8403. private _currentFrameId;
  8404. /** @hidden */
  8405. _alreadyBound: boolean;
  8406. private static _MAX_UNIFORM_SIZE;
  8407. private static _tempBuffer;
  8408. private static _tempBufferInt32View;
  8409. /**
  8410. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8415. /**
  8416. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8421. /**
  8422. * Lambda to Update a single float in a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateFloat: (name: string, x: number) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of float in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of float in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of float in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Lambda to Update an array of 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. updateFloatArray: (name: string, array: Float32Array) => void;
  8451. /**
  8452. * Lambda to Update an array of number in a uniform buffer.
  8453. * This is dynamic to allow compat with webgl 1 and 2.
  8454. * You will need to pass the name of the uniform as well as the value.
  8455. */
  8456. updateArray: (name: string, array: number[]) => void;
  8457. /**
  8458. * Lambda to Update an array of number 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. updateIntArray: (name: string, array: Int32Array) => void;
  8463. /**
  8464. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8465. * This is dynamic to allow compat with webgl 1 and 2.
  8466. * You will need to pass the name of the uniform as well as the value.
  8467. */
  8468. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8469. /**
  8470. * Lambda to Update an array of 4x4 Matrix 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. updateMatrices: (name: string, mat: Float32Array) => void;
  8475. /**
  8476. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8477. * This is dynamic to allow compat with webgl 1 and 2.
  8478. * You will need to pass the name of the uniform as well as the value.
  8479. */
  8480. updateVector3: (name: string, vector: Vector3) => void;
  8481. /**
  8482. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  8487. /**
  8488. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8489. * This is dynamic to allow compat with webgl 1 and 2.
  8490. * You will need to pass the name of the uniform as well as the value.
  8491. */
  8492. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8493. /**
  8494. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8499. /**
  8500. * Lambda to Update a int 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. updateInt: (name: string, x: number, suffix?: string) => void;
  8505. /**
  8506. * Lambda to Update a vec2 of int in a uniform buffer.
  8507. * This is dynamic to allow compat with webgl 1 and 2.
  8508. * You will need to pass the name of the uniform as well as the value.
  8509. */
  8510. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8511. /**
  8512. * Lambda to Update a vec3 of int in a uniform buffer.
  8513. * This is dynamic to allow compat with webgl 1 and 2.
  8514. * You will need to pass the name of the uniform as well as the value.
  8515. */
  8516. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8517. /**
  8518. * Lambda to Update a vec4 of int 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. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8523. /**
  8524. * Instantiates a new Uniform buffer objects.
  8525. *
  8526. * Handles blocks of uniform on the GPU.
  8527. *
  8528. * If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
  8529. *
  8530. * For more information, please refer to :
  8531. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8532. * @param engine Define the engine the buffer is associated with
  8533. * @param data Define the data contained in the buffer
  8534. * @param dynamic Define if the buffer is updatable
  8535. * @param name to assign to the buffer (debugging purpose)
  8536. */
  8537. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8538. /**
  8539. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8540. * or just falling back on setUniformXXX calls.
  8541. */
  8542. get useUbo(): boolean;
  8543. /**
  8544. * Indicates if the WebGL underlying uniform buffer is in sync
  8545. * with the javascript cache data.
  8546. */
  8547. get isSync(): boolean;
  8548. /**
  8549. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8550. * Also, a dynamic UniformBuffer will disable cache verification and always
  8551. * update the underlying WebGL uniform buffer to the GPU.
  8552. * @returns if Dynamic, otherwise false
  8553. */
  8554. isDynamic(): boolean;
  8555. /**
  8556. * The data cache on JS side.
  8557. * @returns the underlying data as a float array
  8558. */
  8559. getData(): Float32Array;
  8560. /**
  8561. * The underlying WebGL Uniform buffer.
  8562. * @returns the webgl buffer
  8563. */
  8564. getBuffer(): Nullable<DataBuffer>;
  8565. /**
  8566. * std140 layout specifies how to align data within an UBO structure.
  8567. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8568. * for specs.
  8569. */
  8570. private _fillAlignment;
  8571. /**
  8572. * Adds an uniform in the buffer.
  8573. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8574. * for the layout to be correct !
  8575. * @param name Name of the uniform, as used in the uniform block in the shader.
  8576. * @param size Data size, or data directly.
  8577. * @param arraySize The number of elements in the array, 0 if not an array.
  8578. */
  8579. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8580. /**
  8581. * Adds a Matrix 4x4 to the uniform buffer.
  8582. * @param name Name of the uniform, as used in the uniform block in the shader.
  8583. * @param mat A 4x4 matrix.
  8584. */
  8585. addMatrix(name: string, mat: Matrix): void;
  8586. /**
  8587. * Adds a vec2 to the uniform buffer.
  8588. * @param name Name of the uniform, as used in the uniform block in the shader.
  8589. * @param x Define the x component value of the vec2
  8590. * @param y Define the y component value of the vec2
  8591. */
  8592. addFloat2(name: string, x: number, y: number): void;
  8593. /**
  8594. * Adds a vec3 to the uniform buffer.
  8595. * @param name Name of the uniform, as used in the uniform block in the shader.
  8596. * @param x Define the x component value of the vec3
  8597. * @param y Define the y component value of the vec3
  8598. * @param z Define the z component value of the vec3
  8599. */
  8600. addFloat3(name: string, x: number, y: number, z: number): void;
  8601. /**
  8602. * Adds a vec3 to the uniform buffer.
  8603. * @param name Name of the uniform, as used in the uniform block in the shader.
  8604. * @param color Define the vec3 from a Color
  8605. */
  8606. addColor3(name: string, color: Color3): void;
  8607. /**
  8608. * Adds a vec4 to the uniform buffer.
  8609. * @param name Name of the uniform, as used in the uniform block in the shader.
  8610. * @param color Define the rgb components from a Color
  8611. * @param alpha Define the a component of the vec4
  8612. */
  8613. addColor4(name: string, color: Color3, alpha: number): void;
  8614. /**
  8615. * Adds a vec3 to the uniform buffer.
  8616. * @param name Name of the uniform, as used in the uniform block in the shader.
  8617. * @param vector Define the vec3 components from a Vector
  8618. */
  8619. addVector3(name: string, vector: Vector3): void;
  8620. /**
  8621. * Adds a Matrix 3x3 to the uniform buffer.
  8622. * @param name Name of the uniform, as used in the uniform block in the shader.
  8623. */
  8624. addMatrix3x3(name: string): void;
  8625. /**
  8626. * Adds a Matrix 2x2 to the uniform buffer.
  8627. * @param name Name of the uniform, as used in the uniform block in the shader.
  8628. */
  8629. addMatrix2x2(name: string): void;
  8630. /**
  8631. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8632. */
  8633. create(): void;
  8634. /** @hidden */
  8635. _rebuild(): void;
  8636. /** @hidden */
  8637. get _numBuffers(): number;
  8638. /** @hidden */
  8639. get _indexBuffer(): number;
  8640. /** Gets the name of this buffer */
  8641. get name(): string;
  8642. /**
  8643. * Updates the WebGL Uniform Buffer on the GPU.
  8644. * If the `dynamic` flag is set to true, no cache comparison is done.
  8645. * Otherwise, the buffer will be updated only if the cache differs.
  8646. */
  8647. update(): void;
  8648. private _createNewBuffer;
  8649. private _checkNewFrame;
  8650. /**
  8651. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8652. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8653. * @param data Define the flattened data
  8654. * @param size Define the size of the data.
  8655. */
  8656. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8657. /**
  8658. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8659. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8660. * @param data Define the flattened data
  8661. * @param size Define the size of the data.
  8662. */
  8663. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8664. private _valueCache;
  8665. private _cacheMatrix;
  8666. private _updateMatrix3x3ForUniform;
  8667. private _updateMatrix3x3ForEffect;
  8668. private _updateMatrix2x2ForEffect;
  8669. private _updateMatrix2x2ForUniform;
  8670. private _updateFloatForEffect;
  8671. private _updateFloatForUniform;
  8672. private _updateFloat2ForEffect;
  8673. private _updateFloat2ForUniform;
  8674. private _updateFloat3ForEffect;
  8675. private _updateFloat3ForUniform;
  8676. private _updateFloat4ForEffect;
  8677. private _updateFloat4ForUniform;
  8678. private _updateFloatArrayForEffect;
  8679. private _updateFloatArrayForUniform;
  8680. private _updateArrayForEffect;
  8681. private _updateArrayForUniform;
  8682. private _updateIntArrayForEffect;
  8683. private _updateIntArrayForUniform;
  8684. private _updateMatrixForEffect;
  8685. private _updateMatrixForUniform;
  8686. private _updateMatricesForEffect;
  8687. private _updateMatricesForUniform;
  8688. private _updateVector3ForEffect;
  8689. private _updateVector3ForUniform;
  8690. private _updateVector4ForEffect;
  8691. private _updateVector4ForUniform;
  8692. private _updateColor3ForEffect;
  8693. private _updateColor3ForUniform;
  8694. private _updateColor4ForEffect;
  8695. private _updateColor4ForUniform;
  8696. private _updateIntForEffect;
  8697. private _updateIntForUniform;
  8698. private _updateInt2ForEffect;
  8699. private _updateInt2ForUniform;
  8700. private _updateInt3ForEffect;
  8701. private _updateInt3ForUniform;
  8702. private _updateInt4ForEffect;
  8703. private _updateInt4ForUniform;
  8704. /**
  8705. * Sets a sampler uniform on the effect.
  8706. * @param name Define the name of the sampler.
  8707. * @param texture Define the texture to set in the sampler
  8708. */
  8709. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8710. /**
  8711. * Directly updates the value of the uniform in the cache AND on the GPU.
  8712. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8713. * @param data Define the flattened data
  8714. */
  8715. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8716. /**
  8717. * Binds this uniform buffer to an effect.
  8718. * @param effect Define the effect to bind the buffer to
  8719. * @param name Name of the uniform block in the shader.
  8720. */
  8721. bindToEffect(effect: Effect, name: string): void;
  8722. /**
  8723. * Disposes the uniform buffer.
  8724. */
  8725. dispose(): void;
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Manages the defines for the Material
  8731. */
  8732. export class MaterialDefines {
  8733. /** @hidden */
  8734. protected _keys: string[];
  8735. private _isDirty;
  8736. /** @hidden */
  8737. _renderId: number;
  8738. /** @hidden */
  8739. _areLightsDirty: boolean;
  8740. /** @hidden */
  8741. _areLightsDisposed: boolean;
  8742. /** @hidden */
  8743. _areAttributesDirty: boolean;
  8744. /** @hidden */
  8745. _areTexturesDirty: boolean;
  8746. /** @hidden */
  8747. _areFresnelDirty: boolean;
  8748. /** @hidden */
  8749. _areMiscDirty: boolean;
  8750. /** @hidden */
  8751. _arePrePassDirty: boolean;
  8752. /** @hidden */
  8753. _areImageProcessingDirty: boolean;
  8754. /** @hidden */
  8755. _normals: boolean;
  8756. /** @hidden */
  8757. _uvs: boolean;
  8758. /** @hidden */
  8759. _needNormals: boolean;
  8760. /** @hidden */
  8761. _needUVs: boolean;
  8762. [id: string]: any;
  8763. /**
  8764. * Specifies if the material needs to be re-calculated
  8765. */
  8766. get isDirty(): boolean;
  8767. /**
  8768. * Marks the material to indicate that it has been re-calculated
  8769. */
  8770. markAsProcessed(): void;
  8771. /**
  8772. * Marks the material to indicate that it needs to be re-calculated
  8773. */
  8774. markAsUnprocessed(): void;
  8775. /**
  8776. * Marks the material to indicate all of its defines need to be re-calculated
  8777. */
  8778. markAllAsDirty(): void;
  8779. /**
  8780. * Marks the material to indicate that image processing needs to be re-calculated
  8781. */
  8782. markAsImageProcessingDirty(): void;
  8783. /**
  8784. * Marks the material to indicate the lights need to be re-calculated
  8785. * @param disposed Defines whether the light is dirty due to dispose or not
  8786. */
  8787. markAsLightDirty(disposed?: boolean): void;
  8788. /**
  8789. * Marks the attribute state as changed
  8790. */
  8791. markAsAttributesDirty(): void;
  8792. /**
  8793. * Marks the texture state as changed
  8794. */
  8795. markAsTexturesDirty(): void;
  8796. /**
  8797. * Marks the fresnel state as changed
  8798. */
  8799. markAsFresnelDirty(): void;
  8800. /**
  8801. * Marks the misc state as changed
  8802. */
  8803. markAsMiscDirty(): void;
  8804. /**
  8805. * Marks the prepass state as changed
  8806. */
  8807. markAsPrePassDirty(): void;
  8808. /**
  8809. * Rebuilds the material defines
  8810. */
  8811. rebuild(): void;
  8812. /**
  8813. * Specifies if two material defines are equal
  8814. * @param other - A material define instance to compare to
  8815. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8816. */
  8817. isEqual(other: MaterialDefines): boolean;
  8818. /**
  8819. * Clones this instance's defines to another instance
  8820. * @param other - material defines to clone values to
  8821. */
  8822. cloneTo(other: MaterialDefines): void;
  8823. /**
  8824. * Resets the material define values
  8825. */
  8826. reset(): void;
  8827. /**
  8828. * Converts the material define values to a string
  8829. * @returns - String of material define information
  8830. */
  8831. toString(): string;
  8832. }
  8833. }
  8834. declare module BABYLON {
  8835. /**
  8836. * Enum that determines the text-wrapping mode to use.
  8837. */
  8838. export enum InspectableType {
  8839. /**
  8840. * Checkbox for booleans
  8841. */
  8842. Checkbox = 0,
  8843. /**
  8844. * Sliders for numbers
  8845. */
  8846. Slider = 1,
  8847. /**
  8848. * Vector3
  8849. */
  8850. Vector3 = 2,
  8851. /**
  8852. * Quaternions
  8853. */
  8854. Quaternion = 3,
  8855. /**
  8856. * Color3
  8857. */
  8858. Color3 = 4,
  8859. /**
  8860. * String
  8861. */
  8862. String = 5
  8863. }
  8864. /**
  8865. * Interface used to define custom inspectable properties.
  8866. * This interface is used by the inspector to display custom property grids
  8867. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8868. */
  8869. export interface IInspectable {
  8870. /**
  8871. * Gets the label to display
  8872. */
  8873. label: string;
  8874. /**
  8875. * Gets the name of the property to edit
  8876. */
  8877. propertyName: string;
  8878. /**
  8879. * Gets the type of the editor to use
  8880. */
  8881. type: InspectableType;
  8882. /**
  8883. * Gets the minimum value of the property when using in "slider" mode
  8884. */
  8885. min?: number;
  8886. /**
  8887. * Gets the maximum value of the property when using in "slider" mode
  8888. */
  8889. max?: number;
  8890. /**
  8891. * Gets the setp to use when using in "slider" mode
  8892. */
  8893. step?: number;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8899. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8900. * 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.
  8901. */
  8902. export abstract class Light extends Node {
  8903. /**
  8904. * Falloff Default: light is falling off following the material specification:
  8905. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8906. */
  8907. static readonly FALLOFF_DEFAULT: number;
  8908. /**
  8909. * Falloff Physical: light is falling off following the inverse squared distance law.
  8910. */
  8911. static readonly FALLOFF_PHYSICAL: number;
  8912. /**
  8913. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8914. * to enhance interoperability with other engines.
  8915. */
  8916. static readonly FALLOFF_GLTF: number;
  8917. /**
  8918. * Falloff Standard: light is falling off like in the standard material
  8919. * to enhance interoperability with other materials.
  8920. */
  8921. static readonly FALLOFF_STANDARD: number;
  8922. /**
  8923. * If every light affecting the material is in this lightmapMode,
  8924. * material.lightmapTexture adds or multiplies
  8925. * (depends on material.useLightmapAsShadowmap)
  8926. * after every other light calculations.
  8927. */
  8928. static readonly LIGHTMAP_DEFAULT: number;
  8929. /**
  8930. * material.lightmapTexture as only diffuse lighting from this light
  8931. * adds only specular lighting from this light
  8932. * adds dynamic shadows
  8933. */
  8934. static readonly LIGHTMAP_SPECULAR: number;
  8935. /**
  8936. * material.lightmapTexture as only lighting
  8937. * no light calculation from this light
  8938. * only adds dynamic shadows from this light
  8939. */
  8940. static readonly LIGHTMAP_SHADOWSONLY: number;
  8941. /**
  8942. * Each light type uses the default quantity according to its type:
  8943. * point/spot lights use luminous intensity
  8944. * directional lights use illuminance
  8945. */
  8946. static readonly INTENSITYMODE_AUTOMATIC: number;
  8947. /**
  8948. * lumen (lm)
  8949. */
  8950. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8951. /**
  8952. * candela (lm/sr)
  8953. */
  8954. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8955. /**
  8956. * lux (lm/m^2)
  8957. */
  8958. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8959. /**
  8960. * nit (cd/m^2)
  8961. */
  8962. static readonly INTENSITYMODE_LUMINANCE: number;
  8963. /**
  8964. * Light type const id of the point light.
  8965. */
  8966. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8967. /**
  8968. * Light type const id of the directional light.
  8969. */
  8970. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8971. /**
  8972. * Light type const id of the spot light.
  8973. */
  8974. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8975. /**
  8976. * Light type const id of the hemispheric light.
  8977. */
  8978. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8979. /**
  8980. * Diffuse gives the basic color to an object.
  8981. */
  8982. diffuse: Color3;
  8983. /**
  8984. * Specular produces a highlight color on an object.
  8985. * Note: This is note affecting PBR materials.
  8986. */
  8987. specular: Color3;
  8988. /**
  8989. * Defines the falloff type for this light. This lets overriding how punctual light are
  8990. * falling off base on range or angle.
  8991. * This can be set to any values in Light.FALLOFF_x.
  8992. *
  8993. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8994. * other types of materials.
  8995. */
  8996. falloffType: number;
  8997. /**
  8998. * Strength of the light.
  8999. * Note: By default it is define in the framework own unit.
  9000. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9001. */
  9002. intensity: number;
  9003. private _range;
  9004. protected _inverseSquaredRange: number;
  9005. /**
  9006. * Defines how far from the source the light is impacting in scene units.
  9007. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9008. */
  9009. get range(): number;
  9010. /**
  9011. * Defines how far from the source the light is impacting in scene units.
  9012. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9013. */
  9014. set range(value: number);
  9015. /**
  9016. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9017. * of light.
  9018. */
  9019. private _photometricScale;
  9020. private _intensityMode;
  9021. /**
  9022. * Gets the photometric scale used to interpret the intensity.
  9023. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9024. */
  9025. get intensityMode(): number;
  9026. /**
  9027. * Sets the photometric scale used to interpret the intensity.
  9028. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9029. */
  9030. set intensityMode(value: number);
  9031. private _radius;
  9032. /**
  9033. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9034. */
  9035. get radius(): number;
  9036. /**
  9037. * sets the light radius used by PBR Materials to simulate soft area lights.
  9038. */
  9039. set radius(value: number);
  9040. private _renderPriority;
  9041. /**
  9042. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9043. * exceeding the number allowed of the materials.
  9044. */
  9045. renderPriority: number;
  9046. private _shadowEnabled;
  9047. /**
  9048. * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9049. * the current shadow generator.
  9050. */
  9051. get shadowEnabled(): boolean;
  9052. /**
  9053. * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9054. * the current shadow generator.
  9055. */
  9056. set shadowEnabled(value: boolean);
  9057. private _includedOnlyMeshes;
  9058. /**
  9059. * Gets the only meshes impacted by this light.
  9060. */
  9061. get includedOnlyMeshes(): AbstractMesh[];
  9062. /**
  9063. * Sets the only meshes impacted by this light.
  9064. */
  9065. set includedOnlyMeshes(value: AbstractMesh[]);
  9066. private _excludedMeshes;
  9067. /**
  9068. * Gets the meshes not impacted by this light.
  9069. */
  9070. get excludedMeshes(): AbstractMesh[];
  9071. /**
  9072. * Sets the meshes not impacted by this light.
  9073. */
  9074. set excludedMeshes(value: AbstractMesh[]);
  9075. private _excludeWithLayerMask;
  9076. /**
  9077. * Gets the layer id use to find what meshes are not impacted by the light.
  9078. * Inactive if 0
  9079. */
  9080. get excludeWithLayerMask(): number;
  9081. /**
  9082. * Sets the layer id use to find what meshes are not impacted by the light.
  9083. * Inactive if 0
  9084. */
  9085. set excludeWithLayerMask(value: number);
  9086. private _includeOnlyWithLayerMask;
  9087. /**
  9088. * Gets the layer id use to find what meshes are impacted by the light.
  9089. * Inactive if 0
  9090. */
  9091. get includeOnlyWithLayerMask(): number;
  9092. /**
  9093. * Sets the layer id use to find what meshes are impacted by the light.
  9094. * Inactive if 0
  9095. */
  9096. set includeOnlyWithLayerMask(value: number);
  9097. private _lightmapMode;
  9098. /**
  9099. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9100. */
  9101. get lightmapMode(): number;
  9102. /**
  9103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9104. */
  9105. set lightmapMode(value: number);
  9106. /**
  9107. * Shadow generator associated to the light.
  9108. * @hidden Internal use only.
  9109. */
  9110. _shadowGenerator: Nullable<IShadowGenerator>;
  9111. /**
  9112. * @hidden Internal use only.
  9113. */
  9114. _excludedMeshesIds: string[];
  9115. /**
  9116. * @hidden Internal use only.
  9117. */
  9118. _includedOnlyMeshesIds: string[];
  9119. /**
  9120. * The current light uniform buffer.
  9121. * @hidden Internal use only.
  9122. */
  9123. _uniformBuffer: UniformBuffer;
  9124. /** @hidden */
  9125. _renderId: number;
  9126. /**
  9127. * Creates a Light object in the scene.
  9128. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9129. * @param name The friendly name of the light
  9130. * @param scene The scene the light belongs too
  9131. */
  9132. constructor(name: string, scene: Scene);
  9133. protected abstract _buildUniformLayout(): void;
  9134. /**
  9135. * Sets the passed Effect "effect" with the Light information.
  9136. * @param effect The effect to update
  9137. * @param lightIndex The index of the light in the effect to update
  9138. * @returns The light
  9139. */
  9140. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9141. /**
  9142. * Sets the passed Effect "effect" with the Light textures.
  9143. * @param effect The effect to update
  9144. * @param lightIndex The index of the light in the effect to update
  9145. * @returns The light
  9146. */
  9147. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9148. /**
  9149. * Binds the lights information from the scene to the effect for the given mesh.
  9150. * @param lightIndex Light index
  9151. * @param scene The scene where the light belongs to
  9152. * @param effect The effect we are binding the data to
  9153. * @param useSpecular Defines if specular is supported
  9154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9155. */
  9156. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9157. /**
  9158. * Sets the passed Effect "effect" with the Light information.
  9159. * @param effect The effect to update
  9160. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9161. * @returns The light
  9162. */
  9163. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9164. /**
  9165. * Returns the string "Light".
  9166. * @returns the class name
  9167. */
  9168. getClassName(): string;
  9169. /** @hidden */
  9170. readonly _isLight: boolean;
  9171. /**
  9172. * Converts the light information to a readable string for debug purpose.
  9173. * @param fullDetails Supports for multiple levels of logging within scene loading
  9174. * @returns the human readable light info
  9175. */
  9176. toString(fullDetails?: boolean): string;
  9177. /** @hidden */
  9178. protected _syncParentEnabledState(): void;
  9179. /**
  9180. * Set the enabled state of this node.
  9181. * @param value - the new enabled state
  9182. */
  9183. setEnabled(value: boolean): void;
  9184. /**
  9185. * Returns the Light associated shadow generator if any.
  9186. * @return the associated shadow generator.
  9187. */
  9188. getShadowGenerator(): Nullable<IShadowGenerator>;
  9189. /**
  9190. * Returns a Vector3, the absolute light position in the World.
  9191. * @returns the world space position of the light
  9192. */
  9193. getAbsolutePosition(): Vector3;
  9194. /**
  9195. * Specifies if the light will affect the passed mesh.
  9196. * @param mesh The mesh to test against the light
  9197. * @return true the mesh is affected otherwise, false.
  9198. */
  9199. canAffectMesh(mesh: AbstractMesh): boolean;
  9200. /**
  9201. * Sort function to order lights for rendering.
  9202. * @param a First Light object to compare to second.
  9203. * @param b Second Light object to compare first.
  9204. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9205. */
  9206. static CompareLightsPriority(a: Light, b: Light): number;
  9207. /**
  9208. * Releases resources associated with this node.
  9209. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9210. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9211. */
  9212. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9213. /**
  9214. * Returns the light type ID (integer).
  9215. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9216. */
  9217. getTypeID(): number;
  9218. /**
  9219. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9220. * @returns the scaled intensity in intensity mode unit
  9221. */
  9222. getScaledIntensity(): number;
  9223. /**
  9224. * Returns a new Light object, named "name", from the current one.
  9225. * @param name The name of the cloned light
  9226. * @param newParent The parent of this light, if it has one
  9227. * @returns the new created light
  9228. */
  9229. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9230. /**
  9231. * Serializes the current light into a Serialization object.
  9232. * @returns the serialized object.
  9233. */
  9234. serialize(): any;
  9235. /**
  9236. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9237. * This new light is named "name" and added to the passed scene.
  9238. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9239. * @param name The friendly name of the light
  9240. * @param scene The scene the new light will belong to
  9241. * @returns the constructor function
  9242. */
  9243. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9244. /**
  9245. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9246. * @param parsedLight The JSON representation of the light
  9247. * @param scene The scene to create the parsed light in
  9248. * @returns the created light after parsing
  9249. */
  9250. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9251. private _hookArrayForExcluded;
  9252. private _hookArrayForIncludedOnly;
  9253. private _resyncMeshes;
  9254. /**
  9255. * Forces the meshes to update their light related information in their rendering used effects
  9256. * @hidden Internal Use Only
  9257. */
  9258. _markMeshesAsLightDirty(): void;
  9259. /**
  9260. * Recomputes the cached photometric scale if needed.
  9261. */
  9262. private _computePhotometricScale;
  9263. /**
  9264. * Returns the Photometric Scale according to the light type and intensity mode.
  9265. */
  9266. private _getPhotometricScale;
  9267. /**
  9268. * Reorder the light in the scene according to their defined priority.
  9269. * @hidden Internal Use Only
  9270. */
  9271. _reorderLightsInScene(): void;
  9272. /**
  9273. * Prepares the list of defines specific to the light type.
  9274. * @param defines the list of defines
  9275. * @param lightIndex defines the index of the light for the effect
  9276. */
  9277. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9278. }
  9279. }
  9280. declare module BABYLON {
  9281. /** Defines supported spaces */
  9282. export enum Space {
  9283. /** Local (object) space */
  9284. LOCAL = 0,
  9285. /** World space */
  9286. WORLD = 1,
  9287. /** Bone space */
  9288. BONE = 2
  9289. }
  9290. /** Defines the 3 main axes */
  9291. export class Axis {
  9292. /** X axis */
  9293. static X: Vector3;
  9294. /** Y axis */
  9295. static Y: Vector3;
  9296. /** Z axis */
  9297. static Z: Vector3;
  9298. }
  9299. /**
  9300. * Defines cartesian components.
  9301. */
  9302. export enum Coordinate {
  9303. /** X axis */
  9304. X = 0,
  9305. /** Y axis */
  9306. Y = 1,
  9307. /** Z axis */
  9308. Z = 2
  9309. }
  9310. }
  9311. declare module BABYLON {
  9312. /**
  9313. * Interface describing all the common properties and methods a shadow light needs to implement.
  9314. * This helps both the shadow generator and materials to generate the corresponding shadow maps
  9315. * as well as binding the different shadow properties to the effects.
  9316. */
  9317. export interface IShadowLight extends Light {
  9318. /**
  9319. * The light id in the scene (used in scene.findLightById for instance)
  9320. */
  9321. id: string;
  9322. /**
  9323. * The position the shadow will be casted from.
  9324. */
  9325. position: Vector3;
  9326. /**
  9327. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9328. */
  9329. direction: Vector3;
  9330. /**
  9331. * The transformed position. Position of the light in world space taking parenting in account.
  9332. */
  9333. transformedPosition: Vector3;
  9334. /**
  9335. * The transformed direction. Direction of the light in world space taking parenting in account.
  9336. */
  9337. transformedDirection: Vector3;
  9338. /**
  9339. * The friendly name of the light in the scene.
  9340. */
  9341. name: string;
  9342. /**
  9343. * Defines the shadow projection clipping minimum z value.
  9344. */
  9345. shadowMinZ: number;
  9346. /**
  9347. * Defines the shadow projection clipping maximum z value.
  9348. */
  9349. shadowMaxZ: number;
  9350. /**
  9351. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9352. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9353. */
  9354. computeTransformedInformation(): boolean;
  9355. /**
  9356. * Gets the scene the light belongs to.
  9357. * @returns The scene
  9358. */
  9359. getScene(): Scene;
  9360. /**
  9361. * Callback defining a custom Projection Matrix Builder.
  9362. * This can be used to override the default projection matrix computation.
  9363. */
  9364. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9365. /**
  9366. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9367. * @param matrix The matrix to updated with the projection information
  9368. * @param viewMatrix The transform matrix of the light
  9369. * @param renderList The list of mesh to render in the map
  9370. * @returns The current light
  9371. */
  9372. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9373. /**
  9374. * Gets the current depth scale used in ESM.
  9375. * @returns The scale
  9376. */
  9377. getDepthScale(): number;
  9378. /**
  9379. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9380. * @returns true if a cube texture needs to be use
  9381. */
  9382. needCube(): boolean;
  9383. /**
  9384. * Detects if the projection matrix requires to be recomputed this frame.
  9385. * @returns true if it requires to be recomputed otherwise, false.
  9386. */
  9387. needProjectionMatrixCompute(): boolean;
  9388. /**
  9389. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9390. */
  9391. forceProjectionMatrixCompute(): void;
  9392. /**
  9393. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9394. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9395. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9396. */
  9397. getShadowDirection(faceIndex?: number): Vector3;
  9398. /**
  9399. * Gets the minZ used for shadow according to both the scene and the light.
  9400. * @param activeCamera The camera we are returning the min for
  9401. * @returns the depth min z
  9402. */
  9403. getDepthMinZ(activeCamera: Camera): number;
  9404. /**
  9405. * Gets the maxZ used for shadow according to both the scene and the light.
  9406. * @param activeCamera The camera we are returning the max for
  9407. * @returns the depth max z
  9408. */
  9409. getDepthMaxZ(activeCamera: Camera): number;
  9410. }
  9411. /**
  9412. * Base implementation IShadowLight
  9413. * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.
  9414. */
  9415. export abstract class ShadowLight extends Light implements IShadowLight {
  9416. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9417. protected _position: Vector3;
  9418. protected _setPosition(value: Vector3): void;
  9419. /**
  9420. * Sets the position the shadow will be casted from. Also use as the light position for both
  9421. * point and spot lights.
  9422. */
  9423. get position(): Vector3;
  9424. /**
  9425. * Sets the position the shadow will be casted from. Also use as the light position for both
  9426. * point and spot lights.
  9427. */
  9428. set position(value: Vector3);
  9429. protected _direction: Vector3;
  9430. protected _setDirection(value: Vector3): void;
  9431. /**
  9432. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9433. * Also use as the light direction on spot and directional lights.
  9434. */
  9435. get direction(): Vector3;
  9436. /**
  9437. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9438. * Also use as the light direction on spot and directional lights.
  9439. */
  9440. set direction(value: Vector3);
  9441. protected _shadowMinZ: number;
  9442. /**
  9443. * Gets the shadow projection clipping minimum z value.
  9444. */
  9445. get shadowMinZ(): number;
  9446. /**
  9447. * Sets the shadow projection clipping minimum z value.
  9448. */
  9449. set shadowMinZ(value: number);
  9450. protected _shadowMaxZ: number;
  9451. /**
  9452. * Sets the shadow projection clipping maximum z value.
  9453. */
  9454. get shadowMaxZ(): number;
  9455. /**
  9456. * Gets the shadow projection clipping maximum z value.
  9457. */
  9458. set shadowMaxZ(value: number);
  9459. /**
  9460. * Callback defining a custom Projection Matrix Builder.
  9461. * This can be used to override the default projection matrix computation.
  9462. */
  9463. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9464. /**
  9465. * The transformed position. Position of the light in world space taking parenting in account.
  9466. */
  9467. transformedPosition: Vector3;
  9468. /**
  9469. * The transformed direction. Direction of the light in world space taking parenting in account.
  9470. */
  9471. transformedDirection: Vector3;
  9472. private _needProjectionMatrixCompute;
  9473. /**
  9474. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9475. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9476. */
  9477. computeTransformedInformation(): boolean;
  9478. /**
  9479. * Return the depth scale used for the shadow map.
  9480. * @returns the depth scale.
  9481. */
  9482. getDepthScale(): number;
  9483. /**
  9484. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9485. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9486. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9487. */
  9488. getShadowDirection(faceIndex?: number): Vector3;
  9489. /**
  9490. * Returns the ShadowLight absolute position in the World.
  9491. * @returns the position vector in world space
  9492. */
  9493. getAbsolutePosition(): Vector3;
  9494. /**
  9495. * Sets the ShadowLight direction toward the passed target.
  9496. * @param target The point to target in local space
  9497. * @returns the updated ShadowLight direction
  9498. */
  9499. setDirectionToTarget(target: Vector3): Vector3;
  9500. /**
  9501. * Returns the light rotation in euler definition.
  9502. * @returns the x y z rotation in local space.
  9503. */
  9504. getRotation(): Vector3;
  9505. /**
  9506. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9507. * @returns true if a cube texture needs to be use
  9508. */
  9509. needCube(): boolean;
  9510. /**
  9511. * Detects if the projection matrix requires to be recomputed this frame.
  9512. * @returns true if it requires to be recomputed otherwise, false.
  9513. */
  9514. needProjectionMatrixCompute(): boolean;
  9515. /**
  9516. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9517. */
  9518. forceProjectionMatrixCompute(): void;
  9519. /** @hidden */
  9520. _initCache(): void;
  9521. /** @hidden */
  9522. _isSynchronized(): boolean;
  9523. /**
  9524. * Computes the world matrix of the node
  9525. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9526. * @returns the world matrix
  9527. */
  9528. computeWorldMatrix(force?: boolean): Matrix;
  9529. /**
  9530. * Gets the minZ used for shadow according to both the scene and the light.
  9531. * @param activeCamera The camera we are returning the min for
  9532. * @returns the depth min z
  9533. */
  9534. getDepthMinZ(activeCamera: Camera): number;
  9535. /**
  9536. * Gets the maxZ used for shadow according to both the scene and the light.
  9537. * @param activeCamera The camera we are returning the max for
  9538. * @returns the depth max z
  9539. */
  9540. getDepthMaxZ(activeCamera: Camera): number;
  9541. /**
  9542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9543. * @param matrix The matrix to updated with the projection information
  9544. * @param viewMatrix The transform matrix of the light
  9545. * @param renderList The list of mesh to render in the map
  9546. * @returns The current light
  9547. */
  9548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9549. }
  9550. }
  9551. declare module BABYLON {
  9552. /**
  9553. * Configuration needed for prepass-capable materials
  9554. */
  9555. export class PrePassConfiguration {
  9556. /**
  9557. * Previous world matrices of meshes carrying this material
  9558. * Used for computing velocity
  9559. */
  9560. previousWorldMatrices: {
  9561. [index: number]: Matrix;
  9562. };
  9563. /**
  9564. * Previous view project matrix
  9565. * Used for computing velocity
  9566. */
  9567. previousViewProjection: Matrix;
  9568. /**
  9569. * Previous bones of meshes carrying this material
  9570. * Used for computing velocity
  9571. */
  9572. previousBones: {
  9573. [index: number]: Float32Array;
  9574. };
  9575. /**
  9576. * Add the required uniforms to the current list.
  9577. * @param uniforms defines the current uniform list.
  9578. */
  9579. static AddUniforms(uniforms: string[]): void;
  9580. /**
  9581. * Add the required samplers to the current list.
  9582. * @param samplers defines the current sampler list.
  9583. */
  9584. static AddSamplers(samplers: string[]): void;
  9585. /**
  9586. * Binds the material data.
  9587. * @param effect defines the effect to update
  9588. * @param scene defines the scene the material belongs to.
  9589. * @param mesh The mesh
  9590. * @param world World matrix of this mesh
  9591. * @param isFrozen Is the material frozen
  9592. */
  9593. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9599. * This is the base of the follow, arc rotate cameras and Free camera
  9600. * @see https://doc.babylonjs.com/features/cameras
  9601. */
  9602. export class TargetCamera extends Camera {
  9603. private static _RigCamTransformMatrix;
  9604. private static _TargetTransformMatrix;
  9605. private static _TargetFocalPoint;
  9606. private _tmpUpVector;
  9607. private _tmpTargetVector;
  9608. /**
  9609. * Define the current direction the camera is moving to
  9610. */
  9611. cameraDirection: Vector3;
  9612. /**
  9613. * Define the current rotation the camera is rotating to
  9614. */
  9615. cameraRotation: Vector2;
  9616. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9617. ignoreParentScaling: boolean;
  9618. /**
  9619. * When set, the up vector of the camera will be updated by the rotation of the camera
  9620. */
  9621. updateUpVectorFromRotation: boolean;
  9622. private _tmpQuaternion;
  9623. /**
  9624. * Define the current rotation of the camera
  9625. */
  9626. rotation: Vector3;
  9627. /**
  9628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9629. */
  9630. rotationQuaternion: Quaternion;
  9631. /**
  9632. * Define the current speed of the camera
  9633. */
  9634. speed: number;
  9635. /**
  9636. * Add constraint to the camera to prevent it to move freely in all directions and
  9637. * around all axis.
  9638. */
  9639. noRotationConstraint: boolean;
  9640. /**
  9641. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9642. * panning
  9643. */
  9644. invertRotation: boolean;
  9645. /**
  9646. * Speed multiplier for inverse camera panning
  9647. */
  9648. inverseRotationSpeed: number;
  9649. /**
  9650. * Define the current target of the camera as an object or a position.
  9651. */
  9652. lockedTarget: any;
  9653. /** @hidden */
  9654. _currentTarget: Vector3;
  9655. /** @hidden */
  9656. _initialFocalDistance: number;
  9657. /** @hidden */
  9658. _viewMatrix: Matrix;
  9659. /** @hidden */
  9660. _camMatrix: Matrix;
  9661. /** @hidden */
  9662. _cameraTransformMatrix: Matrix;
  9663. /** @hidden */
  9664. _cameraRotationMatrix: Matrix;
  9665. /** @hidden */
  9666. _referencePoint: Vector3;
  9667. /** @hidden */
  9668. _transformedReferencePoint: Vector3;
  9669. /** @hidden */
  9670. _reset: () => void;
  9671. private _defaultUp;
  9672. /**
  9673. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9674. * This is the base of the follow, arc rotate cameras and Free camera
  9675. * @see https://doc.babylonjs.com/features/cameras
  9676. * @param name Defines the name of the camera in the scene
  9677. * @param position Defines the start position of the camera in the scene
  9678. * @param scene Defines the scene the camera belongs to
  9679. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  9680. */
  9681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9682. /**
  9683. * Gets the position in front of the camera at a given distance.
  9684. * @param distance The distance from the camera we want the position to be
  9685. * @returns the position
  9686. */
  9687. getFrontPosition(distance: number): Vector3;
  9688. /** @hidden */
  9689. _getLockedTargetPosition(): Nullable<Vector3>;
  9690. private _storedPosition;
  9691. private _storedRotation;
  9692. private _storedRotationQuaternion;
  9693. /**
  9694. * Store current camera state of the camera (fov, position, rotation, etc..)
  9695. * @returns the camera
  9696. */
  9697. storeState(): Camera;
  9698. /**
  9699. * Restored camera state. You must call storeState() first
  9700. * @returns whether it was successful or not
  9701. * @hidden
  9702. */
  9703. _restoreStateValues(): boolean;
  9704. /** @hidden */
  9705. _initCache(): void;
  9706. /** @hidden */
  9707. _updateCache(ignoreParentClass?: boolean): void;
  9708. /** @hidden */
  9709. _isSynchronizedViewMatrix(): boolean;
  9710. /** @hidden */
  9711. _computeLocalCameraSpeed(): number;
  9712. /**
  9713. * Defines the target the camera should look at.
  9714. * @param target Defines the new target as a Vector or a mesh
  9715. */
  9716. setTarget(target: Vector3): void;
  9717. /**
  9718. * Defines the target point of the camera.
  9719. * The camera looks towards it form the radius distance.
  9720. */
  9721. get target(): Vector3;
  9722. set target(value: Vector3);
  9723. /**
  9724. * Return the current target position of the camera. This value is expressed in local space.
  9725. * @returns the target position
  9726. */
  9727. getTarget(): Vector3;
  9728. /** @hidden */
  9729. _decideIfNeedsToMove(): boolean;
  9730. /** @hidden */
  9731. _updatePosition(): void;
  9732. /** @hidden */
  9733. _checkInputs(): void;
  9734. protected _updateCameraRotationMatrix(): void;
  9735. /**
  9736. * 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)
  9737. * @returns the current camera
  9738. */
  9739. private _rotateUpVectorWithCameraRotationMatrix;
  9740. private _cachedRotationZ;
  9741. private _cachedQuaternionRotationZ;
  9742. /** @hidden */
  9743. _getViewMatrix(): Matrix;
  9744. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9745. /**
  9746. * @hidden
  9747. */
  9748. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9749. /**
  9750. * @hidden
  9751. */
  9752. _updateRigCameras(): void;
  9753. private _getRigCamPositionAndTarget;
  9754. /**
  9755. * Gets the current object class name.
  9756. * @return the class name
  9757. */
  9758. getClassName(): string;
  9759. }
  9760. }
  9761. declare module BABYLON {
  9762. /**
  9763. * @ignore
  9764. * This is a list of all the different input types that are available in the application.
  9765. * Fo instance: ArcRotateCameraGamepadInput...
  9766. */
  9767. export var CameraInputTypes: {};
  9768. /**
  9769. * This is the contract to implement in order to create a new input class.
  9770. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9771. */
  9772. export interface ICameraInput<TCamera extends Camera> {
  9773. /**
  9774. * Defines the camera the input is attached to.
  9775. */
  9776. camera: Nullable<TCamera>;
  9777. /**
  9778. * Gets the class name of the current input.
  9779. * @returns the class name
  9780. */
  9781. getClassName(): string;
  9782. /**
  9783. * Get the friendly name associated with the input class.
  9784. * @returns the input friendly name
  9785. */
  9786. getSimpleName(): string;
  9787. /**
  9788. * Attach the input controls to a specific dom element to get the input from.
  9789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9790. */
  9791. attachControl(noPreventDefault?: boolean): void;
  9792. /**
  9793. * Detach the current controls from the specified dom element.
  9794. */
  9795. detachControl(): void;
  9796. /**
  9797. * Update the current camera state depending on the inputs that have been used this frame.
  9798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9799. */
  9800. checkInputs?: () => void;
  9801. }
  9802. /**
  9803. * Represents a map of input types to input instance or input index to input instance.
  9804. */
  9805. export interface CameraInputsMap<TCamera extends Camera> {
  9806. /**
  9807. * Accessor to the input by input type.
  9808. */
  9809. [name: string]: ICameraInput<TCamera>;
  9810. /**
  9811. * Accessor to the input by input index.
  9812. */
  9813. [idx: number]: ICameraInput<TCamera>;
  9814. }
  9815. /**
  9816. * This represents the input manager used within a camera.
  9817. * It helps dealing with all the different kind of input attached to a camera.
  9818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9819. */
  9820. export class CameraInputsManager<TCamera extends Camera> {
  9821. /**
  9822. * Defines the list of inputs attached to the camera.
  9823. */
  9824. attached: CameraInputsMap<TCamera>;
  9825. /**
  9826. * Defines the dom element the camera is collecting inputs from.
  9827. * This is null if the controls have not been attached.
  9828. */
  9829. attachedToElement: boolean;
  9830. /**
  9831. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9832. */
  9833. noPreventDefault: boolean;
  9834. /**
  9835. * Defined the camera the input manager belongs to.
  9836. */
  9837. camera: TCamera;
  9838. /**
  9839. * Update the current camera state depending on the inputs that have been used this frame.
  9840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9841. */
  9842. checkInputs: () => void;
  9843. /**
  9844. * Instantiate a new Camera Input Manager.
  9845. * @param camera Defines the camera the input manager belongs to
  9846. */
  9847. constructor(camera: TCamera);
  9848. /**
  9849. * Add an input method to a camera
  9850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9851. * @param input camera input method
  9852. */
  9853. add(input: ICameraInput<TCamera>): void;
  9854. /**
  9855. * Remove a specific input method from a camera
  9856. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9857. * @param inputToRemove camera input method
  9858. */
  9859. remove(inputToRemove: ICameraInput<TCamera>): void;
  9860. /**
  9861. * Remove a specific input type from a camera
  9862. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9863. * @param inputType the type of the input to remove
  9864. */
  9865. removeByType(inputType: string): void;
  9866. private _addCheckInputs;
  9867. /**
  9868. * Attach the input controls to the currently attached dom element to listen the events from.
  9869. * @param input Defines the input to attach
  9870. */
  9871. attachInput(input: ICameraInput<TCamera>): void;
  9872. /**
  9873. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9874. * @param element Defines the dom element to collect the events from
  9875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9876. */
  9877. attachElement(noPreventDefault?: boolean): void;
  9878. /**
  9879. * Detach the current manager inputs controls from a specific dom element.
  9880. * @param element Defines the dom element to collect the events from
  9881. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9882. */
  9883. detachElement(disconnect?: boolean): void;
  9884. /**
  9885. * Rebuild the dynamic inputCheck function from the current list of
  9886. * defined inputs in the manager.
  9887. */
  9888. rebuildInputCheck(): void;
  9889. /**
  9890. * Remove all attached input methods from a camera
  9891. */
  9892. clear(): void;
  9893. /**
  9894. * Serialize the current input manager attached to a camera.
  9895. * This ensures than once parsed,
  9896. * the input associated to the camera will be identical to the current ones
  9897. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9898. */
  9899. serialize(serializedCamera: any): void;
  9900. /**
  9901. * Parses an input manager serialized JSON to restore the previous list of inputs
  9902. * and states associated to a camera.
  9903. * @param parsedCamera Defines the JSON to parse
  9904. */
  9905. parse(parsedCamera: any): void;
  9906. }
  9907. }
  9908. declare module BABYLON {
  9909. /**
  9910. * Gather the list of keyboard event types as constants.
  9911. */
  9912. export class KeyboardEventTypes {
  9913. /**
  9914. * The keydown event is fired when a key becomes active (pressed).
  9915. */
  9916. static readonly KEYDOWN: number;
  9917. /**
  9918. * The keyup event is fired when a key has been released.
  9919. */
  9920. static readonly KEYUP: number;
  9921. }
  9922. /**
  9923. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9924. */
  9925. export class KeyboardInfo {
  9926. /**
  9927. * Defines the type of event (KeyboardEventTypes)
  9928. */
  9929. type: number;
  9930. /**
  9931. * Defines the related dom event
  9932. */
  9933. event: KeyboardEvent;
  9934. /**
  9935. * Instantiates a new keyboard info.
  9936. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9937. * @param type Defines the type of event (KeyboardEventTypes)
  9938. * @param event Defines the related dom event
  9939. */
  9940. constructor(
  9941. /**
  9942. * Defines the type of event (KeyboardEventTypes)
  9943. */
  9944. type: number,
  9945. /**
  9946. * Defines the related dom event
  9947. */
  9948. event: KeyboardEvent);
  9949. }
  9950. /**
  9951. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9952. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9953. */
  9954. export class KeyboardInfoPre extends KeyboardInfo {
  9955. /**
  9956. * Defines the type of event (KeyboardEventTypes)
  9957. */
  9958. type: number;
  9959. /**
  9960. * Defines the related dom event
  9961. */
  9962. event: KeyboardEvent;
  9963. /**
  9964. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9965. */
  9966. skipOnPointerObservable: boolean;
  9967. /**
  9968. * Instantiates a new keyboard pre info.
  9969. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9970. * @param type Defines the type of event (KeyboardEventTypes)
  9971. * @param event Defines the related dom event
  9972. */
  9973. constructor(
  9974. /**
  9975. * Defines the type of event (KeyboardEventTypes)
  9976. */
  9977. type: number,
  9978. /**
  9979. * Defines the related dom event
  9980. */
  9981. event: KeyboardEvent);
  9982. }
  9983. }
  9984. declare module BABYLON {
  9985. /**
  9986. * Manage the keyboard inputs to control the movement of a free camera.
  9987. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9988. */
  9989. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9990. /**
  9991. * Defines the camera the input is attached to.
  9992. */
  9993. camera: FreeCamera;
  9994. /**
  9995. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9996. */
  9997. keysUp: number[];
  9998. /**
  9999. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  10000. */
  10001. keysUpward: number[];
  10002. /**
  10003. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  10004. */
  10005. keysDown: number[];
  10006. /**
  10007. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  10008. */
  10009. keysDownward: number[];
  10010. /**
  10011. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  10012. */
  10013. keysLeft: number[];
  10014. /**
  10015. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  10016. */
  10017. keysRight: number[];
  10018. private _keys;
  10019. private _onCanvasBlurObserver;
  10020. private _onKeyboardObserver;
  10021. private _engine;
  10022. private _scene;
  10023. /**
  10024. * Attach the input controls to a specific dom element to get the input from.
  10025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  10026. */
  10027. attachControl(noPreventDefault?: boolean): void;
  10028. /**
  10029. * Detach the current controls from the specified dom element.
  10030. */
  10031. detachControl(): void;
  10032. /**
  10033. * Update the current camera state depending on the inputs that have been used this frame.
  10034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  10035. */
  10036. checkInputs(): void;
  10037. /**
  10038. * Gets the class name of the current input.
  10039. * @returns the class name
  10040. */
  10041. getClassName(): string;
  10042. /** @hidden */
  10043. _onLostFocus(): void;
  10044. /**
  10045. * Get the friendly name associated with the input class.
  10046. * @returns the input friendly name
  10047. */
  10048. getSimpleName(): string;
  10049. }
  10050. }
  10051. declare module BABYLON {
  10052. /**
  10053. * Interface used to define Action
  10054. */
  10055. export interface IAction {
  10056. /**
  10057. * Trigger for the action
  10058. */
  10059. trigger: number;
  10060. /** Options of the trigger */
  10061. triggerOptions: any;
  10062. /**
  10063. * Gets the trigger parameters
  10064. * @returns the trigger parameters
  10065. */
  10066. getTriggerParameter(): any;
  10067. /**
  10068. * Internal only - executes current action event
  10069. * @hidden
  10070. */
  10071. _executeCurrent(evt?: ActionEvent): void;
  10072. /**
  10073. * Serialize placeholder for child classes
  10074. * @param parent of child
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. /**
  10079. * Internal only
  10080. * @hidden
  10081. */
  10082. _prepare(): void;
  10083. /**
  10084. * Internal only - manager for action
  10085. * @hidden
  10086. */
  10087. _actionManager: Nullable<AbstractActionManager>;
  10088. /**
  10089. * Adds action to chain of actions, may be a DoNothingAction
  10090. * @param action defines the next action to execute
  10091. * @returns The action passed in
  10092. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10093. */
  10094. then(action: IAction): IAction;
  10095. }
  10096. /**
  10097. * The action to be carried out following a trigger
  10098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10099. */
  10100. export class Action implements IAction {
  10101. /** the trigger, with or without parameters, for the action */
  10102. triggerOptions: any;
  10103. /**
  10104. * Trigger for the action
  10105. */
  10106. trigger: number;
  10107. /**
  10108. * Internal only - manager for action
  10109. * @hidden
  10110. */
  10111. _actionManager: ActionManager;
  10112. private _nextActiveAction;
  10113. private _child;
  10114. private _condition?;
  10115. private _triggerParameter;
  10116. /**
  10117. * An event triggered prior to action being executed.
  10118. */
  10119. onBeforeExecuteObservable: Observable<Action>;
  10120. /**
  10121. * Creates a new Action
  10122. * @param triggerOptions the trigger, with or without parameters, for the action
  10123. * @param condition an optional determinant of action
  10124. */
  10125. constructor(
  10126. /** the trigger, with or without parameters, for the action */
  10127. triggerOptions: any, condition?: Condition);
  10128. /**
  10129. * Internal only
  10130. * @hidden
  10131. */
  10132. _prepare(): void;
  10133. /**
  10134. * Gets the trigger parameter
  10135. * @returns the trigger parameter
  10136. */
  10137. getTriggerParameter(): any;
  10138. /**
  10139. * Sets the trigger parameter
  10140. * @param value defines the new trigger parameter
  10141. */
  10142. setTriggerParameter(value: any): void;
  10143. /**
  10144. * Internal only - executes current action event
  10145. * @hidden
  10146. */
  10147. _executeCurrent(evt?: ActionEvent): void;
  10148. /**
  10149. * Execute placeholder for child classes
  10150. * @param evt optional action event
  10151. */
  10152. execute(evt?: ActionEvent): void;
  10153. /**
  10154. * Skips to next active action
  10155. */
  10156. skipToNextActiveAction(): void;
  10157. /**
  10158. * Adds action to chain of actions, may be a DoNothingAction
  10159. * @param action defines the next action to execute
  10160. * @returns The action passed in
  10161. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10162. */
  10163. then(action: Action): Action;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _getProperty(propertyPath: string): string;
  10169. /**
  10170. * Internal only
  10171. * @hidden
  10172. */
  10173. _getEffectiveTarget(target: any, propertyPath: string): any;
  10174. /**
  10175. * Serialize placeholder for child classes
  10176. * @param parent of child
  10177. * @returns the serialized object
  10178. */
  10179. serialize(parent: any): any;
  10180. /**
  10181. * Internal only called by serialize
  10182. * @hidden
  10183. */
  10184. protected _serialize(serializedAction: any, parent?: any): any;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. static _SerializeValueAsString: (value: any) => string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. static _GetTargetProperty: (target: Scene | Node) => {
  10195. name: string;
  10196. targetType: string;
  10197. value: string;
  10198. };
  10199. }
  10200. }
  10201. declare module BABYLON {
  10202. /**
  10203. * A Condition applied to an Action
  10204. */
  10205. export class Condition {
  10206. /**
  10207. * Internal only - manager for action
  10208. * @hidden
  10209. */
  10210. _actionManager: ActionManager;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. _evaluationId: number;
  10216. /**
  10217. * Internal only
  10218. * @hidden
  10219. */
  10220. _currentResult: boolean;
  10221. /**
  10222. * Creates a new Condition
  10223. * @param actionManager the manager of the action the condition is applied to
  10224. */
  10225. constructor(actionManager: ActionManager);
  10226. /**
  10227. * Check if the current condition is valid
  10228. * @returns a boolean
  10229. */
  10230. isValid(): boolean;
  10231. /**
  10232. * Internal only
  10233. * @hidden
  10234. */
  10235. _getProperty(propertyPath: string): string;
  10236. /**
  10237. * Internal only
  10238. * @hidden
  10239. */
  10240. _getEffectiveTarget(target: any, propertyPath: string): any;
  10241. /**
  10242. * Serialize placeholder for child classes
  10243. * @returns the serialized object
  10244. */
  10245. serialize(): any;
  10246. /**
  10247. * Internal only
  10248. * @hidden
  10249. */
  10250. protected _serialize(serializedCondition: any): any;
  10251. }
  10252. /**
  10253. * Defines specific conditional operators as extensions of Condition
  10254. */
  10255. export class ValueCondition extends Condition {
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string;
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any;
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator: number;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */
  10266. private static _IsEqual;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. private static _IsDifferent;
  10272. /**
  10273. * Internal only
  10274. * @hidden
  10275. */
  10276. private static _IsGreater;
  10277. /**
  10278. * Internal only
  10279. * @hidden
  10280. */
  10281. private static _IsLesser;
  10282. /**
  10283. * returns the number for IsEqual
  10284. */
  10285. static get IsEqual(): number;
  10286. /**
  10287. * Returns the number for IsDifferent
  10288. */
  10289. static get IsDifferent(): number;
  10290. /**
  10291. * Returns the number for IsGreater
  10292. */
  10293. static get IsGreater(): number;
  10294. /**
  10295. * Returns the number for IsLesser
  10296. */
  10297. static get IsLesser(): number;
  10298. /**
  10299. * Internal only The action manager for the condition
  10300. * @hidden
  10301. */
  10302. _actionManager: ActionManager;
  10303. /**
  10304. * Internal only
  10305. * @hidden
  10306. */
  10307. private _target;
  10308. /**
  10309. * Internal only
  10310. * @hidden
  10311. */
  10312. private _effectiveTarget;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. private _property;
  10318. /**
  10319. * Creates a new ValueCondition
  10320. * @param actionManager manager for the action the condition applies to
  10321. * @param target for the action
  10322. * @param propertyPath path to specify the property of the target the conditional operator uses
  10323. * @param value the value compared by the conditional operator against the current value of the property
  10324. * @param operator the conditional operator, default ValueCondition.IsEqual
  10325. */
  10326. constructor(actionManager: ActionManager, target: any,
  10327. /** path to specify the property of the target the conditional operator uses */
  10328. propertyPath: string,
  10329. /** the value compared by the conditional operator against the current value of the property */
  10330. value: any,
  10331. /** the conditional operator, default ValueCondition.IsEqual */
  10332. operator?: number);
  10333. /**
  10334. * Compares the given value with the property value for the specified conditional operator
  10335. * @returns the result of the comparison
  10336. */
  10337. isValid(): boolean;
  10338. /**
  10339. * Serialize the ValueCondition into a JSON compatible object
  10340. * @returns serialization object
  10341. */
  10342. serialize(): any;
  10343. /**
  10344. * Gets the name of the conditional operator for the ValueCondition
  10345. * @param operator the conditional operator
  10346. * @returns the name
  10347. */
  10348. static GetOperatorName(operator: number): string;
  10349. }
  10350. /**
  10351. * Defines a predicate condition as an extension of Condition
  10352. */
  10353. export class PredicateCondition extends Condition {
  10354. /** defines the predicate function used to validate the condition */
  10355. predicate: () => boolean;
  10356. /**
  10357. * Internal only - manager for action
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Creates a new PredicateCondition
  10363. * @param actionManager manager for the action the condition applies to
  10364. * @param predicate defines the predicate function used to validate the condition
  10365. */
  10366. constructor(actionManager: ActionManager,
  10367. /** defines the predicate function used to validate the condition */
  10368. predicate: () => boolean);
  10369. /**
  10370. * @returns the validity of the predicate condition
  10371. */
  10372. isValid(): boolean;
  10373. }
  10374. /**
  10375. * Defines a state condition as an extension of Condition
  10376. */
  10377. export class StateCondition extends Condition {
  10378. /** Value to compare with target state */
  10379. value: string;
  10380. /**
  10381. * Internal only - manager for action
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Creates a new StateCondition
  10392. * @param actionManager manager for the action the condition applies to
  10393. * @param target of the condition
  10394. * @param value to compare with target state
  10395. */
  10396. constructor(actionManager: ActionManager, target: any,
  10397. /** Value to compare with target state */
  10398. value: string);
  10399. /**
  10400. * Gets a boolean indicating if the current condition is met
  10401. * @returns the validity of the state
  10402. */
  10403. isValid(): boolean;
  10404. /**
  10405. * Serialize the StateCondition into a JSON compatible object
  10406. * @returns serialization object
  10407. */
  10408. serialize(): any;
  10409. }
  10410. }
  10411. declare module BABYLON {
  10412. /**
  10413. * This defines an action responsible to toggle a boolean once triggered.
  10414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10415. */
  10416. export class SwitchBooleanAction extends Action {
  10417. /**
  10418. * The path to the boolean property in the target object
  10419. */
  10420. propertyPath: string;
  10421. private _target;
  10422. private _effectiveTarget;
  10423. private _property;
  10424. /**
  10425. * Instantiate the action
  10426. * @param triggerOptions defines the trigger options
  10427. * @param target defines the object containing the boolean
  10428. * @param propertyPath defines the path to the boolean property in the target object
  10429. * @param condition defines the trigger related conditions
  10430. */
  10431. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10432. /** @hidden */
  10433. _prepare(): void;
  10434. /**
  10435. * Execute the action toggle the boolean value.
  10436. */
  10437. execute(): void;
  10438. /**
  10439. * Serializes the actions and its related information.
  10440. * @param parent defines the object to serialize in
  10441. * @returns the serialized object
  10442. */
  10443. serialize(parent: any): any;
  10444. }
  10445. /**
  10446. * This defines an action responsible to set a the state field of the target
  10447. * to a desired value once triggered.
  10448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10449. */
  10450. export class SetStateAction extends Action {
  10451. /**
  10452. * The value to store in the state field.
  10453. */
  10454. value: string;
  10455. private _target;
  10456. /**
  10457. * Instantiate the action
  10458. * @param triggerOptions defines the trigger options
  10459. * @param target defines the object containing the state property
  10460. * @param value defines the value to store in the state field
  10461. * @param condition defines the trigger related conditions
  10462. */
  10463. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10464. /**
  10465. * Execute the action and store the value on the target state property.
  10466. */
  10467. execute(): void;
  10468. /**
  10469. * Serializes the actions and its related information.
  10470. * @param parent defines the object to serialize in
  10471. * @returns the serialized object
  10472. */
  10473. serialize(parent: any): any;
  10474. }
  10475. /**
  10476. * This defines an action responsible to set a property of the target
  10477. * to a desired value once triggered.
  10478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10479. */
  10480. export class SetValueAction extends Action {
  10481. /**
  10482. * The path of the property to set in the target.
  10483. */
  10484. propertyPath: string;
  10485. /**
  10486. * The value to set in the property
  10487. */
  10488. value: any;
  10489. private _target;
  10490. private _effectiveTarget;
  10491. private _property;
  10492. /**
  10493. * Instantiate the action
  10494. * @param triggerOptions defines the trigger options
  10495. * @param target defines the object containing the property
  10496. * @param propertyPath defines the path of the property to set in the target
  10497. * @param value defines the value to set in the property
  10498. * @param condition defines the trigger related conditions
  10499. */
  10500. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10501. /** @hidden */
  10502. _prepare(): void;
  10503. /**
  10504. * Execute the action and set the targeted property to the desired value.
  10505. */
  10506. execute(): void;
  10507. /**
  10508. * Serializes the actions and its related information.
  10509. * @param parent defines the object to serialize in
  10510. * @returns the serialized object
  10511. */
  10512. serialize(parent: any): any;
  10513. }
  10514. /**
  10515. * This defines an action responsible to increment the target value
  10516. * to a desired value once triggered.
  10517. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10518. */
  10519. export class IncrementValueAction extends Action {
  10520. /**
  10521. * The path of the property to increment in the target.
  10522. */
  10523. propertyPath: string;
  10524. /**
  10525. * The value we should increment the property by.
  10526. */
  10527. value: any;
  10528. private _target;
  10529. private _effectiveTarget;
  10530. private _property;
  10531. /**
  10532. * Instantiate the action
  10533. * @param triggerOptions defines the trigger options
  10534. * @param target defines the object containing the property
  10535. * @param propertyPath defines the path of the property to increment in the target
  10536. * @param value defines the value value we should increment the property by
  10537. * @param condition defines the trigger related conditions
  10538. */
  10539. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10540. /** @hidden */
  10541. _prepare(): void;
  10542. /**
  10543. * Execute the action and increment the target of the value amount.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to start an animation once triggered.
  10555. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10556. */
  10557. export class PlayAnimationAction extends Action {
  10558. /**
  10559. * Where the animation should start (animation frame)
  10560. */
  10561. from: number;
  10562. /**
  10563. * Where the animation should stop (animation frame)
  10564. */
  10565. to: number;
  10566. /**
  10567. * Define if the animation should loop or stop after the first play.
  10568. */
  10569. loop?: boolean;
  10570. private _target;
  10571. /**
  10572. * Instantiate the action
  10573. * @param triggerOptions defines the trigger options
  10574. * @param target defines the target animation or animation name
  10575. * @param from defines from where the animation should start (animation frame)
  10576. * @param to defines where the animation should stop (animation frame)
  10577. * @param loop defines if the animation should loop or stop after the first play
  10578. * @param condition defines the trigger related conditions
  10579. */
  10580. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10581. /** @hidden */
  10582. _prepare(): void;
  10583. /**
  10584. * Execute the action and play the animation.
  10585. */
  10586. execute(): void;
  10587. /**
  10588. * Serializes the actions and its related information.
  10589. * @param parent defines the object to serialize in
  10590. * @returns the serialized object
  10591. */
  10592. serialize(parent: any): any;
  10593. }
  10594. /**
  10595. * This defines an action responsible to stop an animation once triggered.
  10596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class StopAnimationAction extends Action {
  10599. private _target;
  10600. /**
  10601. * Instantiate the action
  10602. * @param triggerOptions defines the trigger options
  10603. * @param target defines the target animation or animation name
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions: any, target: any, condition?: Condition);
  10607. /** @hidden */
  10608. _prepare(): void;
  10609. /**
  10610. * Execute the action and stop the animation.
  10611. */
  10612. execute(): void;
  10613. /**
  10614. * Serializes the actions and its related information.
  10615. * @param parent defines the object to serialize in
  10616. * @returns the serialized object
  10617. */
  10618. serialize(parent: any): any;
  10619. }
  10620. /**
  10621. * This defines an action responsible that does nothing once triggered.
  10622. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10623. */
  10624. export class DoNothingAction extends Action {
  10625. /**
  10626. * Instantiate the action
  10627. * @param triggerOptions defines the trigger options
  10628. * @param condition defines the trigger related conditions
  10629. */
  10630. constructor(triggerOptions?: any, condition?: Condition);
  10631. /**
  10632. * Execute the action and do nothing.
  10633. */
  10634. execute(): void;
  10635. /**
  10636. * Serializes the actions and its related information.
  10637. * @param parent defines the object to serialize in
  10638. * @returns the serialized object
  10639. */
  10640. serialize(parent: any): any;
  10641. }
  10642. /**
  10643. * This defines an action responsible to trigger several actions once triggered.
  10644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10645. */
  10646. export class CombineAction extends Action {
  10647. /**
  10648. * The list of aggregated animations to run.
  10649. */
  10650. children: Action[];
  10651. /**
  10652. * Instantiate the action
  10653. * @param triggerOptions defines the trigger options
  10654. * @param children defines the list of aggregated animations to run
  10655. * @param condition defines the trigger related conditions
  10656. */
  10657. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10658. /** @hidden */
  10659. _prepare(): void;
  10660. /**
  10661. * Execute the action and executes all the aggregated actions.
  10662. */
  10663. execute(evt: ActionEvent): void;
  10664. /**
  10665. * Serializes the actions and its related information.
  10666. * @param parent defines the object to serialize in
  10667. * @returns the serialized object
  10668. */
  10669. serialize(parent: any): any;
  10670. }
  10671. /**
  10672. * This defines an action responsible to run code (external event) once triggered.
  10673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class ExecuteCodeAction extends Action {
  10676. /**
  10677. * The callback function to run.
  10678. */
  10679. func: (evt: ActionEvent) => void;
  10680. /**
  10681. * Instantiate the action
  10682. * @param triggerOptions defines the trigger options
  10683. * @param func defines the callback function to run
  10684. * @param condition defines the trigger related conditions
  10685. */
  10686. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10687. /**
  10688. * Execute the action and run the attached code.
  10689. */
  10690. execute(evt: ActionEvent): void;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set the parent property of the target once triggered.
  10694. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class SetParentAction extends Action {
  10697. private _parent;
  10698. private _target;
  10699. /**
  10700. * Instantiate the action
  10701. * @param triggerOptions defines the trigger options
  10702. * @param target defines the target containing the parent property
  10703. * @param parent defines from where the animation should start (animation frame)
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10707. /** @hidden */
  10708. _prepare(): void;
  10709. /**
  10710. * Execute the action and set the parent property.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. /**
  10723. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10724. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10725. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class ActionManager extends AbstractActionManager {
  10728. /**
  10729. * Nothing
  10730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly NothingTrigger: number;
  10733. /**
  10734. * On pick
  10735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnPickTrigger: number;
  10738. /**
  10739. * On left pick
  10740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnLeftPickTrigger: number;
  10743. /**
  10744. * On right pick
  10745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10746. */
  10747. static readonly OnRightPickTrigger: number;
  10748. /**
  10749. * On center pick
  10750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10751. */
  10752. static readonly OnCenterPickTrigger: number;
  10753. /**
  10754. * On pick down
  10755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10756. */
  10757. static readonly OnPickDownTrigger: number;
  10758. /**
  10759. * On double pick
  10760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10761. */
  10762. static readonly OnDoublePickTrigger: number;
  10763. /**
  10764. * On pick up
  10765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10766. */
  10767. static readonly OnPickUpTrigger: number;
  10768. /**
  10769. * On pick out.
  10770. * This trigger will only be raised if you also declared a OnPickDown
  10771. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnPickOutTrigger: number;
  10774. /**
  10775. * On long press
  10776. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnLongPressTrigger: number;
  10779. /**
  10780. * On pointer over
  10781. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnPointerOverTrigger: number;
  10784. /**
  10785. * On pointer out
  10786. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPointerOutTrigger: number;
  10789. /**
  10790. * On every frame
  10791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10792. */
  10793. static readonly OnEveryFrameTrigger: number;
  10794. /**
  10795. * On intersection enter
  10796. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10797. */
  10798. static readonly OnIntersectionEnterTrigger: number;
  10799. /**
  10800. * On intersection exit
  10801. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10802. */
  10803. static readonly OnIntersectionExitTrigger: number;
  10804. /**
  10805. * On key down
  10806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10807. */
  10808. static readonly OnKeyDownTrigger: number;
  10809. /**
  10810. * On key up
  10811. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10812. */
  10813. static readonly OnKeyUpTrigger: number;
  10814. private _scene;
  10815. /**
  10816. * Creates a new action manager
  10817. * @param scene defines the hosting scene
  10818. */
  10819. constructor(scene: Scene);
  10820. /**
  10821. * Releases all associated resources
  10822. */
  10823. dispose(): void;
  10824. /**
  10825. * Gets hosting scene
  10826. * @returns the hosting scene
  10827. */
  10828. getScene(): Scene;
  10829. /**
  10830. * Does this action manager handles actions of any of the given triggers
  10831. * @param triggers defines the triggers to be tested
  10832. * @return a boolean indicating whether one (or more) of the triggers is handled
  10833. */
  10834. hasSpecificTriggers(triggers: number[]): boolean;
  10835. /**
  10836. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10837. * speed.
  10838. * @param triggerA defines the trigger to be tested
  10839. * @param triggerB defines the trigger to be tested
  10840. * @return a boolean indicating whether one (or more) of the triggers is handled
  10841. */
  10842. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10843. /**
  10844. * Does this action manager handles actions of a given trigger
  10845. * @param trigger defines the trigger to be tested
  10846. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10847. * @return whether the trigger is handled
  10848. */
  10849. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10850. /**
  10851. * Does this action manager has pointer triggers
  10852. */
  10853. get hasPointerTriggers(): boolean;
  10854. /**
  10855. * Does this action manager has pick triggers
  10856. */
  10857. get hasPickTriggers(): boolean;
  10858. /**
  10859. * Registers an action to this action manager
  10860. * @param action defines the action to be registered
  10861. * @return the action amended (prepared) after registration
  10862. */
  10863. registerAction(action: IAction): Nullable<IAction>;
  10864. /**
  10865. * Unregisters an action to this action manager
  10866. * @param action defines the action to be unregistered
  10867. * @return a boolean indicating whether the action has been unregistered
  10868. */
  10869. unregisterAction(action: IAction): Boolean;
  10870. /**
  10871. * Process a specific trigger
  10872. * @param trigger defines the trigger to process
  10873. * @param evt defines the event details to be processed
  10874. */
  10875. processTrigger(trigger: number, evt?: IActionEvent): void;
  10876. /** @hidden */
  10877. _getEffectiveTarget(target: any, propertyPath: string): any;
  10878. /** @hidden */
  10879. _getProperty(propertyPath: string): string;
  10880. /**
  10881. * Serialize this manager to a JSON object
  10882. * @param name defines the property name to store this manager
  10883. * @returns a JSON representation of this manager
  10884. */
  10885. serialize(name: string): any;
  10886. /**
  10887. * Creates a new ActionManager from a JSON data
  10888. * @param parsedActions defines the JSON data to read from
  10889. * @param object defines the hosting mesh
  10890. * @param scene defines the hosting scene
  10891. */
  10892. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10893. /**
  10894. * Get a trigger name by index
  10895. * @param trigger defines the trigger index
  10896. * @returns a trigger name
  10897. */
  10898. static GetTriggerName(trigger: number): string;
  10899. }
  10900. }
  10901. declare module BABYLON {
  10902. /**
  10903. * Class representing a ray with position and direction
  10904. */
  10905. export class Ray {
  10906. /** origin point */
  10907. origin: Vector3;
  10908. /** direction */
  10909. direction: Vector3;
  10910. /** length of the ray */
  10911. length: number;
  10912. private static readonly _TmpVector3;
  10913. private _tmpRay;
  10914. /**
  10915. * Creates a new ray
  10916. * @param origin origin point
  10917. * @param direction direction
  10918. * @param length length of the ray
  10919. */
  10920. constructor(
  10921. /** origin point */
  10922. origin: Vector3,
  10923. /** direction */
  10924. direction: Vector3,
  10925. /** length of the ray */
  10926. length?: number);
  10927. /**
  10928. * Checks if the ray intersects a box
  10929. * This does not account for the ray length by design to improve perfs.
  10930. * @param minimum bound of the box
  10931. * @param maximum bound of the box
  10932. * @param intersectionTreshold extra extend to be added to the box in all direction
  10933. * @returns if the box was hit
  10934. */
  10935. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10936. /**
  10937. * Checks if the ray intersects a box
  10938. * This does not account for the ray lenght by design to improve perfs.
  10939. * @param box the bounding box to check
  10940. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10941. * @returns if the box was hit
  10942. */
  10943. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10944. /**
  10945. * If the ray hits a sphere
  10946. * @param sphere the bounding sphere to check
  10947. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10948. * @returns true if it hits the sphere
  10949. */
  10950. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10951. /**
  10952. * If the ray hits a triange
  10953. * @param vertex0 triangle vertex
  10954. * @param vertex1 triangle vertex
  10955. * @param vertex2 triangle vertex
  10956. * @returns intersection information if hit
  10957. */
  10958. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10959. /**
  10960. * Checks if ray intersects a plane
  10961. * @param plane the plane to check
  10962. * @returns the distance away it was hit
  10963. */
  10964. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10965. /**
  10966. * Calculate the intercept of a ray on a given axis
  10967. * @param axis to check 'x' | 'y' | 'z'
  10968. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10969. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10970. */
  10971. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10972. /**
  10973. * Checks if ray intersects a mesh
  10974. * @param mesh the mesh to check
  10975. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10976. * @returns picking info of the intersection
  10977. */
  10978. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10979. /**
  10980. * Checks if ray intersects a mesh
  10981. * @param meshes the meshes to check
  10982. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10983. * @param results array to store result in
  10984. * @returns Array of picking infos
  10985. */
  10986. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10987. private _comparePickingInfo;
  10988. private static smallnum;
  10989. private static rayl;
  10990. /**
  10991. * Intersection test between the ray and a given segment within a given tolerance (threshold)
  10992. * @param sega the first point of the segment to test the intersection against
  10993. * @param segb the second point of the segment to test the intersection against
  10994. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10995. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10996. */
  10997. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10998. /**
  10999. * Update the ray from viewport position
  11000. * @param x position
  11001. * @param y y position
  11002. * @param viewportWidth viewport width
  11003. * @param viewportHeight viewport height
  11004. * @param world world matrix
  11005. * @param view view matrix
  11006. * @param projection projection matrix
  11007. * @returns this ray updated
  11008. */
  11009. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11010. /**
  11011. * Creates a ray with origin and direction of 0,0,0
  11012. * @returns the new ray
  11013. */
  11014. static Zero(): Ray;
  11015. /**
  11016. * Creates a new ray from screen space and viewport
  11017. * @param x position
  11018. * @param y y position
  11019. * @param viewportWidth viewport width
  11020. * @param viewportHeight viewport height
  11021. * @param world world matrix
  11022. * @param view view matrix
  11023. * @param projection projection matrix
  11024. * @returns new ray
  11025. */
  11026. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11027. /**
  11028. * 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
  11029. * transformed to the given world matrix.
  11030. * @param origin The origin point
  11031. * @param end The end point
  11032. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11033. * @returns the new ray
  11034. */
  11035. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  11036. /**
  11037. * Transforms a ray by a matrix
  11038. * @param ray ray to transform
  11039. * @param matrix matrix to apply
  11040. * @returns the resulting new ray
  11041. */
  11042. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11043. /**
  11044. * Transforms a ray by a matrix
  11045. * @param ray ray to transform
  11046. * @param matrix matrix to apply
  11047. * @param result ray to store result in
  11048. */
  11049. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11050. /**
  11051. * Unproject a ray from screen space to object space
  11052. * @param sourceX defines the screen space x coordinate to use
  11053. * @param sourceY defines the screen space y coordinate to use
  11054. * @param viewportWidth defines the current width of the viewport
  11055. * @param viewportHeight defines the current height of the viewport
  11056. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11057. * @param view defines the view matrix to use
  11058. * @param projection defines the projection matrix to use
  11059. */
  11060. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11061. }
  11062. /**
  11063. * Type used to define predicate used to select faces when a mesh intersection is detected
  11064. */
  11065. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11066. interface Scene {
  11067. /** @hidden */
  11068. _tempPickingRay: Nullable<Ray>;
  11069. /** @hidden */
  11070. _cachedRayForTransform: Ray;
  11071. /** @hidden */
  11072. _pickWithRayInverseMatrix: Matrix;
  11073. /** @hidden */
  11074. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11075. /** @hidden */
  11076. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11077. /** @hidden */
  11078. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11079. }
  11080. }
  11081. declare module BABYLON {
  11082. /**
  11083. * Groups all the scene component constants in one place to ease maintenance.
  11084. * @hidden
  11085. */
  11086. export class SceneComponentConstants {
  11087. static readonly NAME_EFFECTLAYER: string;
  11088. static readonly NAME_LAYER: string;
  11089. static readonly NAME_LENSFLARESYSTEM: string;
  11090. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11091. static readonly NAME_PARTICLESYSTEM: string;
  11092. static readonly NAME_GAMEPAD: string;
  11093. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11094. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11095. static readonly NAME_PREPASSRENDERER: string;
  11096. static readonly NAME_DEPTHRENDERER: string;
  11097. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11098. static readonly NAME_SPRITE: string;
  11099. static readonly NAME_SUBSURFACE: string;
  11100. static readonly NAME_OUTLINERENDERER: string;
  11101. static readonly NAME_PROCEDURALTEXTURE: string;
  11102. static readonly NAME_SHADOWGENERATOR: string;
  11103. static readonly NAME_OCTREE: string;
  11104. static readonly NAME_PHYSICSENGINE: string;
  11105. static readonly NAME_AUDIO: string;
  11106. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11107. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11108. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11109. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11110. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11111. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11112. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11113. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11114. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS: number;
  11115. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11116. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11117. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11118. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11119. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11120. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11121. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11122. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11123. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11124. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11125. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS: number;
  11126. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11127. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11128. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11129. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11130. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11131. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11132. static readonly STEP_AFTERRENDER_AUDIO: number;
  11133. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11134. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11135. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11136. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11137. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11138. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11139. static readonly STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS: number;
  11140. static readonly STEP_POINTERMOVE_SPRITE: number;
  11141. static readonly STEP_POINTERDOWN_SPRITE: number;
  11142. static readonly STEP_POINTERUP_SPRITE: number;
  11143. }
  11144. /**
  11145. * This represents a scene component.
  11146. *
  11147. * This is used to decouple the dependency the scene is having on the different workloads like
  11148. * layers, post processes...
  11149. */
  11150. export interface ISceneComponent {
  11151. /**
  11152. * The name of the component. Each component must have a unique name.
  11153. */
  11154. name: string;
  11155. /**
  11156. * The scene the component belongs to.
  11157. */
  11158. scene: Scene;
  11159. /**
  11160. * Register the component to one instance of a scene.
  11161. */
  11162. register(): void;
  11163. /**
  11164. * Rebuilds the elements related to this component in case of
  11165. * context lost for instance.
  11166. */
  11167. rebuild(): void;
  11168. /**
  11169. * Disposes the component and the associated ressources.
  11170. */
  11171. dispose(): void;
  11172. }
  11173. /**
  11174. * This represents a SERIALIZABLE scene component.
  11175. *
  11176. * This extends Scene Component to add Serialization methods on top.
  11177. */
  11178. export interface ISceneSerializableComponent extends ISceneComponent {
  11179. /**
  11180. * Adds all the elements from the container to the scene
  11181. * @param container the container holding the elements
  11182. */
  11183. addFromContainer(container: AbstractScene): void;
  11184. /**
  11185. * Removes all the elements in the container from the scene
  11186. * @param container contains the elements to remove
  11187. * @param dispose if the removed element should be disposed (default: false)
  11188. */
  11189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11190. /**
  11191. * Serializes the component data to the specified json object
  11192. * @param serializationObject The object to serialize to
  11193. */
  11194. serialize(serializationObject: any): void;
  11195. }
  11196. /**
  11197. * Strong typing of a Mesh related stage step action
  11198. */
  11199. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11200. /**
  11201. * Strong typing of a Evaluate Sub Mesh related stage step action
  11202. */
  11203. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11204. /**
  11205. * Strong typing of a pre active Mesh related stage step action
  11206. */
  11207. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11208. /**
  11209. * Strong typing of a Camera related stage step action
  11210. */
  11211. export type CameraStageAction = (camera: Camera) => void;
  11212. /**
  11213. * Strong typing of a Camera Frame buffer related stage step action
  11214. */
  11215. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11216. /**
  11217. * Strong typing of a Render Target related stage step action
  11218. */
  11219. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  11220. /**
  11221. * Strong typing of a RenderingGroup related stage step action
  11222. */
  11223. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11224. /**
  11225. * Strong typing of a Mesh Render related stage step action
  11226. */
  11227. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11228. /**
  11229. * Strong typing of a simple stage step action
  11230. */
  11231. export type SimpleStageAction = () => void;
  11232. /**
  11233. * Strong typing of a render target action.
  11234. */
  11235. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11236. /**
  11237. * Strong typing of a pointer move action.
  11238. */
  11239. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11240. /**
  11241. * Strong typing of a pointer up/down action.
  11242. */
  11243. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11244. /**
  11245. * Representation of a stage in the scene (Basically a list of ordered steps)
  11246. * @hidden
  11247. */
  11248. export class Stage<T extends Function> extends Array<{
  11249. index: number;
  11250. component: ISceneComponent;
  11251. action: T;
  11252. }> {
  11253. /**
  11254. * Hide ctor from the rest of the world.
  11255. * @param items The items to add.
  11256. */
  11257. private constructor();
  11258. /**
  11259. * Creates a new Stage.
  11260. * @returns A new instance of a Stage
  11261. */
  11262. static Create<T extends Function>(): Stage<T>;
  11263. /**
  11264. * Registers a step in an ordered way in the targeted stage.
  11265. * @param index Defines the position to register the step in
  11266. * @param component Defines the component attached to the step
  11267. * @param action Defines the action to launch during the step
  11268. */
  11269. registerStep(index: number, component: ISceneComponent, action: T): void;
  11270. /**
  11271. * Clears all the steps from the stage.
  11272. */
  11273. clear(): void;
  11274. }
  11275. }
  11276. declare module BABYLON {
  11277. interface Scene {
  11278. /** @hidden */
  11279. _pointerOverSprite: Nullable<Sprite>;
  11280. /** @hidden */
  11281. _pickedDownSprite: Nullable<Sprite>;
  11282. /** @hidden */
  11283. _tempSpritePickingRay: Nullable<Ray>;
  11284. /**
  11285. * All of the sprite managers added to this scene
  11286. * @see https://doc.babylonjs.com/babylon101/sprites
  11287. */
  11288. spriteManagers: Array<ISpriteManager>;
  11289. /**
  11290. * An event triggered when sprites rendering is about to start
  11291. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11292. */
  11293. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11294. /**
  11295. * An event triggered when sprites rendering is done
  11296. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11297. */
  11298. onAfterSpritesRenderingObservable: Observable<Scene>;
  11299. /** @hidden */
  11300. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11301. /** Launch a ray to try to pick a sprite in the scene
  11302. * @param x position on screen
  11303. * @param y position on screen
  11304. * @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
  11305. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11306. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11307. * @returns a PickingInfo
  11308. */
  11309. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11310. /** Use the given ray to pick a sprite in the scene
  11311. * @param ray The ray (in world space) to use to pick meshes
  11312. * @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
  11313. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11314. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11315. * @returns a PickingInfo
  11316. */
  11317. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11318. /** @hidden */
  11319. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11320. /** Launch a ray to try to pick sprites in the scene
  11321. * @param x position on screen
  11322. * @param y position on screen
  11323. * @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
  11324. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11325. * @returns a PickingInfo array
  11326. */
  11327. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11328. /** Use the given ray to pick sprites in the scene
  11329. * @param ray The ray (in world space) to use to pick meshes
  11330. * @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
  11331. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /**
  11336. * Force the sprite under the pointer
  11337. * @param sprite defines the sprite to use
  11338. */
  11339. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11340. /**
  11341. * Gets the sprite under the pointer
  11342. * @returns a Sprite or null if no sprite is under the pointer
  11343. */
  11344. getPointerOverSprite(): Nullable<Sprite>;
  11345. }
  11346. /**
  11347. * Defines the sprite scene component responsible to manage sprites
  11348. * in a given scene.
  11349. */
  11350. export class SpriteSceneComponent implements ISceneComponent {
  11351. /**
  11352. * The component name helpfull to identify the component in the list of scene components.
  11353. */
  11354. readonly name: string;
  11355. /**
  11356. * The scene the component belongs to.
  11357. */
  11358. scene: Scene;
  11359. /** @hidden */
  11360. private _spritePredicate;
  11361. /**
  11362. * Creates a new instance of the component for the given scene
  11363. * @param scene Defines the scene to register the component in
  11364. */
  11365. constructor(scene: Scene);
  11366. /**
  11367. * Registers the component in a given scene
  11368. */
  11369. register(): void;
  11370. /**
  11371. * Rebuilds the elements related to this component in case of
  11372. * context lost for instance.
  11373. */
  11374. rebuild(): void;
  11375. /**
  11376. * Disposes the component and the associated resources.
  11377. */
  11378. dispose(): void;
  11379. private _pickSpriteButKeepRay;
  11380. private _pointerMove;
  11381. private _pointerDown;
  11382. private _pointerUp;
  11383. }
  11384. }
  11385. declare module BABYLON {
  11386. /**
  11387. * Class used to provide helper for timing
  11388. */
  11389. export class TimingTools {
  11390. /**
  11391. * Polyfill for setImmediate
  11392. * @param action defines the action to execute after the current execution block
  11393. */
  11394. static SetImmediate(action: () => void): void;
  11395. }
  11396. }
  11397. declare module BABYLON {
  11398. /**
  11399. * Class used to enable instantiation of objects by class name
  11400. */
  11401. export class InstantiationTools {
  11402. /**
  11403. * Use this object to register external classes like custom textures or material
  11404. * to allow the loaders to instantiate them
  11405. */
  11406. static RegisteredExternalClasses: {
  11407. [key: string]: Object;
  11408. };
  11409. /**
  11410. * Tries to instantiate a new object from a given class name
  11411. * @param className defines the class name to instantiate
  11412. * @returns the new object or null if the system was not able to do the instantiation
  11413. */
  11414. static Instantiate(className: string): any;
  11415. }
  11416. }
  11417. declare module BABYLON {
  11418. /**
  11419. * Class used to host copy specific utilities
  11420. */
  11421. export class CopyTools {
  11422. /**
  11423. * Transform some pixel data to a base64 string
  11424. * @param pixels defines the pixel data to transform to base64
  11425. * @param size defines the width and height of the (texture) data
  11426. * @param invertY true if the data must be inverted for the Y coordinate during the conversion
  11427. * @returns The base64 encoded string or null
  11428. */
  11429. static GenerateBase64StringFromPixelData(pixels: ArrayBufferView, size: ISize, invertY?: boolean): Nullable<string>;
  11430. /**
  11431. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11432. * @param texture defines the texture to read pixels from
  11433. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11434. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11435. * @returns The base64 encoded string or null
  11436. */
  11437. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  11438. /**
  11439. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11440. * @param texture defines the texture to read pixels from
  11441. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11442. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11443. * @returns The base64 encoded string or null wrapped in a promise
  11444. */
  11445. static GenerateBase64StringFromTextureAsync(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11446. }
  11447. }
  11448. declare module BABYLON {
  11449. /**
  11450. * Define options used to create a depth texture
  11451. */
  11452. export class DepthTextureCreationOptions {
  11453. /** Specifies whether or not a stencil should be allocated in the texture */
  11454. generateStencil?: boolean;
  11455. /** Specifies whether or not bilinear filtering is enable on the texture */
  11456. bilinearFiltering?: boolean;
  11457. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11458. comparisonFunction?: number;
  11459. /** Specifies if the created texture is a cube texture */
  11460. isCube?: boolean;
  11461. /** Specifies the sample count of the depth/stencil texture texture */
  11462. samples?: number;
  11463. }
  11464. }
  11465. declare module BABYLON {
  11466. interface ThinEngine {
  11467. /**
  11468. * Creates a depth stencil cube texture.
  11469. * This is only available in WebGL 2.
  11470. * @param size The size of face edge in the cube texture.
  11471. * @param options The options defining the cube texture.
  11472. * @returns The cube texture
  11473. */
  11474. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11475. /**
  11476. * Creates a cube texture
  11477. * @param rootUrl defines the url where the files to load is located
  11478. * @param scene defines the current scene
  11479. * @param files defines the list of files to load (1 per face)
  11480. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11481. * @param onLoad defines an optional callback raised when the texture is loaded
  11482. * @param onError defines an optional callback raised if there is an issue to load the texture
  11483. * @param format defines the format of the data
  11484. * @param forcedExtension defines the extension to use to pick the right loader
  11485. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11486. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11487. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11488. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11489. * @param loaderOptions options to be passed to the loader
  11490. * @returns the cube texture as an InternalTexture
  11491. */
  11492. 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;
  11493. /**
  11494. * Creates a cube texture
  11495. * @param rootUrl defines the url where the files to load is located
  11496. * @param scene defines the current scene
  11497. * @param files defines the list of files to load (1 per face)
  11498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11499. * @param onLoad defines an optional callback raised when the texture is loaded
  11500. * @param onError defines an optional callback raised if there is an issue to load the texture
  11501. * @param format defines the format of the data
  11502. * @param forcedExtension defines the extension to use to pick the right loader
  11503. * @returns the cube texture as an InternalTexture
  11504. */
  11505. 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;
  11506. /**
  11507. * Creates a cube texture
  11508. * @param rootUrl defines the url where the files to load is located
  11509. * @param scene defines the current scene
  11510. * @param files defines the list of files to load (1 per face)
  11511. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11512. * @param onLoad defines an optional callback raised when the texture is loaded
  11513. * @param onError defines an optional callback raised if there is an issue to load the texture
  11514. * @param format defines the format of the data
  11515. * @param forcedExtension defines the extension to use to pick the right loader
  11516. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11519. * @returns the cube texture as an InternalTexture
  11520. */
  11521. 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;
  11522. /** @hidden */
  11523. 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;
  11524. /** @hidden */
  11525. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11526. /** @hidden */
  11527. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11528. /** @hidden */
  11529. _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;
  11530. /** @hidden */
  11531. _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;
  11532. /**
  11533. * @hidden
  11534. */
  11535. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11536. }
  11537. }
  11538. declare module BABYLON {
  11539. /**
  11540. * Class for creating a cube texture
  11541. */
  11542. export class CubeTexture extends BaseTexture {
  11543. private _delayedOnLoad;
  11544. /**
  11545. * Observable triggered once the texture has been loaded.
  11546. */
  11547. onLoadObservable: Observable<CubeTexture>;
  11548. /**
  11549. * The url of the texture
  11550. */
  11551. url: string;
  11552. /**
  11553. * Gets or sets the center of the bounding box associated with the cube texture.
  11554. * It must define where the camera used to render the texture was set
  11555. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11556. */
  11557. boundingBoxPosition: Vector3;
  11558. private _boundingBoxSize;
  11559. /**
  11560. * Gets or sets the size of the bounding box associated with the cube texture
  11561. * When defined, the cubemap will switch to local mode
  11562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11563. * @example https://www.babylonjs-playground.com/#RNASML
  11564. */
  11565. set boundingBoxSize(value: Vector3);
  11566. /**
  11567. * Returns the bounding box size
  11568. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11569. */
  11570. get boundingBoxSize(): Vector3;
  11571. protected _rotationY: number;
  11572. /**
  11573. * Sets texture matrix rotation angle around Y axis in radians.
  11574. */
  11575. set rotationY(value: number);
  11576. /**
  11577. * Gets texture matrix rotation angle around Y axis radians.
  11578. */
  11579. get rotationY(): number;
  11580. /**
  11581. * Are mip maps generated for this texture or not.
  11582. */
  11583. get noMipmap(): boolean;
  11584. private _noMipmap;
  11585. private _files;
  11586. protected _forcedExtension: Nullable<string>;
  11587. private _extensions;
  11588. private _textureMatrix;
  11589. private _format;
  11590. private _createPolynomials;
  11591. private _loaderOptions;
  11592. /**
  11593. * Creates a cube texture from an array of image urls
  11594. * @param files defines an array of image urls
  11595. * @param scene defines the hosting scene
  11596. * @param noMipmap specifies if mip maps are not used
  11597. * @returns a cube texture
  11598. */
  11599. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11600. /**
  11601. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11602. * @param url defines the url of the prefiltered texture
  11603. * @param scene defines the scene the texture is attached to
  11604. * @param forcedExtension defines the extension of the file if different from the url
  11605. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11606. * @return the prefiltered texture
  11607. */
  11608. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11609. /**
  11610. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11611. * as prefiltered data.
  11612. * @param rootUrl defines the url of the texture or the root name of the six images
  11613. * @param null defines the scene or engine the texture is attached to
  11614. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11615. * @param noMipmap defines if mipmaps should be created or not
  11616. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11617. * @param onLoad defines a callback triggered at the end of the file load if no errors occurred
  11618. * @param onError defines a callback triggered in case of error during load
  11619. * @param format defines the internal format to use for the texture once loaded
  11620. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11621. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11622. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11623. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11624. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11625. * @param loaderOptions options to be passed to the loader
  11626. * @return the cube texture
  11627. */
  11628. 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);
  11629. /**
  11630. * Get the current class name of the texture useful for serialization or dynamic coding.
  11631. * @returns "CubeTexture"
  11632. */
  11633. getClassName(): string;
  11634. /**
  11635. * Update the url (and optional buffer) of this texture if url was null during construction.
  11636. * @param url the url of the texture
  11637. * @param forcedExtension defines the extension to use
  11638. * @param onLoad callback called when the texture is loaded (defaults to null)
  11639. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11640. */
  11641. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11642. /**
  11643. * Delays loading of the cube texture
  11644. * @param forcedExtension defines the extension to use
  11645. */
  11646. delayLoad(forcedExtension?: string): void;
  11647. /**
  11648. * Returns the reflection texture matrix
  11649. * @returns the reflection texture matrix
  11650. */
  11651. getReflectionTextureMatrix(): Matrix;
  11652. /**
  11653. * Sets the reflection texture matrix
  11654. * @param value Reflection texture matrix
  11655. */
  11656. setReflectionTextureMatrix(value: Matrix): void;
  11657. /**
  11658. * Parses text to create a cube texture
  11659. * @param parsedTexture define the serialized text to read from
  11660. * @param scene defines the hosting scene
  11661. * @param rootUrl defines the root url of the cube texture
  11662. * @returns a cube texture
  11663. */
  11664. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11665. /**
  11666. * Makes a clone, or deep copy, of the cube texture
  11667. * @returns a new cube texture
  11668. */
  11669. clone(): CubeTexture;
  11670. }
  11671. }
  11672. declare module BABYLON {
  11673. /**
  11674. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  11675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11676. * 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;
  11677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11678. */
  11679. export class ColorCurves {
  11680. private _dirty;
  11681. private _tempColor;
  11682. private _globalCurve;
  11683. private _highlightsCurve;
  11684. private _midtonesCurve;
  11685. private _shadowsCurve;
  11686. private _positiveCurve;
  11687. private _negativeCurve;
  11688. private _globalHue;
  11689. private _globalDensity;
  11690. private _globalSaturation;
  11691. private _globalExposure;
  11692. /**
  11693. * Gets the global Hue value.
  11694. * 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).
  11695. */
  11696. get globalHue(): number;
  11697. /**
  11698. * Sets the global Hue value.
  11699. * 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).
  11700. */
  11701. set globalHue(value: number);
  11702. /**
  11703. * Gets the global Density value.
  11704. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11705. * Values less than zero provide a filter of opposite hue.
  11706. */
  11707. get globalDensity(): number;
  11708. /**
  11709. * Sets the global Density value.
  11710. * 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.
  11711. * Values less than zero provide a filter of opposite hue.
  11712. */
  11713. set globalDensity(value: number);
  11714. /**
  11715. * Gets the global Saturation value.
  11716. * 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.
  11717. */
  11718. get globalSaturation(): number;
  11719. /**
  11720. * Sets the global Saturation value.
  11721. * 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.
  11722. */
  11723. set globalSaturation(value: number);
  11724. /**
  11725. * Gets the global Exposure value.
  11726. * 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.
  11727. */
  11728. get globalExposure(): number;
  11729. /**
  11730. * Sets the global Exposure value.
  11731. * 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.
  11732. */
  11733. set globalExposure(value: number);
  11734. private _highlightsHue;
  11735. private _highlightsDensity;
  11736. private _highlightsSaturation;
  11737. private _highlightsExposure;
  11738. /**
  11739. * Gets the highlights Hue value.
  11740. * 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).
  11741. */
  11742. get highlightsHue(): number;
  11743. /**
  11744. * Sets the highlights Hue value.
  11745. * 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).
  11746. */
  11747. set highlightsHue(value: number);
  11748. /**
  11749. * Gets the highlights Density value.
  11750. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11751. * Values less than zero provide a filter of opposite hue.
  11752. */
  11753. get highlightsDensity(): number;
  11754. /**
  11755. * Sets the highlights Density value.
  11756. * 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.
  11757. * Values less than zero provide a filter of opposite hue.
  11758. */
  11759. set highlightsDensity(value: number);
  11760. /**
  11761. * Gets the highlights Saturation value.
  11762. * 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.
  11763. */
  11764. get highlightsSaturation(): number;
  11765. /**
  11766. * Sets the highlights Saturation value.
  11767. * 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.
  11768. */
  11769. set highlightsSaturation(value: number);
  11770. /**
  11771. * Gets the highlights Exposure value.
  11772. * 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.
  11773. */
  11774. get highlightsExposure(): number;
  11775. /**
  11776. * Sets the highlights Exposure value.
  11777. * 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.
  11778. */
  11779. set highlightsExposure(value: number);
  11780. private _midtonesHue;
  11781. private _midtonesDensity;
  11782. private _midtonesSaturation;
  11783. private _midtonesExposure;
  11784. /**
  11785. * Gets the midtones Hue value.
  11786. * 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).
  11787. */
  11788. get midtonesHue(): number;
  11789. /**
  11790. * Sets the midtones Hue value.
  11791. * 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).
  11792. */
  11793. set midtonesHue(value: number);
  11794. /**
  11795. * Gets the midtones Density value.
  11796. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11797. * Values less than zero provide a filter of opposite hue.
  11798. */
  11799. get midtonesDensity(): number;
  11800. /**
  11801. * Sets the midtones Density value.
  11802. * 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.
  11803. * Values less than zero provide a filter of opposite hue.
  11804. */
  11805. set midtonesDensity(value: number);
  11806. /**
  11807. * Gets the midtones Saturation value.
  11808. * 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.
  11809. */
  11810. get midtonesSaturation(): number;
  11811. /**
  11812. * Sets the midtones Saturation value.
  11813. * 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.
  11814. */
  11815. set midtonesSaturation(value: number);
  11816. /**
  11817. * Gets the midtones Exposure value.
  11818. * 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.
  11819. */
  11820. get midtonesExposure(): number;
  11821. /**
  11822. * Sets the midtones Exposure value.
  11823. * 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.
  11824. */
  11825. set midtonesExposure(value: number);
  11826. private _shadowsHue;
  11827. private _shadowsDensity;
  11828. private _shadowsSaturation;
  11829. private _shadowsExposure;
  11830. /**
  11831. * Gets the shadows Hue value.
  11832. * 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).
  11833. */
  11834. get shadowsHue(): number;
  11835. /**
  11836. * Sets the shadows Hue value.
  11837. * 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).
  11838. */
  11839. set shadowsHue(value: number);
  11840. /**
  11841. * Gets the shadows Density value.
  11842. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11843. * Values less than zero provide a filter of opposite hue.
  11844. */
  11845. get shadowsDensity(): number;
  11846. /**
  11847. * Sets the shadows Density value.
  11848. * 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.
  11849. * Values less than zero provide a filter of opposite hue.
  11850. */
  11851. set shadowsDensity(value: number);
  11852. /**
  11853. * Gets the shadows Saturation value.
  11854. * 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.
  11855. */
  11856. get shadowsSaturation(): number;
  11857. /**
  11858. * Sets the shadows Saturation value.
  11859. * 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.
  11860. */
  11861. set shadowsSaturation(value: number);
  11862. /**
  11863. * Gets the shadows Exposure value.
  11864. * 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.
  11865. */
  11866. get shadowsExposure(): number;
  11867. /**
  11868. * Sets the shadows Exposure value.
  11869. * 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.
  11870. */
  11871. set shadowsExposure(value: number);
  11872. /**
  11873. * Returns the class name
  11874. * @returns The class name
  11875. */
  11876. getClassName(): string;
  11877. /**
  11878. * Binds the color curves to the shader.
  11879. * @param colorCurves The color curve to bind
  11880. * @param effect The effect to bind to
  11881. * @param positiveUniform The positive uniform shader parameter
  11882. * @param neutralUniform The neutral uniform shader parameter
  11883. * @param negativeUniform The negative uniform shader parameter
  11884. */
  11885. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11886. /**
  11887. * Prepare the list of uniforms associated with the ColorCurves effects.
  11888. * @param uniformsList The list of uniforms used in the effect
  11889. */
  11890. static PrepareUniforms(uniformsList: string[]): void;
  11891. /**
  11892. * Returns color grading data based on a hue, density, saturation and exposure value.
  11893. * @param filterHue The hue of the color filter.
  11894. * @param filterDensity The density of the color filter.
  11895. * @param saturation The saturation.
  11896. * @param exposure The exposure.
  11897. * @param result The result data container.
  11898. */
  11899. private getColorGradingDataToRef;
  11900. /**
  11901. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11902. * @param value The input slider value in range [-100,100].
  11903. * @returns Adjusted value.
  11904. */
  11905. private static applyColorGradingSliderNonlinear;
  11906. /**
  11907. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11908. * @param hue The hue (H) input.
  11909. * @param saturation The saturation (S) input.
  11910. * @param brightness The brightness (B) input.
  11911. * @result An RGBA color represented as Vector4.
  11912. */
  11913. private static fromHSBToRef;
  11914. /**
  11915. * Returns a value clamped between min and max
  11916. * @param value The value to clamp
  11917. * @param min The minimum of value
  11918. * @param max The maximum of value
  11919. * @returns The clamped value.
  11920. */
  11921. private static clamp;
  11922. /**
  11923. * Clones the current color curve instance.
  11924. * @return The cloned curves
  11925. */
  11926. clone(): ColorCurves;
  11927. /**
  11928. * Serializes the current color curve instance to a json representation.
  11929. * @return a JSON representation
  11930. */
  11931. serialize(): any;
  11932. /**
  11933. * Parses the color curve from a json representation.
  11934. * @param source the JSON source to parse
  11935. * @return The parsed curves
  11936. */
  11937. static Parse(source: any): ColorCurves;
  11938. }
  11939. }
  11940. declare module BABYLON {
  11941. /**
  11942. * Interface to follow in your material defines to integrate easily the
  11943. * Image processing functions.
  11944. * @hidden
  11945. */
  11946. export interface IImageProcessingConfigurationDefines {
  11947. IMAGEPROCESSING: boolean;
  11948. VIGNETTE: boolean;
  11949. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11950. VIGNETTEBLENDMODEOPAQUE: boolean;
  11951. TONEMAPPING: boolean;
  11952. TONEMAPPING_ACES: boolean;
  11953. CONTRAST: boolean;
  11954. EXPOSURE: boolean;
  11955. COLORCURVES: boolean;
  11956. COLORGRADING: boolean;
  11957. COLORGRADING3D: boolean;
  11958. SAMPLER3DGREENDEPTH: boolean;
  11959. SAMPLER3DBGRMAP: boolean;
  11960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11961. }
  11962. /**
  11963. * @hidden
  11964. */
  11965. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11966. IMAGEPROCESSING: boolean;
  11967. VIGNETTE: boolean;
  11968. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11969. VIGNETTEBLENDMODEOPAQUE: boolean;
  11970. TONEMAPPING: boolean;
  11971. TONEMAPPING_ACES: boolean;
  11972. CONTRAST: boolean;
  11973. COLORCURVES: boolean;
  11974. COLORGRADING: boolean;
  11975. COLORGRADING3D: boolean;
  11976. SAMPLER3DGREENDEPTH: boolean;
  11977. SAMPLER3DBGRMAP: boolean;
  11978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11979. EXPOSURE: boolean;
  11980. constructor();
  11981. }
  11982. /**
  11983. * This groups together the common properties used for image processing either in direct forward pass
  11984. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11985. * or not.
  11986. */
  11987. export class ImageProcessingConfiguration {
  11988. /**
  11989. * Default tone mapping applied in BabylonJS.
  11990. */
  11991. static readonly TONEMAPPING_STANDARD: number;
  11992. /**
  11993. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11994. * to other engines rendering to increase portability.
  11995. */
  11996. static readonly TONEMAPPING_ACES: number;
  11997. /**
  11998. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11999. */
  12000. colorCurves: Nullable<ColorCurves>;
  12001. private _colorCurvesEnabled;
  12002. /**
  12003. * Gets whether the color curves effect is enabled.
  12004. */
  12005. get colorCurvesEnabled(): boolean;
  12006. /**
  12007. * Sets whether the color curves effect is enabled.
  12008. */
  12009. set colorCurvesEnabled(value: boolean);
  12010. private _colorGradingTexture;
  12011. /**
  12012. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12013. */
  12014. get colorGradingTexture(): Nullable<BaseTexture>;
  12015. /**
  12016. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  12017. */
  12018. set colorGradingTexture(value: Nullable<BaseTexture>);
  12019. private _colorGradingEnabled;
  12020. /**
  12021. * Gets whether the color grading effect is enabled.
  12022. */
  12023. get colorGradingEnabled(): boolean;
  12024. /**
  12025. * Sets whether the color grading effect is enabled.
  12026. */
  12027. set colorGradingEnabled(value: boolean);
  12028. private _colorGradingWithGreenDepth;
  12029. /**
  12030. * Gets whether the color grading effect is using a green depth for the 3d Texture.
  12031. */
  12032. get colorGradingWithGreenDepth(): boolean;
  12033. /**
  12034. * Sets whether the color grading effect is using a green depth for the 3d Texture.
  12035. */
  12036. set colorGradingWithGreenDepth(value: boolean);
  12037. private _colorGradingBGR;
  12038. /**
  12039. * Gets whether the color grading texture contains BGR values.
  12040. */
  12041. get colorGradingBGR(): boolean;
  12042. /**
  12043. * Sets whether the color grading texture contains BGR values.
  12044. */
  12045. set colorGradingBGR(value: boolean);
  12046. /** @hidden */
  12047. _exposure: number;
  12048. /**
  12049. * Gets the Exposure used in the effect.
  12050. */
  12051. get exposure(): number;
  12052. /**
  12053. * Sets the Exposure used in the effect.
  12054. */
  12055. set exposure(value: number);
  12056. private _toneMappingEnabled;
  12057. /**
  12058. * Gets whether the tone mapping effect is enabled.
  12059. */
  12060. get toneMappingEnabled(): boolean;
  12061. /**
  12062. * Sets whether the tone mapping effect is enabled.
  12063. */
  12064. set toneMappingEnabled(value: boolean);
  12065. private _toneMappingType;
  12066. /**
  12067. * Gets the type of tone mapping effect.
  12068. */
  12069. get toneMappingType(): number;
  12070. /**
  12071. * Sets the type of tone mapping effect used in BabylonJS.
  12072. */
  12073. set toneMappingType(value: number);
  12074. protected _contrast: number;
  12075. /**
  12076. * Gets the contrast used in the effect.
  12077. */
  12078. get contrast(): number;
  12079. /**
  12080. * Sets the contrast used in the effect.
  12081. */
  12082. set contrast(value: number);
  12083. /**
  12084. * Vignette stretch size.
  12085. */
  12086. vignetteStretch: number;
  12087. /**
  12088. * Vignette centre X Offset.
  12089. */
  12090. vignetteCentreX: number;
  12091. /**
  12092. * Vignette centre Y Offset.
  12093. */
  12094. vignetteCentreY: number;
  12095. /**
  12096. * Vignette weight or intensity of the vignette effect.
  12097. */
  12098. vignetteWeight: number;
  12099. /**
  12100. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12101. * if vignetteEnabled is set to true.
  12102. */
  12103. vignetteColor: Color4;
  12104. /**
  12105. * Camera field of view used by the Vignette effect.
  12106. */
  12107. vignetteCameraFov: number;
  12108. private _vignetteBlendMode;
  12109. /**
  12110. * Gets the vignette blend mode allowing different kind of effect.
  12111. */
  12112. get vignetteBlendMode(): number;
  12113. /**
  12114. * Sets the vignette blend mode allowing different kind of effect.
  12115. */
  12116. set vignetteBlendMode(value: number);
  12117. private _vignetteEnabled;
  12118. /**
  12119. * Gets whether the vignette effect is enabled.
  12120. */
  12121. get vignetteEnabled(): boolean;
  12122. /**
  12123. * Sets whether the vignette effect is enabled.
  12124. */
  12125. set vignetteEnabled(value: boolean);
  12126. private _applyByPostProcess;
  12127. /**
  12128. * Gets whether the image processing is applied through a post process or not.
  12129. */
  12130. get applyByPostProcess(): boolean;
  12131. /**
  12132. * Sets whether the image processing is applied through a post process or not.
  12133. */
  12134. set applyByPostProcess(value: boolean);
  12135. private _isEnabled;
  12136. /**
  12137. * Gets whether the image processing is enabled or not.
  12138. */
  12139. get isEnabled(): boolean;
  12140. /**
  12141. * Sets whether the image processing is enabled or not.
  12142. */
  12143. set isEnabled(value: boolean);
  12144. /**
  12145. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12146. */
  12147. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12148. /**
  12149. * Method called each time the image processing information changes requires to recompile the effect.
  12150. */
  12151. protected _updateParameters(): void;
  12152. /**
  12153. * Gets the current class name.
  12154. * @return "ImageProcessingConfiguration"
  12155. */
  12156. getClassName(): string;
  12157. /**
  12158. * Prepare the list of uniforms associated with the Image Processing effects.
  12159. * @param uniforms The list of uniforms used in the effect
  12160. * @param defines the list of defines currently in use
  12161. */
  12162. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12163. /**
  12164. * Prepare the list of samplers associated with the Image Processing effects.
  12165. * @param samplersList The list of uniforms used in the effect
  12166. * @param defines the list of defines currently in use
  12167. */
  12168. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12169. /**
  12170. * Prepare the list of defines associated to the shader.
  12171. * @param defines the list of defines to complete
  12172. * @param forPostProcess Define if we are currently in post process mode or not
  12173. */
  12174. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12175. /**
  12176. * Returns true if all the image processing information are ready.
  12177. * @returns True if ready, otherwise, false
  12178. */
  12179. isReady(): boolean;
  12180. /**
  12181. * Binds the image processing to the shader.
  12182. * @param effect The effect to bind to
  12183. * @param overrideAspectRatio Override the aspect ratio of the effect
  12184. */
  12185. bind(effect: Effect, overrideAspectRatio?: number): void;
  12186. /**
  12187. * Clones the current image processing instance.
  12188. * @return The cloned image processing
  12189. */
  12190. clone(): ImageProcessingConfiguration;
  12191. /**
  12192. * Serializes the current image processing instance to a json representation.
  12193. * @return a JSON representation
  12194. */
  12195. serialize(): any;
  12196. /**
  12197. * Parses the image processing from a json representation.
  12198. * @param source the JSON source to parse
  12199. * @return The parsed image processing
  12200. */
  12201. static Parse(source: any): ImageProcessingConfiguration;
  12202. private static _VIGNETTEMODE_MULTIPLY;
  12203. private static _VIGNETTEMODE_OPAQUE;
  12204. /**
  12205. * Used to apply the vignette as a mix with the pixel color.
  12206. */
  12207. static get VIGNETTEMODE_MULTIPLY(): number;
  12208. /**
  12209. * Used to apply the vignette as a replacement of the pixel color.
  12210. */
  12211. static get VIGNETTEMODE_OPAQUE(): number;
  12212. }
  12213. }
  12214. declare module BABYLON {
  12215. /** @hidden */
  12216. export var postprocessVertexShader: {
  12217. name: string;
  12218. shader: string;
  12219. };
  12220. }
  12221. declare module BABYLON {
  12222. /**
  12223. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12224. */
  12225. export type RenderTargetTextureSize = number | {
  12226. width: number;
  12227. height: number;
  12228. layers?: number;
  12229. };
  12230. interface ThinEngine {
  12231. /**
  12232. * Creates a new render target texture
  12233. * @param size defines the size of the texture
  12234. * @param options defines the options used to create the texture
  12235. * @returns a new render target texture stored in an InternalTexture
  12236. */
  12237. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12238. /**
  12239. * Creates a depth stencil texture.
  12240. * This is only available in WebGL 2 or with the depth texture extension available.
  12241. * @param size The size of face edge in the texture.
  12242. * @param options The options defining the texture.
  12243. * @returns The texture
  12244. */
  12245. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12246. /** @hidden */
  12247. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12248. }
  12249. }
  12250. declare module BABYLON {
  12251. /**
  12252. * Defines the kind of connection point for node based material
  12253. */
  12254. export enum NodeMaterialBlockConnectionPointTypes {
  12255. /** Float */
  12256. Float = 1,
  12257. /** Int */
  12258. Int = 2,
  12259. /** Vector2 */
  12260. Vector2 = 4,
  12261. /** Vector3 */
  12262. Vector3 = 8,
  12263. /** Vector4 */
  12264. Vector4 = 16,
  12265. /** Color3 */
  12266. Color3 = 32,
  12267. /** Color4 */
  12268. Color4 = 64,
  12269. /** Matrix */
  12270. Matrix = 128,
  12271. /** Custom object */
  12272. Object = 256,
  12273. /** Detect type based on connection */
  12274. AutoDetect = 1024,
  12275. /** Output type that will be defined by input type */
  12276. BasedOnInput = 2048
  12277. }
  12278. }
  12279. declare module BABYLON {
  12280. /**
  12281. * Enum used to define the target of a block
  12282. */
  12283. export enum NodeMaterialBlockTargets {
  12284. /** Vertex shader */
  12285. Vertex = 1,
  12286. /** Fragment shader */
  12287. Fragment = 2,
  12288. /** Neutral */
  12289. Neutral = 4,
  12290. /** Vertex and Fragment */
  12291. VertexAndFragment = 3
  12292. }
  12293. }
  12294. declare module BABYLON {
  12295. /**
  12296. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12297. */
  12298. export enum NodeMaterialBlockConnectionPointMode {
  12299. /** Value is an uniform */
  12300. Uniform = 0,
  12301. /** Value is a mesh attribute */
  12302. Attribute = 1,
  12303. /** Value is a varying between vertex and fragment shaders */
  12304. Varying = 2,
  12305. /** Mode is undefined */
  12306. Undefined = 3
  12307. }
  12308. }
  12309. declare module BABYLON {
  12310. /**
  12311. * Enum used to define system values e.g. values automatically provided by the system
  12312. */
  12313. export enum NodeMaterialSystemValues {
  12314. /** World */
  12315. World = 1,
  12316. /** View */
  12317. View = 2,
  12318. /** Projection */
  12319. Projection = 3,
  12320. /** ViewProjection */
  12321. ViewProjection = 4,
  12322. /** WorldView */
  12323. WorldView = 5,
  12324. /** WorldViewProjection */
  12325. WorldViewProjection = 6,
  12326. /** CameraPosition */
  12327. CameraPosition = 7,
  12328. /** Fog Color */
  12329. FogColor = 8,
  12330. /** Delta time */
  12331. DeltaTime = 9
  12332. }
  12333. }
  12334. declare module BABYLON {
  12335. /**
  12336. * Represents a camera frustum
  12337. */
  12338. export class Frustum {
  12339. /**
  12340. * Gets the planes representing the frustum
  12341. * @param transform matrix to be applied to the returned planes
  12342. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12343. */
  12344. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12345. /**
  12346. * Gets the near frustum plane transformed by the transform matrix
  12347. * @param transform transformation matrix to be applied to the resulting frustum plane
  12348. * @param frustumPlane the resuling frustum plane
  12349. */
  12350. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12351. /**
  12352. * Gets the far frustum plane transformed by the transform matrix
  12353. * @param transform transformation matrix to be applied to the resulting frustum plane
  12354. * @param frustumPlane the resuling frustum plane
  12355. */
  12356. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12357. /**
  12358. * Gets the left frustum plane transformed by the transform matrix
  12359. * @param transform transformation matrix to be applied to the resulting frustum plane
  12360. * @param frustumPlane the resuling frustum plane
  12361. */
  12362. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12363. /**
  12364. * Gets the right frustum plane transformed by the transform matrix
  12365. * @param transform transformation matrix to be applied to the resulting frustum plane
  12366. * @param frustumPlane the resuling frustum plane
  12367. */
  12368. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12369. /**
  12370. * Gets the top frustum plane transformed by the transform matrix
  12371. * @param transform transformation matrix to be applied to the resulting frustum plane
  12372. * @param frustumPlane the resuling frustum plane
  12373. */
  12374. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12375. /**
  12376. * Gets the bottom frustum plane transformed by the transform matrix
  12377. * @param transform transformation matrix to be applied to the resulting frustum plane
  12378. * @param frustumPlane the resuling frustum plane
  12379. */
  12380. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12381. /**
  12382. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12383. * @param transform transformation matrix to be applied to the resulting frustum planes
  12384. * @param frustumPlanes the resuling frustum planes
  12385. */
  12386. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12387. }
  12388. }
  12389. declare module BABYLON {
  12390. /**
  12391. * Contains position and normal vectors for a vertex
  12392. */
  12393. export class PositionNormalVertex {
  12394. /** the position of the vertex (defaut: 0,0,0) */
  12395. position: Vector3;
  12396. /** the normal of the vertex (defaut: 0,1,0) */
  12397. normal: Vector3;
  12398. /**
  12399. * Creates a PositionNormalVertex
  12400. * @param position the position of the vertex (defaut: 0,0,0)
  12401. * @param normal the normal of the vertex (defaut: 0,1,0)
  12402. */
  12403. constructor(
  12404. /** the position of the vertex (defaut: 0,0,0) */
  12405. position?: Vector3,
  12406. /** the normal of the vertex (defaut: 0,1,0) */
  12407. normal?: Vector3);
  12408. /**
  12409. * Clones the PositionNormalVertex
  12410. * @returns the cloned PositionNormalVertex
  12411. */
  12412. clone(): PositionNormalVertex;
  12413. }
  12414. /**
  12415. * Contains position, normal and uv vectors for a vertex
  12416. */
  12417. export class PositionNormalTextureVertex {
  12418. /** the position of the vertex (defaut: 0,0,0) */
  12419. position: Vector3;
  12420. /** the normal of the vertex (defaut: 0,1,0) */
  12421. normal: Vector3;
  12422. /** the uv of the vertex (default: 0,0) */
  12423. uv: Vector2;
  12424. /**
  12425. * Creates a PositionNormalTextureVertex
  12426. * @param position the position of the vertex (defaut: 0,0,0)
  12427. * @param normal the normal of the vertex (defaut: 0,1,0)
  12428. * @param uv the uv of the vertex (default: 0,0)
  12429. */
  12430. constructor(
  12431. /** the position of the vertex (defaut: 0,0,0) */
  12432. position?: Vector3,
  12433. /** the normal of the vertex (defaut: 0,1,0) */
  12434. normal?: Vector3,
  12435. /** the uv of the vertex (default: 0,0) */
  12436. uv?: Vector2);
  12437. /**
  12438. * Clones the PositionNormalTextureVertex
  12439. * @returns the cloned PositionNormalTextureVertex
  12440. */
  12441. clone(): PositionNormalTextureVertex;
  12442. }
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Enum defining the type of animations supported by InputBlock
  12447. */
  12448. export enum AnimatedInputBlockTypes {
  12449. /** No animation */
  12450. None = 0,
  12451. /** Time based animation. Will only work for floats */
  12452. Time = 1
  12453. }
  12454. }
  12455. declare module BABYLON {
  12456. /**
  12457. * Block used to expose an input value
  12458. */
  12459. export class InputBlock extends NodeMaterialBlock {
  12460. private _mode;
  12461. private _associatedVariableName;
  12462. private _storedValue;
  12463. private _valueCallback;
  12464. private _type;
  12465. private _animationType;
  12466. /** Gets or set a value used to limit the range of float values */
  12467. min: number;
  12468. /** Gets or set a value used to limit the range of float values */
  12469. max: number;
  12470. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12471. isBoolean: boolean;
  12472. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12473. matrixMode: number;
  12474. /** @hidden */
  12475. _systemValue: Nullable<NodeMaterialSystemValues>;
  12476. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12477. isConstant: boolean;
  12478. /** Gets or sets the group to use to display this block in the Inspector */
  12479. groupInInspector: string;
  12480. /** Gets an observable raised when the value is changed */
  12481. onValueChangedObservable: Observable<InputBlock>;
  12482. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12483. convertToGammaSpace: boolean;
  12484. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12485. convertToLinearSpace: boolean;
  12486. /**
  12487. * Gets or sets the connection point type (default is float)
  12488. */
  12489. get type(): NodeMaterialBlockConnectionPointTypes;
  12490. /**
  12491. * Creates a new InputBlock
  12492. * @param name defines the block name
  12493. * @param target defines the target of that block (Vertex by default)
  12494. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12495. */
  12496. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12497. /**
  12498. * Validates if a name is a reserve word.
  12499. * @param newName the new name to be given to the node.
  12500. * @returns false if the name is a reserve word, else true.
  12501. */
  12502. validateBlockName(newName: string): boolean;
  12503. /**
  12504. * Gets the output component
  12505. */
  12506. get output(): NodeMaterialConnectionPoint;
  12507. /**
  12508. * Set the source of this connection point to a vertex attribute
  12509. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12510. * @returns the current connection point
  12511. */
  12512. setAsAttribute(attributeName?: string): InputBlock;
  12513. /**
  12514. * Set the source of this connection point to a system value
  12515. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12516. * @returns the current connection point
  12517. */
  12518. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12519. /**
  12520. * Gets or sets the value of that point.
  12521. * Please note that this value will be ignored if valueCallback is defined
  12522. */
  12523. get value(): any;
  12524. set value(value: any);
  12525. /**
  12526. * Gets or sets a callback used to get the value of that point.
  12527. * Please note that setting this value will force the connection point to ignore the value property
  12528. */
  12529. get valueCallback(): () => any;
  12530. set valueCallback(value: () => any);
  12531. /**
  12532. * Gets or sets the associated variable name in the shader
  12533. */
  12534. get associatedVariableName(): string;
  12535. set associatedVariableName(value: string);
  12536. /** Gets or sets the type of animation applied to the input */
  12537. get animationType(): AnimatedInputBlockTypes;
  12538. set animationType(value: AnimatedInputBlockTypes);
  12539. /**
  12540. * Gets a boolean indicating that this connection point not defined yet
  12541. */
  12542. get isUndefined(): boolean;
  12543. /**
  12544. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12545. * In this case the connection point name must be the name of the uniform to use.
  12546. * Can only be set on inputs
  12547. */
  12548. get isUniform(): boolean;
  12549. set isUniform(value: boolean);
  12550. /**
  12551. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12552. * In this case the connection point name must be the name of the attribute to use
  12553. * Can only be set on inputs
  12554. */
  12555. get isAttribute(): boolean;
  12556. set isAttribute(value: boolean);
  12557. /**
  12558. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12559. * Can only be set on exit points
  12560. */
  12561. get isVarying(): boolean;
  12562. set isVarying(value: boolean);
  12563. /**
  12564. * Gets a boolean indicating that the current connection point is a system value
  12565. */
  12566. get isSystemValue(): boolean;
  12567. /**
  12568. * Gets or sets the current well known value or null if not defined as a system value
  12569. */
  12570. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12571. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12572. /**
  12573. * Gets the current class name
  12574. * @returns the class name
  12575. */
  12576. getClassName(): string;
  12577. /**
  12578. * Animate the input if animationType !== None
  12579. * @param scene defines the rendering scene
  12580. */
  12581. animate(scene: Scene): void;
  12582. private _emitDefine;
  12583. initialize(state: NodeMaterialBuildState): void;
  12584. /**
  12585. * Set the input block to its default value (based on its type)
  12586. */
  12587. setDefaultValue(): void;
  12588. private _emitConstant;
  12589. /** @hidden */
  12590. get _noContextSwitch(): boolean;
  12591. private _emit;
  12592. /** @hidden */
  12593. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12594. /** @hidden */
  12595. _transmit(effect: Effect, scene: Scene): void;
  12596. protected _buildBlock(state: NodeMaterialBuildState): void;
  12597. protected _dumpPropertiesCode(): string;
  12598. dispose(): void;
  12599. serialize(): any;
  12600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12601. }
  12602. }
  12603. declare module BABYLON {
  12604. /**
  12605. * Enum used to define the compatibility state between two connection points
  12606. */
  12607. export enum NodeMaterialConnectionPointCompatibilityStates {
  12608. /** Points are compatibles */
  12609. Compatible = 0,
  12610. /** Points are incompatible because of their types */
  12611. TypeIncompatible = 1,
  12612. /** Points are incompatible because of their targets (vertex vs fragment) */
  12613. TargetIncompatible = 2
  12614. }
  12615. /**
  12616. * Defines the direction of a connection point
  12617. */
  12618. export enum NodeMaterialConnectionPointDirection {
  12619. /** Input */
  12620. Input = 0,
  12621. /** Output */
  12622. Output = 1
  12623. }
  12624. /**
  12625. * Defines a connection point for a block
  12626. */
  12627. export class NodeMaterialConnectionPoint {
  12628. /**
  12629. * Checks if two types are equivalent
  12630. * @param type1 type 1 to check
  12631. * @param type2 type 2 to check
  12632. * @returns true if both types are equivalent, else false
  12633. */
  12634. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12635. /** @hidden */
  12636. _ownerBlock: NodeMaterialBlock;
  12637. /** @hidden */
  12638. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12639. private _endpoints;
  12640. private _associatedVariableName;
  12641. private _direction;
  12642. /** @hidden */
  12643. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12644. /** @hidden */
  12645. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12646. /** @hidden */
  12647. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12648. private _type;
  12649. /** @hidden */
  12650. _enforceAssociatedVariableName: boolean;
  12651. /** Gets the direction of the point */
  12652. get direction(): NodeMaterialConnectionPointDirection;
  12653. /** Indicates that this connection point needs dual validation before being connected to another point */
  12654. needDualDirectionValidation: boolean;
  12655. /**
  12656. * Gets or sets the additional types supported by this connection point
  12657. */
  12658. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12659. /**
  12660. * Gets or sets the additional types excluded by this connection point
  12661. */
  12662. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12663. /**
  12664. * Observable triggered when this point is connected
  12665. */
  12666. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12667. /**
  12668. * Gets or sets the associated variable name in the shader
  12669. */
  12670. get associatedVariableName(): string;
  12671. set associatedVariableName(value: string);
  12672. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12673. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12674. /**
  12675. * Gets or sets the connection point type (default is float)
  12676. */
  12677. get type(): NodeMaterialBlockConnectionPointTypes;
  12678. set type(value: NodeMaterialBlockConnectionPointTypes);
  12679. /**
  12680. * Gets or sets the connection point name
  12681. */
  12682. name: string;
  12683. /**
  12684. * Gets or sets the connection point name
  12685. */
  12686. displayName: string;
  12687. /**
  12688. * Gets or sets a boolean indicating that this connection point can be omitted
  12689. */
  12690. isOptional: boolean;
  12691. /**
  12692. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12693. */
  12694. isExposedOnFrame: boolean;
  12695. /**
  12696. * Gets or sets number indicating the position that the port is exposed to on a frame
  12697. */
  12698. exposedPortPosition: number;
  12699. /**
  12700. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12701. */
  12702. define: string;
  12703. /** @hidden */
  12704. _prioritizeVertex: boolean;
  12705. private _target;
  12706. /** Gets or sets the target of that connection point */
  12707. get target(): NodeMaterialBlockTargets;
  12708. set target(value: NodeMaterialBlockTargets);
  12709. /**
  12710. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12711. */
  12712. get isConnected(): boolean;
  12713. /**
  12714. * Gets a boolean indicating that the current point is connected to an input block
  12715. */
  12716. get isConnectedToInputBlock(): boolean;
  12717. /**
  12718. * Gets a the connected input block (if any)
  12719. */
  12720. get connectInputBlock(): Nullable<InputBlock>;
  12721. /** Get the other side of the connection (if any) */
  12722. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12723. /** Get the block that owns this connection point */
  12724. get ownerBlock(): NodeMaterialBlock;
  12725. /** Get the block connected on the other side of this connection (if any) */
  12726. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12727. /** Get the block connected on the endpoints of this connection (if any) */
  12728. get connectedBlocks(): Array<NodeMaterialBlock>;
  12729. /** Gets the list of connected endpoints */
  12730. get endpoints(): NodeMaterialConnectionPoint[];
  12731. /** Gets a boolean indicating if that output point is connected to at least one input */
  12732. get hasEndpoints(): boolean;
  12733. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12734. get isConnectedInVertexShader(): boolean;
  12735. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12736. get isConnectedInFragmentShader(): boolean;
  12737. /**
  12738. * Creates a block suitable to be used as an input for this input point.
  12739. * If null is returned, a block based on the point type will be created.
  12740. * @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
  12741. */
  12742. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12743. /**
  12744. * Creates a new connection point
  12745. * @param name defines the connection point name
  12746. * @param ownerBlock defines the block hosting this connection point
  12747. * @param direction defines the direction of the connection point
  12748. */
  12749. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12750. /**
  12751. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets a boolean indicating if the current point can be connected to another point
  12757. * @param connectionPoint defines the other connection point
  12758. * @returns a boolean
  12759. */
  12760. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12761. /**
  12762. * Gets a number indicating if the current point can be connected to another point
  12763. * @param connectionPoint defines the other connection point
  12764. * @returns a number defining the compatibility state
  12765. */
  12766. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12767. /**
  12768. * Connect this point to another connection point
  12769. * @param connectionPoint defines the other connection point
  12770. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12771. * @returns the current connection point
  12772. */
  12773. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12774. /**
  12775. * Disconnect this point from one of his endpoint
  12776. * @param endpoint defines the other connection point
  12777. * @returns the current connection point
  12778. */
  12779. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12780. /**
  12781. * Serializes this point in a JSON representation
  12782. * @param isInput defines if the connection point is an input (default is true)
  12783. * @returns the serialized point object
  12784. */
  12785. serialize(isInput?: boolean): any;
  12786. /**
  12787. * Release resources
  12788. */
  12789. dispose(): void;
  12790. }
  12791. }
  12792. declare module BABYLON {
  12793. /**
  12794. * Enum used to define the material modes
  12795. */
  12796. export enum NodeMaterialModes {
  12797. /** Regular material */
  12798. Material = 0,
  12799. /** For post process */
  12800. PostProcess = 1,
  12801. /** For particle system */
  12802. Particle = 2,
  12803. /** For procedural texture */
  12804. ProceduralTexture = 3
  12805. }
  12806. }
  12807. declare module BABYLON {
  12808. /** @hidden */
  12809. export var helperFunctions: {
  12810. name: string;
  12811. shader: string;
  12812. };
  12813. }
  12814. declare module BABYLON {
  12815. /**
  12816. * Block used to read a texture from a sampler
  12817. */
  12818. export class TextureBlock extends NodeMaterialBlock {
  12819. private _defineName;
  12820. private _linearDefineName;
  12821. private _gammaDefineName;
  12822. private _tempTextureRead;
  12823. private _samplerName;
  12824. private _transformedUVName;
  12825. private _textureTransformName;
  12826. private _textureInfoName;
  12827. private _mainUVName;
  12828. private _mainUVDefineName;
  12829. private _fragmentOnly;
  12830. /**
  12831. * Gets or sets the texture associated with the node
  12832. */
  12833. texture: Nullable<Texture>;
  12834. /**
  12835. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12836. */
  12837. convertToGammaSpace: boolean;
  12838. /**
  12839. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12840. */
  12841. convertToLinearSpace: boolean;
  12842. /**
  12843. * Create a new TextureBlock
  12844. * @param name defines the block name
  12845. */
  12846. constructor(name: string, fragmentOnly?: boolean);
  12847. /**
  12848. * Gets the current class name
  12849. * @returns the class name
  12850. */
  12851. getClassName(): string;
  12852. /**
  12853. * Gets the uv input component
  12854. */
  12855. get uv(): NodeMaterialConnectionPoint;
  12856. /**
  12857. * Gets the rgba output component
  12858. */
  12859. get rgba(): NodeMaterialConnectionPoint;
  12860. /**
  12861. * Gets the rgb output component
  12862. */
  12863. get rgb(): NodeMaterialConnectionPoint;
  12864. /**
  12865. * Gets the r output component
  12866. */
  12867. get r(): NodeMaterialConnectionPoint;
  12868. /**
  12869. * Gets the g output component
  12870. */
  12871. get g(): NodeMaterialConnectionPoint;
  12872. /**
  12873. * Gets the b output component
  12874. */
  12875. get b(): NodeMaterialConnectionPoint;
  12876. /**
  12877. * Gets the a output component
  12878. */
  12879. get a(): NodeMaterialConnectionPoint;
  12880. get target(): NodeMaterialBlockTargets;
  12881. autoConfigure(material: NodeMaterial): void;
  12882. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12884. isReady(): boolean;
  12885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12886. private get _isMixed();
  12887. private _injectVertexCode;
  12888. private _writeTextureRead;
  12889. private _generateConversionCode;
  12890. private _writeOutput;
  12891. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12892. protected _dumpPropertiesCode(): string;
  12893. serialize(): any;
  12894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12895. }
  12896. }
  12897. declare module BABYLON {
  12898. /** @hidden */
  12899. export var reflectionFunction: {
  12900. name: string;
  12901. shader: string;
  12902. };
  12903. }
  12904. declare module BABYLON {
  12905. /**
  12906. * Base block used to read a reflection texture from a sampler
  12907. */
  12908. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12909. /** @hidden */
  12910. _define3DName: string;
  12911. /** @hidden */
  12912. _defineCubicName: string;
  12913. /** @hidden */
  12914. _defineExplicitName: string;
  12915. /** @hidden */
  12916. _defineProjectionName: string;
  12917. /** @hidden */
  12918. _defineLocalCubicName: string;
  12919. /** @hidden */
  12920. _defineSphericalName: string;
  12921. /** @hidden */
  12922. _definePlanarName: string;
  12923. /** @hidden */
  12924. _defineEquirectangularName: string;
  12925. /** @hidden */
  12926. _defineMirroredEquirectangularFixedName: string;
  12927. /** @hidden */
  12928. _defineEquirectangularFixedName: string;
  12929. /** @hidden */
  12930. _defineSkyboxName: string;
  12931. /** @hidden */
  12932. _defineOppositeZ: string;
  12933. /** @hidden */
  12934. _cubeSamplerName: string;
  12935. /** @hidden */
  12936. _2DSamplerName: string;
  12937. protected _positionUVWName: string;
  12938. protected _directionWName: string;
  12939. protected _reflectionVectorName: string;
  12940. /** @hidden */
  12941. _reflectionCoordsName: string;
  12942. /** @hidden */
  12943. _reflectionMatrixName: string;
  12944. protected _reflectionColorName: string;
  12945. /**
  12946. * Gets or sets the texture associated with the node
  12947. */
  12948. texture: Nullable<BaseTexture>;
  12949. /**
  12950. * Create a new ReflectionTextureBaseBlock
  12951. * @param name defines the block name
  12952. */
  12953. constructor(name: string);
  12954. /**
  12955. * Gets the current class name
  12956. * @returns the class name
  12957. */
  12958. getClassName(): string;
  12959. /**
  12960. * Gets the world position input component
  12961. */
  12962. abstract get position(): NodeMaterialConnectionPoint;
  12963. /**
  12964. * Gets the world position input component
  12965. */
  12966. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12967. /**
  12968. * Gets the world normal input component
  12969. */
  12970. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12971. /**
  12972. * Gets the world input component
  12973. */
  12974. abstract get world(): NodeMaterialConnectionPoint;
  12975. /**
  12976. * Gets the camera (or eye) position component
  12977. */
  12978. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12979. /**
  12980. * Gets the view input component
  12981. */
  12982. abstract get view(): NodeMaterialConnectionPoint;
  12983. protected _getTexture(): Nullable<BaseTexture>;
  12984. autoConfigure(material: NodeMaterial): void;
  12985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12986. isReady(): boolean;
  12987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12988. /**
  12989. * Gets the code to inject in the vertex shader
  12990. * @param state current state of the node material building
  12991. * @returns the shader code
  12992. */
  12993. handleVertexSide(state: NodeMaterialBuildState): string;
  12994. /**
  12995. * Handles the inits for the fragment code path
  12996. * @param state node material build state
  12997. */
  12998. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12999. /**
  13000. * Generates the reflection coords code for the fragment code path
  13001. * @param worldNormalVarName name of the world normal variable
  13002. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  13003. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  13004. * @returns the shader code
  13005. */
  13006. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  13007. /**
  13008. * Generates the reflection color code for the fragment code path
  13009. * @param lodVarName name of the lod variable
  13010. * @param swizzleLookupTexture swizzle to use for the final color variable
  13011. * @returns the shader code
  13012. */
  13013. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  13014. /**
  13015. * Generates the code corresponding to the connected output points
  13016. * @param state node material build state
  13017. * @param varName name of the variable to output
  13018. * @returns the shader code
  13019. */
  13020. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  13021. protected _buildBlock(state: NodeMaterialBuildState): this;
  13022. protected _dumpPropertiesCode(): string;
  13023. serialize(): any;
  13024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13025. }
  13026. }
  13027. declare module BABYLON {
  13028. /**
  13029. * Defines a connection point to be used for points with a custom object type
  13030. */
  13031. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  13032. private _blockType;
  13033. private _blockName;
  13034. private _nameForCheking?;
  13035. /**
  13036. * Creates a new connection point
  13037. * @param name defines the connection point name
  13038. * @param ownerBlock defines the block hosting this connection point
  13039. * @param direction defines the direction of the connection point
  13040. */
  13041. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  13042. /**
  13043. * Gets a number indicating if the current point can be connected to another point
  13044. * @param connectionPoint defines the other connection point
  13045. * @returns a number defining the compatibility state
  13046. */
  13047. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  13048. /**
  13049. * Creates a block suitable to be used as an input for this input point.
  13050. * If null is returned, a block based on the point type will be created.
  13051. * @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
  13052. */
  13053. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  13054. }
  13055. }
  13056. declare module BABYLON {
  13057. /**
  13058. * Enum defining the type of properties that can be edited in the property pages in the NME
  13059. */
  13060. export enum PropertyTypeForEdition {
  13061. /** property is a boolean */
  13062. Boolean = 0,
  13063. /** property is a float */
  13064. Float = 1,
  13065. /** property is a Vector2 */
  13066. Vector2 = 2,
  13067. /** property is a list of values */
  13068. List = 3
  13069. }
  13070. /**
  13071. * Interface that defines an option in a variable of type list
  13072. */
  13073. export interface IEditablePropertyListOption {
  13074. /** label of the option */
  13075. "label": string;
  13076. /** value of the option */
  13077. "value": number;
  13078. }
  13079. /**
  13080. * Interface that defines the options available for an editable property
  13081. */
  13082. export interface IEditablePropertyOption {
  13083. /** min value */
  13084. "min"?: number;
  13085. /** max value */
  13086. "max"?: number;
  13087. /** notifiers: indicates which actions to take when the property is changed */
  13088. "notifiers"?: {
  13089. /** the material should be rebuilt */
  13090. "rebuild"?: boolean;
  13091. /** the preview should be updated */
  13092. "update"?: boolean;
  13093. };
  13094. /** list of the options for a variable of type list */
  13095. "options"?: IEditablePropertyListOption[];
  13096. }
  13097. /**
  13098. * Interface that describes an editable property
  13099. */
  13100. export interface IPropertyDescriptionForEdition {
  13101. /** name of the property */
  13102. "propertyName": string;
  13103. /** display name of the property */
  13104. "displayName": string;
  13105. /** type of the property */
  13106. "type": PropertyTypeForEdition;
  13107. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13108. "groupName": string;
  13109. /** options for the property */
  13110. "options": IEditablePropertyOption;
  13111. }
  13112. /**
  13113. * Decorator that flags a property in a node material block as being editable
  13114. */
  13115. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13116. }
  13117. declare module BABYLON {
  13118. /**
  13119. * Block used to implement the refraction part of the sub surface module of the PBR material
  13120. */
  13121. export class RefractionBlock extends NodeMaterialBlock {
  13122. /** @hidden */
  13123. _define3DName: string;
  13124. /** @hidden */
  13125. _refractionMatrixName: string;
  13126. /** @hidden */
  13127. _defineLODRefractionAlpha: string;
  13128. /** @hidden */
  13129. _defineLinearSpecularRefraction: string;
  13130. /** @hidden */
  13131. _defineOppositeZ: string;
  13132. /** @hidden */
  13133. _cubeSamplerName: string;
  13134. /** @hidden */
  13135. _2DSamplerName: string;
  13136. /** @hidden */
  13137. _vRefractionMicrosurfaceInfosName: string;
  13138. /** @hidden */
  13139. _vRefractionInfosName: string;
  13140. /** @hidden */
  13141. _vRefractionFilteringInfoName: string;
  13142. private _scene;
  13143. /**
  13144. * The properties below are set by the main PBR block prior to calling methods of this class.
  13145. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13146. * It's less burden on the user side in the editor part.
  13147. */
  13148. /** @hidden */
  13149. viewConnectionPoint: NodeMaterialConnectionPoint;
  13150. /** @hidden */
  13151. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13152. /**
  13153. * This parameters will make the material used its opacity to control how much it is refracting against not.
  13154. * Materials half opaque for instance using refraction could benefit from this control.
  13155. */
  13156. linkRefractionWithTransparency: boolean;
  13157. /**
  13158. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13159. */
  13160. invertRefractionY: boolean;
  13161. /**
  13162. * Gets or sets the texture associated with the node
  13163. */
  13164. texture: Nullable<BaseTexture>;
  13165. /**
  13166. * Create a new RefractionBlock
  13167. * @param name defines the block name
  13168. */
  13169. constructor(name: string);
  13170. /**
  13171. * Gets the current class name
  13172. * @returns the class name
  13173. */
  13174. getClassName(): string;
  13175. /**
  13176. * Gets the intensity input component
  13177. */
  13178. get intensity(): NodeMaterialConnectionPoint;
  13179. /**
  13180. * Gets the tint at distance input component
  13181. */
  13182. get tintAtDistance(): NodeMaterialConnectionPoint;
  13183. /**
  13184. * Gets the view input component
  13185. */
  13186. get view(): NodeMaterialConnectionPoint;
  13187. /**
  13188. * Gets the refraction object output component
  13189. */
  13190. get refraction(): NodeMaterialConnectionPoint;
  13191. /**
  13192. * Returns true if the block has a texture
  13193. */
  13194. get hasTexture(): boolean;
  13195. protected _getTexture(): Nullable<BaseTexture>;
  13196. autoConfigure(material: NodeMaterial): void;
  13197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13198. isReady(): boolean;
  13199. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13200. /**
  13201. * Gets the main code of the block (fragment side)
  13202. * @param state current state of the node material building
  13203. * @returns the shader code
  13204. */
  13205. getCode(state: NodeMaterialBuildState): string;
  13206. protected _buildBlock(state: NodeMaterialBuildState): this;
  13207. protected _dumpPropertiesCode(): string;
  13208. serialize(): any;
  13209. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13210. }
  13211. }
  13212. declare module BABYLON {
  13213. /**
  13214. * Base block used as input for post process
  13215. */
  13216. export class CurrentScreenBlock extends NodeMaterialBlock {
  13217. private _samplerName;
  13218. private _linearDefineName;
  13219. private _gammaDefineName;
  13220. private _mainUVName;
  13221. private _tempTextureRead;
  13222. /**
  13223. * Gets or sets the texture associated with the node
  13224. */
  13225. texture: Nullable<BaseTexture>;
  13226. /**
  13227. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13228. */
  13229. convertToGammaSpace: boolean;
  13230. /**
  13231. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13232. */
  13233. convertToLinearSpace: boolean;
  13234. /**
  13235. * Create a new CurrentScreenBlock
  13236. * @param name defines the block name
  13237. */
  13238. constructor(name: string);
  13239. /**
  13240. * Gets the current class name
  13241. * @returns the class name
  13242. */
  13243. getClassName(): string;
  13244. /**
  13245. * Gets the uv input component
  13246. */
  13247. get uv(): NodeMaterialConnectionPoint;
  13248. /**
  13249. * Gets the rgba output component
  13250. */
  13251. get rgba(): NodeMaterialConnectionPoint;
  13252. /**
  13253. * Gets the rgb output component
  13254. */
  13255. get rgb(): NodeMaterialConnectionPoint;
  13256. /**
  13257. * Gets the r output component
  13258. */
  13259. get r(): NodeMaterialConnectionPoint;
  13260. /**
  13261. * Gets the g output component
  13262. */
  13263. get g(): NodeMaterialConnectionPoint;
  13264. /**
  13265. * Gets the b output component
  13266. */
  13267. get b(): NodeMaterialConnectionPoint;
  13268. /**
  13269. * Gets the a output component
  13270. */
  13271. get a(): NodeMaterialConnectionPoint;
  13272. /**
  13273. * Initialize the block and prepare the context for build
  13274. * @param state defines the state that will be used for the build
  13275. */
  13276. initialize(state: NodeMaterialBuildState): void;
  13277. get target(): NodeMaterialBlockTargets;
  13278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13279. isReady(): boolean;
  13280. private _injectVertexCode;
  13281. private _writeTextureRead;
  13282. private _writeOutput;
  13283. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13284. serialize(): any;
  13285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13286. }
  13287. }
  13288. declare module BABYLON {
  13289. /**
  13290. * Base block used for the particle texture
  13291. */
  13292. export class ParticleTextureBlock extends NodeMaterialBlock {
  13293. private _samplerName;
  13294. private _linearDefineName;
  13295. private _gammaDefineName;
  13296. private _tempTextureRead;
  13297. /**
  13298. * Gets or sets the texture associated with the node
  13299. */
  13300. texture: Nullable<BaseTexture>;
  13301. /**
  13302. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13303. */
  13304. convertToGammaSpace: boolean;
  13305. /**
  13306. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13307. */
  13308. convertToLinearSpace: boolean;
  13309. /**
  13310. * Create a new ParticleTextureBlock
  13311. * @param name defines the block name
  13312. */
  13313. constructor(name: string);
  13314. /**
  13315. * Gets the current class name
  13316. * @returns the class name
  13317. */
  13318. getClassName(): string;
  13319. /**
  13320. * Gets the uv input component
  13321. */
  13322. get uv(): NodeMaterialConnectionPoint;
  13323. /**
  13324. * Gets the rgba output component
  13325. */
  13326. get rgba(): NodeMaterialConnectionPoint;
  13327. /**
  13328. * Gets the rgb output component
  13329. */
  13330. get rgb(): NodeMaterialConnectionPoint;
  13331. /**
  13332. * Gets the r output component
  13333. */
  13334. get r(): NodeMaterialConnectionPoint;
  13335. /**
  13336. * Gets the g output component
  13337. */
  13338. get g(): NodeMaterialConnectionPoint;
  13339. /**
  13340. * Gets the b output component
  13341. */
  13342. get b(): NodeMaterialConnectionPoint;
  13343. /**
  13344. * Gets the a output component
  13345. */
  13346. get a(): NodeMaterialConnectionPoint;
  13347. /**
  13348. * Initialize the block and prepare the context for build
  13349. * @param state defines the state that will be used for the build
  13350. */
  13351. initialize(state: NodeMaterialBuildState): void;
  13352. autoConfigure(material: NodeMaterial): void;
  13353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13354. isReady(): boolean;
  13355. private _writeOutput;
  13356. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13357. serialize(): any;
  13358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13359. }
  13360. }
  13361. declare module BABYLON {
  13362. /**
  13363. * Class used to store shared data between 2 NodeMaterialBuildState
  13364. */
  13365. export class NodeMaterialBuildStateSharedData {
  13366. /**
  13367. * Gets the list of emitted varyings
  13368. */
  13369. temps: string[];
  13370. /**
  13371. * Gets the list of emitted varyings
  13372. */
  13373. varyings: string[];
  13374. /**
  13375. * Gets the varying declaration string
  13376. */
  13377. varyingDeclaration: string;
  13378. /**
  13379. * Input blocks
  13380. */
  13381. inputBlocks: InputBlock[];
  13382. /**
  13383. * Input blocks
  13384. */
  13385. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13386. /**
  13387. * Bindable blocks (Blocks that need to set data to the effect)
  13388. */
  13389. bindableBlocks: NodeMaterialBlock[];
  13390. /**
  13391. * List of blocks that can provide a compilation fallback
  13392. */
  13393. blocksWithFallbacks: NodeMaterialBlock[];
  13394. /**
  13395. * List of blocks that can provide a define update
  13396. */
  13397. blocksWithDefines: NodeMaterialBlock[];
  13398. /**
  13399. * List of blocks that can provide a repeatable content
  13400. */
  13401. repeatableContentBlocks: NodeMaterialBlock[];
  13402. /**
  13403. * List of blocks that can provide a dynamic list of uniforms
  13404. */
  13405. dynamicUniformBlocks: NodeMaterialBlock[];
  13406. /**
  13407. * List of blocks that can block the isReady function for the material
  13408. */
  13409. blockingBlocks: NodeMaterialBlock[];
  13410. /**
  13411. * Gets the list of animated inputs
  13412. */
  13413. animatedInputs: InputBlock[];
  13414. /**
  13415. * Build Id used to avoid multiple recompilations
  13416. */
  13417. buildId: number;
  13418. /** List of emitted variables */
  13419. variableNames: {
  13420. [key: string]: number;
  13421. };
  13422. /** List of emitted defines */
  13423. defineNames: {
  13424. [key: string]: number;
  13425. };
  13426. /** Should emit comments? */
  13427. emitComments: boolean;
  13428. /** Emit build activity */
  13429. verbose: boolean;
  13430. /** Gets or sets the hosting scene */
  13431. scene: Scene;
  13432. /**
  13433. * Gets the compilation hints emitted at compilation time
  13434. */
  13435. hints: {
  13436. needWorldViewMatrix: boolean;
  13437. needWorldViewProjectionMatrix: boolean;
  13438. needAlphaBlending: boolean;
  13439. needAlphaTesting: boolean;
  13440. };
  13441. /**
  13442. * List of compilation checks
  13443. */
  13444. checks: {
  13445. emitVertex: boolean;
  13446. emitFragment: boolean;
  13447. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13448. };
  13449. /**
  13450. * Is vertex program allowed to be empty?
  13451. */
  13452. allowEmptyVertexProgram: boolean;
  13453. /** Creates a new shared data */
  13454. constructor();
  13455. /**
  13456. * Emits console errors and exceptions if there is a failing check
  13457. */
  13458. emitErrors(): void;
  13459. }
  13460. }
  13461. declare module BABYLON {
  13462. /**
  13463. * Class used to store node based material build state
  13464. */
  13465. export class NodeMaterialBuildState {
  13466. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13467. supportUniformBuffers: boolean;
  13468. /**
  13469. * Gets the list of emitted attributes
  13470. */
  13471. attributes: string[];
  13472. /**
  13473. * Gets the list of emitted uniforms
  13474. */
  13475. uniforms: string[];
  13476. /**
  13477. * Gets the list of emitted constants
  13478. */
  13479. constants: string[];
  13480. /**
  13481. * Gets the list of emitted samplers
  13482. */
  13483. samplers: string[];
  13484. /**
  13485. * Gets the list of emitted functions
  13486. */
  13487. functions: {
  13488. [key: string]: string;
  13489. };
  13490. /**
  13491. * Gets the list of emitted extensions
  13492. */
  13493. extensions: {
  13494. [key: string]: string;
  13495. };
  13496. /**
  13497. * Gets the target of the compilation state
  13498. */
  13499. target: NodeMaterialBlockTargets;
  13500. /**
  13501. * Gets the list of emitted counters
  13502. */
  13503. counters: {
  13504. [key: string]: number;
  13505. };
  13506. /**
  13507. * Shared data between multiple NodeMaterialBuildState instances
  13508. */
  13509. sharedData: NodeMaterialBuildStateSharedData;
  13510. /** @hidden */
  13511. _vertexState: NodeMaterialBuildState;
  13512. /** @hidden */
  13513. _attributeDeclaration: string;
  13514. /** @hidden */
  13515. _uniformDeclaration: string;
  13516. /** @hidden */
  13517. _constantDeclaration: string;
  13518. /** @hidden */
  13519. _samplerDeclaration: string;
  13520. /** @hidden */
  13521. _varyingTransfer: string;
  13522. /** @hidden */
  13523. _injectAtEnd: string;
  13524. private _repeatableContentAnchorIndex;
  13525. /** @hidden */
  13526. _builtCompilationString: string;
  13527. /**
  13528. * Gets the emitted compilation strings
  13529. */
  13530. compilationString: string;
  13531. /**
  13532. * Finalize the compilation strings
  13533. * @param state defines the current compilation state
  13534. */
  13535. finalize(state: NodeMaterialBuildState): void;
  13536. /** @hidden */
  13537. get _repeatableContentAnchor(): string;
  13538. /** @hidden */
  13539. _getFreeVariableName(prefix: string): string;
  13540. /** @hidden */
  13541. _getFreeDefineName(prefix: string): string;
  13542. /** @hidden */
  13543. _excludeVariableName(name: string): void;
  13544. /** @hidden */
  13545. _emit2DSampler(name: string): void;
  13546. /** @hidden */
  13547. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13548. /** @hidden */
  13549. _emitExtension(name: string, extension: string, define?: string): void;
  13550. /** @hidden */
  13551. _emitFunction(name: string, code: string, comments: string): void;
  13552. /** @hidden */
  13553. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13554. replaceStrings?: {
  13555. search: RegExp;
  13556. replace: string;
  13557. }[];
  13558. repeatKey?: string;
  13559. }): string;
  13560. /** @hidden */
  13561. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13562. repeatKey?: string;
  13563. removeAttributes?: boolean;
  13564. removeUniforms?: boolean;
  13565. removeVaryings?: boolean;
  13566. removeIfDef?: boolean;
  13567. replaceStrings?: {
  13568. search: RegExp;
  13569. replace: string;
  13570. }[];
  13571. }, storeKey?: string): void;
  13572. /** @hidden */
  13573. _registerTempVariable(name: string): boolean;
  13574. /** @hidden */
  13575. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13576. /** @hidden */
  13577. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13578. /** @hidden */
  13579. _emitFloat(value: number): string;
  13580. }
  13581. }
  13582. declare module BABYLON {
  13583. /**
  13584. * Helper class used to generate session unique ID
  13585. */
  13586. export class UniqueIdGenerator {
  13587. private static _UniqueIdCounter;
  13588. /**
  13589. * Gets an unique (relatively to the current scene) Id
  13590. */
  13591. static get UniqueId(): number;
  13592. }
  13593. }
  13594. declare module BABYLON {
  13595. /**
  13596. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13597. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13598. */
  13599. export class EffectFallbacks implements IEffectFallbacks {
  13600. private _defines;
  13601. private _currentRank;
  13602. private _maxRank;
  13603. private _mesh;
  13604. /**
  13605. * Removes the fallback from the bound mesh.
  13606. */
  13607. unBindMesh(): void;
  13608. /**
  13609. * Adds a fallback on the specified property.
  13610. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13611. * @param define The name of the define in the shader
  13612. */
  13613. addFallback(rank: number, define: string): void;
  13614. /**
  13615. * Sets the mesh to use CPU skinning when needing to fallback.
  13616. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13617. * @param mesh The mesh to use the fallbacks.
  13618. */
  13619. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13620. /**
  13621. * Checks to see if more fallbacks are still available.
  13622. */
  13623. get hasMoreFallbacks(): boolean;
  13624. /**
  13625. * Removes the defines that should be removed when falling back.
  13626. * @param currentDefines defines the current define statements for the shader.
  13627. * @param effect defines the current effect we try to compile
  13628. * @returns The resulting defines with defines of the current rank removed.
  13629. */
  13630. reduce(currentDefines: string, effect: Effect): string;
  13631. }
  13632. }
  13633. declare module BABYLON {
  13634. /**
  13635. * Defines a block that can be used inside a node based material
  13636. */
  13637. export class NodeMaterialBlock {
  13638. private _buildId;
  13639. private _buildTarget;
  13640. private _target;
  13641. private _isFinalMerger;
  13642. private _isInput;
  13643. private _name;
  13644. protected _isUnique: boolean;
  13645. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13646. inputsAreExclusive: boolean;
  13647. /** @hidden */
  13648. _codeVariableName: string;
  13649. /** @hidden */
  13650. _inputs: NodeMaterialConnectionPoint[];
  13651. /** @hidden */
  13652. _outputs: NodeMaterialConnectionPoint[];
  13653. /** @hidden */
  13654. _preparationId: number;
  13655. /** @hidden */
  13656. readonly _originalTargetIsNeutral: boolean;
  13657. /**
  13658. * Gets the name of the block
  13659. */
  13660. get name(): string;
  13661. /**
  13662. * Sets the name of the block. Will check if the name is valid.
  13663. */
  13664. set name(newName: string);
  13665. /**
  13666. * Gets or sets the unique id of the node
  13667. */
  13668. uniqueId: number;
  13669. /**
  13670. * Gets or sets the comments associated with this block
  13671. */
  13672. comments: string;
  13673. /**
  13674. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13675. */
  13676. get isUnique(): boolean;
  13677. /**
  13678. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13679. */
  13680. get isFinalMerger(): boolean;
  13681. /**
  13682. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13683. */
  13684. get isInput(): boolean;
  13685. /**
  13686. * Gets or sets the build Id
  13687. */
  13688. get buildId(): number;
  13689. set buildId(value: number);
  13690. /**
  13691. * Gets or sets the target of the block
  13692. */
  13693. get target(): NodeMaterialBlockTargets;
  13694. set target(value: NodeMaterialBlockTargets);
  13695. /**
  13696. * Gets the list of input points
  13697. */
  13698. get inputs(): NodeMaterialConnectionPoint[];
  13699. /** Gets the list of output points */
  13700. get outputs(): NodeMaterialConnectionPoint[];
  13701. /**
  13702. * Find an input by its name
  13703. * @param name defines the name of the input to look for
  13704. * @returns the input or null if not found
  13705. */
  13706. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13707. /**
  13708. * Find an output by its name
  13709. * @param name defines the name of the output to look for
  13710. * @returns the output or null if not found
  13711. */
  13712. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13713. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13714. visibleInInspector: boolean;
  13715. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13716. visibleOnFrame: boolean;
  13717. /**
  13718. * Creates a new NodeMaterialBlock
  13719. * @param name defines the block name
  13720. * @param target defines the target of that block (Vertex by default)
  13721. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13722. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13723. */
  13724. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13725. /**
  13726. * Initialize the block and prepare the context for build
  13727. * @param state defines the state that will be used for the build
  13728. */
  13729. initialize(state: NodeMaterialBuildState): void;
  13730. /**
  13731. * Bind data to effect. Will only be called for blocks with isBindable === true
  13732. * @param effect defines the effect to bind data to
  13733. * @param nodeMaterial defines the hosting NodeMaterial
  13734. * @param mesh defines the mesh that will be rendered
  13735. * @param subMesh defines the submesh that will be rendered
  13736. */
  13737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13738. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13739. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13740. protected _writeFloat(value: number): string;
  13741. /**
  13742. * Gets the current class name e.g. "NodeMaterialBlock"
  13743. * @returns the class name
  13744. */
  13745. getClassName(): string;
  13746. /**
  13747. * Register a new input. Must be called inside a block constructor
  13748. * @param name defines the connection point name
  13749. * @param type defines the connection point type
  13750. * @param isOptional defines a boolean indicating that this input can be omitted
  13751. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13752. * @param point an already created connection point. If not provided, create a new one
  13753. * @returns the current block
  13754. */
  13755. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13756. /**
  13757. * Register a new output. Must be called inside a block constructor
  13758. * @param name defines the connection point name
  13759. * @param type defines the connection point type
  13760. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13761. * @param point an already created connection point. If not provided, create a new one
  13762. * @returns the current block
  13763. */
  13764. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13765. /**
  13766. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13767. * @param forOutput defines an optional connection point to check compatibility with
  13768. * @returns the first available input or null
  13769. */
  13770. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13771. /**
  13772. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13773. * @param forBlock defines an optional block to check compatibility with
  13774. * @returns the first available input or null
  13775. */
  13776. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13777. /**
  13778. * Gets the sibling of the given output
  13779. * @param current defines the current output
  13780. * @returns the next output in the list or null
  13781. */
  13782. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13783. /**
  13784. * Connect current block with another block
  13785. * @param other defines the block to connect with
  13786. * @param options define the various options to help pick the right connections
  13787. * @returns the current block
  13788. */
  13789. connectTo(other: NodeMaterialBlock, options?: {
  13790. input?: string;
  13791. output?: string;
  13792. outputSwizzle?: string;
  13793. }): this | undefined;
  13794. protected _buildBlock(state: NodeMaterialBuildState): void;
  13795. /**
  13796. * Add uniforms, samplers and uniform buffers at compilation time
  13797. * @param state defines the state to update
  13798. * @param nodeMaterial defines the node material requesting the update
  13799. * @param defines defines the material defines to update
  13800. * @param uniformBuffers defines the list of uniform buffer names
  13801. */
  13802. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13803. /**
  13804. * Add potential fallbacks if shader compilation fails
  13805. * @param mesh defines the mesh to be rendered
  13806. * @param fallbacks defines the current prioritized list of fallbacks
  13807. */
  13808. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13809. /**
  13810. * Initialize defines for shader compilation
  13811. * @param mesh defines the mesh to be rendered
  13812. * @param nodeMaterial defines the node material requesting the update
  13813. * @param defines defines the material defines to update
  13814. * @param useInstances specifies that instances should be used
  13815. */
  13816. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13817. /**
  13818. * Update defines for shader compilation
  13819. * @param mesh defines the mesh to be rendered
  13820. * @param nodeMaterial defines the node material requesting the update
  13821. * @param defines defines the material defines to update
  13822. * @param useInstances specifies that instances should be used
  13823. * @param subMesh defines which submesh to render
  13824. */
  13825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13826. /**
  13827. * Lets the block try to connect some inputs automatically
  13828. * @param material defines the hosting NodeMaterial
  13829. */
  13830. autoConfigure(material: NodeMaterial): void;
  13831. /**
  13832. * Function called when a block is declared as repeatable content generator
  13833. * @param vertexShaderState defines the current compilation state for the vertex shader
  13834. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13835. * @param mesh defines the mesh to be rendered
  13836. * @param defines defines the material defines to update
  13837. */
  13838. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13839. /**
  13840. * Checks if the block is ready
  13841. * @param mesh defines the mesh to be rendered
  13842. * @param nodeMaterial defines the node material requesting the update
  13843. * @param defines defines the material defines to update
  13844. * @param useInstances specifies that instances should be used
  13845. * @returns true if the block is ready
  13846. */
  13847. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13848. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13849. private _processBuild;
  13850. /**
  13851. * Validates the new name for the block node.
  13852. * @param newName the new name to be given to the node.
  13853. * @returns false if the name is a reserve word, else true.
  13854. */
  13855. validateBlockName(newName: string): boolean;
  13856. /**
  13857. * Compile the current node and generate the shader code
  13858. * @param state defines the current compilation state (uniforms, samplers, current string)
  13859. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13860. * @returns true if already built
  13861. */
  13862. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13863. protected _inputRename(name: string): string;
  13864. protected _outputRename(name: string): string;
  13865. protected _dumpPropertiesCode(): string;
  13866. /** @hidden */
  13867. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13868. /** @hidden */
  13869. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13870. /**
  13871. * Clone the current block to a new identical block
  13872. * @param scene defines the hosting scene
  13873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13874. * @returns a copy of the current block
  13875. */
  13876. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13877. /**
  13878. * Serializes this block in a JSON representation
  13879. * @returns the serialized block object
  13880. */
  13881. serialize(): any;
  13882. /** @hidden */
  13883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13884. private _deserializePortDisplayNamesAndExposedOnFrame;
  13885. /**
  13886. * Release resources
  13887. */
  13888. dispose(): void;
  13889. }
  13890. }
  13891. declare module BABYLON {
  13892. /**
  13893. * Base class of materials working in push mode in babylon JS
  13894. * @hidden
  13895. */
  13896. export class PushMaterial extends Material {
  13897. protected _activeEffect: Effect;
  13898. protected _normalMatrix: Matrix;
  13899. constructor(name: string, scene: Scene);
  13900. getEffect(): Effect;
  13901. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13902. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13903. /**
  13904. * Binds the given world matrix to the active effect
  13905. *
  13906. * @param world the matrix to bind
  13907. */
  13908. bindOnlyWorldMatrix(world: Matrix): void;
  13909. /**
  13910. * Binds the given normal matrix to the active effect
  13911. *
  13912. * @param normalMatrix the matrix to bind
  13913. */
  13914. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13915. bind(world: Matrix, mesh?: Mesh): void;
  13916. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13917. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13918. }
  13919. }
  13920. declare module BABYLON {
  13921. /**
  13922. * Root class for all node material optimizers
  13923. */
  13924. export class NodeMaterialOptimizer {
  13925. /**
  13926. * Function used to optimize a NodeMaterial graph
  13927. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13928. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13929. */
  13930. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13936. */
  13937. export class TransformBlock extends NodeMaterialBlock {
  13938. /**
  13939. * Defines the value to use to complement W value to transform it to a Vector4
  13940. */
  13941. complementW: number;
  13942. /**
  13943. * Defines the value to use to complement z value to transform it to a Vector4
  13944. */
  13945. complementZ: number;
  13946. /**
  13947. * Creates a new TransformBlock
  13948. * @param name defines the block name
  13949. */
  13950. constructor(name: string);
  13951. /**
  13952. * Gets the current class name
  13953. * @returns the class name
  13954. */
  13955. getClassName(): string;
  13956. /**
  13957. * Gets the vector input
  13958. */
  13959. get vector(): NodeMaterialConnectionPoint;
  13960. /**
  13961. * Gets the output component
  13962. */
  13963. get output(): NodeMaterialConnectionPoint;
  13964. /**
  13965. * Gets the xyz output component
  13966. */
  13967. get xyz(): NodeMaterialConnectionPoint;
  13968. /**
  13969. * Gets the matrix transform input
  13970. */
  13971. get transform(): NodeMaterialConnectionPoint;
  13972. protected _buildBlock(state: NodeMaterialBuildState): this;
  13973. /**
  13974. * Update defines for shader compilation
  13975. * @param mesh defines the mesh to be rendered
  13976. * @param nodeMaterial defines the node material requesting the update
  13977. * @param defines defines the material defines to update
  13978. * @param useInstances specifies that instances should be used
  13979. * @param subMesh defines which submesh to render
  13980. */
  13981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13982. serialize(): any;
  13983. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13984. protected _dumpPropertiesCode(): string;
  13985. }
  13986. }
  13987. declare module BABYLON {
  13988. /**
  13989. * Block used to output the vertex position
  13990. */
  13991. export class VertexOutputBlock extends NodeMaterialBlock {
  13992. /**
  13993. * Creates a new VertexOutputBlock
  13994. * @param name defines the block name
  13995. */
  13996. constructor(name: string);
  13997. /**
  13998. * Gets the current class name
  13999. * @returns the class name
  14000. */
  14001. getClassName(): string;
  14002. /**
  14003. * Gets the vector input component
  14004. */
  14005. get vector(): NodeMaterialConnectionPoint;
  14006. protected _buildBlock(state: NodeMaterialBuildState): this;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Block used to output the final color
  14012. */
  14013. export class FragmentOutputBlock extends NodeMaterialBlock {
  14014. /**
  14015. * Create a new FragmentOutputBlock
  14016. * @param name defines the block name
  14017. */
  14018. constructor(name: string);
  14019. /**
  14020. * Gets the current class name
  14021. * @returns the class name
  14022. */
  14023. getClassName(): string;
  14024. /**
  14025. * Gets the rgba input component
  14026. */
  14027. get rgba(): NodeMaterialConnectionPoint;
  14028. /**
  14029. * Gets the rgb input component
  14030. */
  14031. get rgb(): NodeMaterialConnectionPoint;
  14032. /**
  14033. * Gets the a input component
  14034. */
  14035. get a(): NodeMaterialConnectionPoint;
  14036. protected _buildBlock(state: NodeMaterialBuildState): this;
  14037. }
  14038. }
  14039. declare module BABYLON {
  14040. /**
  14041. * Block used for the particle ramp gradient section
  14042. */
  14043. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  14044. /**
  14045. * Create a new ParticleRampGradientBlock
  14046. * @param name defines the block name
  14047. */
  14048. constructor(name: string);
  14049. /**
  14050. * Gets the current class name
  14051. * @returns the class name
  14052. */
  14053. getClassName(): string;
  14054. /**
  14055. * Gets the color input component
  14056. */
  14057. get color(): NodeMaterialConnectionPoint;
  14058. /**
  14059. * Gets the rampColor output component
  14060. */
  14061. get rampColor(): NodeMaterialConnectionPoint;
  14062. /**
  14063. * Initialize the block and prepare the context for build
  14064. * @param state defines the state that will be used for the build
  14065. */
  14066. initialize(state: NodeMaterialBuildState): void;
  14067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14068. }
  14069. }
  14070. declare module BABYLON {
  14071. /**
  14072. * Block used for the particle blend multiply section
  14073. */
  14074. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  14075. /**
  14076. * Create a new ParticleBlendMultiplyBlock
  14077. * @param name defines the block name
  14078. */
  14079. constructor(name: string);
  14080. /**
  14081. * Gets the current class name
  14082. * @returns the class name
  14083. */
  14084. getClassName(): string;
  14085. /**
  14086. * Gets the color input component
  14087. */
  14088. get color(): NodeMaterialConnectionPoint;
  14089. /**
  14090. * Gets the alphaTexture input component
  14091. */
  14092. get alphaTexture(): NodeMaterialConnectionPoint;
  14093. /**
  14094. * Gets the alphaColor input component
  14095. */
  14096. get alphaColor(): NodeMaterialConnectionPoint;
  14097. /**
  14098. * Gets the blendColor output component
  14099. */
  14100. get blendColor(): NodeMaterialConnectionPoint;
  14101. /**
  14102. * Initialize the block and prepare the context for build
  14103. * @param state defines the state that will be used for the build
  14104. */
  14105. initialize(state: NodeMaterialBuildState): void;
  14106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14107. }
  14108. }
  14109. declare module BABYLON {
  14110. /**
  14111. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14112. */
  14113. export class VectorMergerBlock extends NodeMaterialBlock {
  14114. /**
  14115. * Create a new VectorMergerBlock
  14116. * @param name defines the block name
  14117. */
  14118. constructor(name: string);
  14119. /**
  14120. * Gets the current class name
  14121. * @returns the class name
  14122. */
  14123. getClassName(): string;
  14124. /**
  14125. * Gets the xyz component (input)
  14126. */
  14127. get xyzIn(): NodeMaterialConnectionPoint;
  14128. /**
  14129. * Gets the xy component (input)
  14130. */
  14131. get xyIn(): NodeMaterialConnectionPoint;
  14132. /**
  14133. * Gets the x component (input)
  14134. */
  14135. get x(): NodeMaterialConnectionPoint;
  14136. /**
  14137. * Gets the y component (input)
  14138. */
  14139. get y(): NodeMaterialConnectionPoint;
  14140. /**
  14141. * Gets the z component (input)
  14142. */
  14143. get z(): NodeMaterialConnectionPoint;
  14144. /**
  14145. * Gets the w component (input)
  14146. */
  14147. get w(): NodeMaterialConnectionPoint;
  14148. /**
  14149. * Gets the xyzw component (output)
  14150. */
  14151. get xyzw(): NodeMaterialConnectionPoint;
  14152. /**
  14153. * Gets the xyz component (output)
  14154. */
  14155. get xyzOut(): NodeMaterialConnectionPoint;
  14156. /**
  14157. * Gets the xy component (output)
  14158. */
  14159. get xyOut(): NodeMaterialConnectionPoint;
  14160. /**
  14161. * Gets the xy component (output)
  14162. * @deprecated Please use xyOut instead.
  14163. */
  14164. get xy(): NodeMaterialConnectionPoint;
  14165. /**
  14166. * Gets the xyz component (output)
  14167. * @deprecated Please use xyzOut instead.
  14168. */
  14169. get xyz(): NodeMaterialConnectionPoint;
  14170. protected _buildBlock(state: NodeMaterialBuildState): this;
  14171. }
  14172. }
  14173. declare module BABYLON {
  14174. /**
  14175. * Block used to remap a float from a range to a new one
  14176. */
  14177. export class RemapBlock extends NodeMaterialBlock {
  14178. /**
  14179. * Gets or sets the source range
  14180. */
  14181. sourceRange: Vector2;
  14182. /**
  14183. * Gets or sets the target range
  14184. */
  14185. targetRange: Vector2;
  14186. /**
  14187. * Creates a new RemapBlock
  14188. * @param name defines the block name
  14189. */
  14190. constructor(name: string);
  14191. /**
  14192. * Gets the current class name
  14193. * @returns the class name
  14194. */
  14195. getClassName(): string;
  14196. /**
  14197. * Gets the input component
  14198. */
  14199. get input(): NodeMaterialConnectionPoint;
  14200. /**
  14201. * Gets the source min input component
  14202. */
  14203. get sourceMin(): NodeMaterialConnectionPoint;
  14204. /**
  14205. * Gets the source max input component
  14206. */
  14207. get sourceMax(): NodeMaterialConnectionPoint;
  14208. /**
  14209. * Gets the target min input component
  14210. */
  14211. get targetMin(): NodeMaterialConnectionPoint;
  14212. /**
  14213. * Gets the target max input component
  14214. */
  14215. get targetMax(): NodeMaterialConnectionPoint;
  14216. /**
  14217. * Gets the output component
  14218. */
  14219. get output(): NodeMaterialConnectionPoint;
  14220. protected _buildBlock(state: NodeMaterialBuildState): this;
  14221. protected _dumpPropertiesCode(): string;
  14222. serialize(): any;
  14223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14224. }
  14225. }
  14226. declare module BABYLON {
  14227. /**
  14228. * Block used to multiply 2 values
  14229. */
  14230. export class MultiplyBlock extends NodeMaterialBlock {
  14231. /**
  14232. * Creates a new MultiplyBlock
  14233. * @param name defines the block name
  14234. */
  14235. constructor(name: string);
  14236. /**
  14237. * Gets the current class name
  14238. * @returns the class name
  14239. */
  14240. getClassName(): string;
  14241. /**
  14242. * Gets the left operand input component
  14243. */
  14244. get left(): NodeMaterialConnectionPoint;
  14245. /**
  14246. * Gets the right operand input component
  14247. */
  14248. get right(): NodeMaterialConnectionPoint;
  14249. /**
  14250. * Gets the output component
  14251. */
  14252. get output(): NodeMaterialConnectionPoint;
  14253. protected _buildBlock(state: NodeMaterialBuildState): this;
  14254. }
  14255. }
  14256. declare module BABYLON {
  14257. /** Interface used by value gradients (color, factor, ...) */
  14258. export interface IValueGradient {
  14259. /**
  14260. * Gets or sets the gradient value (between 0 and 1)
  14261. */
  14262. gradient: number;
  14263. }
  14264. /** Class used to store color4 gradient */
  14265. export class ColorGradient implements IValueGradient {
  14266. /**
  14267. * Gets or sets the gradient value (between 0 and 1)
  14268. */
  14269. gradient: number;
  14270. /**
  14271. * Gets or sets first associated color
  14272. */
  14273. color1: Color4;
  14274. /**
  14275. * Gets or sets second associated color
  14276. */
  14277. color2?: Color4 | undefined;
  14278. /**
  14279. * Creates a new color4 gradient
  14280. * @param gradient gets or sets the gradient value (between 0 and 1)
  14281. * @param color1 gets or sets first associated color
  14282. * @param color2 gets or sets first second color
  14283. */
  14284. constructor(
  14285. /**
  14286. * Gets or sets the gradient value (between 0 and 1)
  14287. */
  14288. gradient: number,
  14289. /**
  14290. * Gets or sets first associated color
  14291. */
  14292. color1: Color4,
  14293. /**
  14294. * Gets or sets second associated color
  14295. */
  14296. color2?: Color4 | undefined);
  14297. /**
  14298. * Will get a color picked randomly between color1 and color2.
  14299. * If color2 is undefined then color1 will be used
  14300. * @param result defines the target Color4 to store the result in
  14301. */
  14302. getColorToRef(result: Color4): void;
  14303. }
  14304. /** Class used to store color 3 gradient */
  14305. export class Color3Gradient implements IValueGradient {
  14306. /**
  14307. * Gets or sets the gradient value (between 0 and 1)
  14308. */
  14309. gradient: number;
  14310. /**
  14311. * Gets or sets the associated color
  14312. */
  14313. color: Color3;
  14314. /**
  14315. * Creates a new color3 gradient
  14316. * @param gradient gets or sets the gradient value (between 0 and 1)
  14317. * @param color gets or sets associated color
  14318. */
  14319. constructor(
  14320. /**
  14321. * Gets or sets the gradient value (between 0 and 1)
  14322. */
  14323. gradient: number,
  14324. /**
  14325. * Gets or sets the associated color
  14326. */
  14327. color: Color3);
  14328. }
  14329. /** Class used to store factor gradient */
  14330. export class FactorGradient implements IValueGradient {
  14331. /**
  14332. * Gets or sets the gradient value (between 0 and 1)
  14333. */
  14334. gradient: number;
  14335. /**
  14336. * Gets or sets first associated factor
  14337. */
  14338. factor1: number;
  14339. /**
  14340. * Gets or sets second associated factor
  14341. */
  14342. factor2?: number | undefined;
  14343. /**
  14344. * Creates a new factor gradient
  14345. * @param gradient gets or sets the gradient value (between 0 and 1)
  14346. * @param factor1 gets or sets first associated factor
  14347. * @param factor2 gets or sets second associated factor
  14348. */
  14349. constructor(
  14350. /**
  14351. * Gets or sets the gradient value (between 0 and 1)
  14352. */
  14353. gradient: number,
  14354. /**
  14355. * Gets or sets first associated factor
  14356. */
  14357. factor1: number,
  14358. /**
  14359. * Gets or sets second associated factor
  14360. */
  14361. factor2?: number | undefined);
  14362. /**
  14363. * Will get a number picked randomly between factor1 and factor2.
  14364. * If factor2 is undefined then factor1 will be used
  14365. * @returns the picked number
  14366. */
  14367. getFactor(): number;
  14368. }
  14369. /**
  14370. * Helper used to simplify some generic gradient tasks
  14371. */
  14372. export class GradientHelper {
  14373. /**
  14374. * Gets the current gradient from an array of IValueGradient
  14375. * @param ratio defines the current ratio to get
  14376. * @param gradients defines the array of IValueGradient
  14377. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14378. */
  14379. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14380. }
  14381. }
  14382. declare module BABYLON {
  14383. interface ThinEngine {
  14384. /**
  14385. * Creates a raw texture
  14386. * @param data defines the data to store in the texture
  14387. * @param width defines the width of the texture
  14388. * @param height defines the height of the texture
  14389. * @param format defines the format of the data
  14390. * @param generateMipMaps defines if the engine should generate the mip levels
  14391. * @param invertY defines if data must be stored with Y axis inverted
  14392. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14393. * @param compression defines the compression used (null by default)
  14394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14395. * @returns the raw texture inside an InternalTexture
  14396. */
  14397. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14398. /**
  14399. * Update a raw texture
  14400. * @param texture defines the texture to update
  14401. * @param data defines the data to store in the texture
  14402. * @param format defines the format of the data
  14403. * @param invertY defines if data must be stored with Y axis inverted
  14404. */
  14405. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14406. /**
  14407. * Update a raw texture
  14408. * @param texture defines the texture to update
  14409. * @param data defines the data to store in the texture
  14410. * @param format defines the format of the data
  14411. * @param invertY defines if data must be stored with Y axis inverted
  14412. * @param compression defines the compression used (null by default)
  14413. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14414. */
  14415. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14416. /**
  14417. * Creates a new raw cube texture
  14418. * @param data defines the array of data to use to create each face
  14419. * @param size defines the size of the textures
  14420. * @param format defines the format of the data
  14421. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14422. * @param generateMipMaps defines if the engine should generate the mip levels
  14423. * @param invertY defines if data must be stored with Y axis inverted
  14424. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14425. * @param compression defines the compression used (null by default)
  14426. * @returns the cube texture as an InternalTexture
  14427. */
  14428. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14429. /**
  14430. * Update a raw cube texture
  14431. * @param texture defines the texture to update
  14432. * @param data defines the data to store
  14433. * @param format defines the data format
  14434. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14435. * @param invertY defines if data must be stored with Y axis inverted
  14436. */
  14437. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14438. /**
  14439. * Update a raw cube texture
  14440. * @param texture defines the texture to update
  14441. * @param data defines the data to store
  14442. * @param format defines the data format
  14443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14444. * @param invertY defines if data must be stored with Y axis inverted
  14445. * @param compression defines the compression used (null by default)
  14446. */
  14447. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14448. /**
  14449. * Update a raw cube texture
  14450. * @param texture defines the texture to update
  14451. * @param data defines the data to store
  14452. * @param format defines the data format
  14453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14454. * @param invertY defines if data must be stored with Y axis inverted
  14455. * @param compression defines the compression used (null by default)
  14456. * @param level defines which level of the texture to update
  14457. */
  14458. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14459. /**
  14460. * Creates a new raw cube texture from a specified url
  14461. * @param url defines the url where the data is located
  14462. * @param scene defines the current scene
  14463. * @param size defines the size of the textures
  14464. * @param format defines the format of the data
  14465. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14466. * @param noMipmap defines if the engine should avoid generating the mip levels
  14467. * @param callback defines a callback used to extract texture data from loaded data
  14468. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14469. * @param onLoad defines a callback called when texture is loaded
  14470. * @param onError defines a callback called if there is an error
  14471. * @returns the cube texture as an InternalTexture
  14472. */
  14473. 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;
  14474. /**
  14475. * Creates a new raw cube texture from a specified url
  14476. * @param url defines the url where the data is located
  14477. * @param scene defines the current scene
  14478. * @param size defines the size of the textures
  14479. * @param format defines the format of the data
  14480. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14481. * @param noMipmap defines if the engine should avoid generating the mip levels
  14482. * @param callback defines a callback used to extract texture data from loaded data
  14483. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14484. * @param onLoad defines a callback called when texture is loaded
  14485. * @param onError defines a callback called if there is an error
  14486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14487. * @param invertY defines if data must be stored with Y axis inverted
  14488. * @returns the cube texture as an InternalTexture
  14489. */
  14490. 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;
  14491. /**
  14492. * Creates a new raw 3D texture
  14493. * @param data defines the data used to create the texture
  14494. * @param width defines the width of the texture
  14495. * @param height defines the height of the texture
  14496. * @param depth defines the depth of the texture
  14497. * @param format defines the format of the texture
  14498. * @param generateMipMaps defines if the engine must generate mip levels
  14499. * @param invertY defines if data must be stored with Y axis inverted
  14500. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14501. * @param compression defines the compressed used (can be null)
  14502. * @param textureType defines the compressed used (can be null)
  14503. * @returns a new raw 3D texture (stored in an InternalTexture)
  14504. */
  14505. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14506. /**
  14507. * Update a raw 3D texture
  14508. * @param texture defines the texture to update
  14509. * @param data defines the data to store
  14510. * @param format defines the data format
  14511. * @param invertY defines if data must be stored with Y axis inverted
  14512. */
  14513. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14514. /**
  14515. * Update a raw 3D texture
  14516. * @param texture defines the texture to update
  14517. * @param data defines the data to store
  14518. * @param format defines the data format
  14519. * @param invertY defines if data must be stored with Y axis inverted
  14520. * @param compression defines the used compression (can be null)
  14521. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14522. */
  14523. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14524. /**
  14525. * Creates a new raw 2D array texture
  14526. * @param data defines the data used to create the texture
  14527. * @param width defines the width of the texture
  14528. * @param height defines the height of the texture
  14529. * @param depth defines the number of layers of the texture
  14530. * @param format defines the format of the texture
  14531. * @param generateMipMaps defines if the engine must generate mip levels
  14532. * @param invertY defines if data must be stored with Y axis inverted
  14533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14534. * @param compression defines the compressed used (can be null)
  14535. * @param textureType defines the compressed used (can be null)
  14536. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14537. */
  14538. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14539. /**
  14540. * Update a raw 2D array texture
  14541. * @param texture defines the texture to update
  14542. * @param data defines the data to store
  14543. * @param format defines the data format
  14544. * @param invertY defines if data must be stored with Y axis inverted
  14545. */
  14546. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14547. /**
  14548. * Update a raw 2D array texture
  14549. * @param texture defines the texture to update
  14550. * @param data defines the data to store
  14551. * @param format defines the data format
  14552. * @param invertY defines if data must be stored with Y axis inverted
  14553. * @param compression defines the used compression (can be null)
  14554. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14555. */
  14556. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14557. }
  14558. }
  14559. declare module BABYLON {
  14560. /**
  14561. * Raw texture can help creating a texture directly from an array of data.
  14562. * This can be super useful if you either get the data from an uncompressed source or
  14563. * if you wish to create your texture pixel by pixel.
  14564. */
  14565. export class RawTexture extends Texture {
  14566. /**
  14567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14568. */
  14569. format: number;
  14570. /**
  14571. * Instantiates a new RawTexture.
  14572. * Raw texture can help creating a texture directly from an array of data.
  14573. * This can be super useful if you either get the data from an uncompressed source or
  14574. * if you wish to create your texture pixel by pixel.
  14575. * @param data define the array of data to use to create the texture
  14576. * @param width define the width of the texture
  14577. * @param height define the height of the texture
  14578. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14579. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14580. * @param generateMipMaps define whether mip maps should be generated or not
  14581. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14582. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14583. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14584. */
  14585. constructor(data: ArrayBufferView, width: number, height: number,
  14586. /**
  14587. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14588. */
  14589. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14590. /**
  14591. * Updates the texture underlying data.
  14592. * @param data Define the new data of the texture
  14593. */
  14594. update(data: ArrayBufferView): void;
  14595. /**
  14596. * Creates a luminance texture from some data.
  14597. * @param data Define the texture data
  14598. * @param width Define the width of the texture
  14599. * @param height Define the height of the texture
  14600. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14601. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14602. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14603. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14604. * @returns the luminance texture
  14605. */
  14606. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14607. /**
  14608. * Creates a luminance alpha texture from some data.
  14609. * @param data Define the texture data
  14610. * @param width Define the width of the texture
  14611. * @param height Define the height of the texture
  14612. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14613. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14614. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14615. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14616. * @returns the luminance alpha texture
  14617. */
  14618. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14619. /**
  14620. * Creates an alpha texture from some data.
  14621. * @param data Define the texture data
  14622. * @param width Define the width of the texture
  14623. * @param height Define the height of the texture
  14624. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14625. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14626. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14627. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14628. * @returns the alpha texture
  14629. */
  14630. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14631. /**
  14632. * Creates a RGB texture from some data.
  14633. * @param data Define the texture data
  14634. * @param width Define the width of the texture
  14635. * @param height Define the height of the texture
  14636. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14637. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14638. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14639. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14640. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14641. * @returns the RGB alpha texture
  14642. */
  14643. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14644. /**
  14645. * Creates a RGBA texture from some data.
  14646. * @param data Define the texture data
  14647. * @param width Define the width of the texture
  14648. * @param height Define the height of the texture
  14649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14653. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14654. * @returns the RGBA texture
  14655. */
  14656. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14657. /**
  14658. * Creates a R texture from some data.
  14659. * @param data Define the texture data
  14660. * @param width Define the width of the texture
  14661. * @param height Define the height of the texture
  14662. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14663. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14667. * @returns the R texture
  14668. */
  14669. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14670. }
  14671. }
  14672. declare module BABYLON {
  14673. interface ThinEngine {
  14674. /**
  14675. * Update a dynamic index buffer
  14676. * @param indexBuffer defines the target index buffer
  14677. * @param indices defines the data to update
  14678. * @param offset defines the offset in the target index buffer where update should start
  14679. */
  14680. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14681. /**
  14682. * Updates a dynamic vertex buffer.
  14683. * @param vertexBuffer the vertex buffer to update
  14684. * @param data the data used to update the vertex buffer
  14685. * @param byteOffset the byte offset of the data
  14686. * @param byteLength the byte length of the data
  14687. */
  14688. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14689. }
  14690. }
  14691. declare module BABYLON {
  14692. interface AbstractScene {
  14693. /**
  14694. * The list of procedural textures added to the scene
  14695. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14696. */
  14697. proceduralTextures: Array<ProceduralTexture>;
  14698. }
  14699. /**
  14700. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14701. * in a given scene.
  14702. */
  14703. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14704. /**
  14705. * The component name helpful to identify the component in the list of scene components.
  14706. */
  14707. readonly name: string;
  14708. /**
  14709. * The scene the component belongs to.
  14710. */
  14711. scene: Scene;
  14712. /**
  14713. * Creates a new instance of the component for the given scene
  14714. * @param scene Defines the scene to register the component in
  14715. */
  14716. constructor(scene: Scene);
  14717. /**
  14718. * Registers the component in a given scene
  14719. */
  14720. register(): void;
  14721. /**
  14722. * Rebuilds the elements related to this component in case of
  14723. * context lost for instance.
  14724. */
  14725. rebuild(): void;
  14726. /**
  14727. * Disposes the component and the associated resources.
  14728. */
  14729. dispose(): void;
  14730. private _beforeClear;
  14731. }
  14732. }
  14733. declare module BABYLON {
  14734. interface ThinEngine {
  14735. /**
  14736. * Creates a new render target cube texture
  14737. * @param size defines the size of the texture
  14738. * @param options defines the options used to create the texture
  14739. * @returns a new render target cube texture stored in an InternalTexture
  14740. */
  14741. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14742. }
  14743. }
  14744. declare module BABYLON {
  14745. /** @hidden */
  14746. export var proceduralVertexShader: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module BABYLON {
  14752. /**
  14753. * 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.
  14754. * This is the base class of any Procedural texture and contains most of the shareable code.
  14755. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14756. */
  14757. export class ProceduralTexture extends Texture {
  14758. /**
  14759. * Define if the texture is enabled or not (disabled texture will not render)
  14760. */
  14761. isEnabled: boolean;
  14762. /**
  14763. * Define if the texture must be cleared before rendering (default is true)
  14764. */
  14765. autoClear: boolean;
  14766. /**
  14767. * Callback called when the texture is generated
  14768. */
  14769. onGenerated: () => void;
  14770. /**
  14771. * Event raised when the texture is generated
  14772. */
  14773. onGeneratedObservable: Observable<ProceduralTexture>;
  14774. /**
  14775. * Event raised before the texture is generated
  14776. */
  14777. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14778. /**
  14779. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14780. */
  14781. nodeMaterialSource: Nullable<NodeMaterial>;
  14782. /** @hidden */
  14783. _generateMipMaps: boolean;
  14784. /** @hidden **/
  14785. _effect: Effect;
  14786. /** @hidden */
  14787. _textures: {
  14788. [key: string]: Texture;
  14789. };
  14790. /** @hidden */
  14791. protected _fallbackTexture: Nullable<Texture>;
  14792. private _size;
  14793. private _textureType;
  14794. private _currentRefreshId;
  14795. private _frameId;
  14796. private _refreshRate;
  14797. private _vertexBuffers;
  14798. private _indexBuffer;
  14799. private _uniforms;
  14800. private _samplers;
  14801. private _fragment;
  14802. private _floats;
  14803. private _ints;
  14804. private _floatsArrays;
  14805. private _colors3;
  14806. private _colors4;
  14807. private _vectors2;
  14808. private _vectors3;
  14809. private _matrices;
  14810. private _fallbackTextureUsed;
  14811. private _fullEngine;
  14812. private _cachedDefines;
  14813. private _contentUpdateId;
  14814. private _contentData;
  14815. /**
  14816. * Instantiates a new procedural texture.
  14817. * 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.
  14818. * This is the base class of any Procedural texture and contains most of the shareable code.
  14819. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14820. * @param name Define the name of the texture
  14821. * @param size Define the size of the texture to create
  14822. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14823. * @param scene Define the scene the texture belongs to
  14824. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14825. * @param generateMipMaps Define if the texture should creates mip maps or not
  14826. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14827. * @param textureType The FBO internal texture type
  14828. */
  14829. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14830. /**
  14831. * The effect that is created when initializing the post process.
  14832. * @returns The created effect corresponding the the postprocess.
  14833. */
  14834. getEffect(): Effect;
  14835. /**
  14836. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14837. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14838. */
  14839. getContent(): Nullable<Promise<ArrayBufferView>>;
  14840. private _createIndexBuffer;
  14841. /** @hidden */
  14842. _rebuild(): void;
  14843. /**
  14844. * Resets the texture in order to recreate its associated resources.
  14845. * This can be called in case of context loss
  14846. */
  14847. reset(): void;
  14848. protected _getDefines(): string;
  14849. /**
  14850. * Is the texture ready to be used ? (rendered at least once)
  14851. * @returns true if ready, otherwise, false.
  14852. */
  14853. isReady(): boolean;
  14854. /**
  14855. * Resets the refresh counter of the texture and start bak from scratch.
  14856. * Could be useful to regenerate the texture if it is setup to render only once.
  14857. */
  14858. resetRefreshCounter(): void;
  14859. /**
  14860. * Set the fragment shader to use in order to render the texture.
  14861. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14862. */
  14863. setFragment(fragment: any): void;
  14864. /**
  14865. * Define the refresh rate of the texture or the rendering frequency.
  14866. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14867. */
  14868. get refreshRate(): number;
  14869. set refreshRate(value: number);
  14870. /** @hidden */
  14871. _shouldRender(): boolean;
  14872. /**
  14873. * Get the size the texture is rendering at.
  14874. * @returns the size (on cube texture it is always squared)
  14875. */
  14876. getRenderSize(): RenderTargetTextureSize;
  14877. /**
  14878. * Resize the texture to new value.
  14879. * @param size Define the new size the texture should have
  14880. * @param generateMipMaps Define whether the new texture should create mip maps
  14881. */
  14882. resize(size: number, generateMipMaps: boolean): void;
  14883. private _checkUniform;
  14884. /**
  14885. * Set a texture in the shader program used to render.
  14886. * @param name Define the name of the uniform samplers as defined in the shader
  14887. * @param texture Define the texture to bind to this sampler
  14888. * @return the texture itself allowing "fluent" like uniform updates
  14889. */
  14890. setTexture(name: string, texture: Texture): ProceduralTexture;
  14891. /**
  14892. * Set a float in the shader.
  14893. * @param name Define the name of the uniform as defined in the shader
  14894. * @param value Define the value to give to the uniform
  14895. * @return the texture itself allowing "fluent" like uniform updates
  14896. */
  14897. setFloat(name: string, value: number): ProceduralTexture;
  14898. /**
  14899. * Set a int in the shader.
  14900. * @param name Define the name of the uniform as defined in the shader
  14901. * @param value Define the value to give to the uniform
  14902. * @return the texture itself allowing "fluent" like uniform updates
  14903. */
  14904. setInt(name: string, value: number): ProceduralTexture;
  14905. /**
  14906. * Set an array of floats in the shader.
  14907. * @param name Define the name of the uniform as defined in the shader
  14908. * @param value Define the value to give to the uniform
  14909. * @return the texture itself allowing "fluent" like uniform updates
  14910. */
  14911. setFloats(name: string, value: number[]): ProceduralTexture;
  14912. /**
  14913. * Set a vec3 in the shader from a Color3.
  14914. * @param name Define the name of the uniform as defined in the shader
  14915. * @param value Define the value to give to the uniform
  14916. * @return the texture itself allowing "fluent" like uniform updates
  14917. */
  14918. setColor3(name: string, value: Color3): ProceduralTexture;
  14919. /**
  14920. * Set a vec4 in the shader from a Color4.
  14921. * @param name Define the name of the uniform as defined in the shader
  14922. * @param value Define the value to give to the uniform
  14923. * @return the texture itself allowing "fluent" like uniform updates
  14924. */
  14925. setColor4(name: string, value: Color4): ProceduralTexture;
  14926. /**
  14927. * Set a vec2 in the shader from a Vector2.
  14928. * @param name Define the name of the uniform as defined in the shader
  14929. * @param value Define the value to give to the uniform
  14930. * @return the texture itself allowing "fluent" like uniform updates
  14931. */
  14932. setVector2(name: string, value: Vector2): ProceduralTexture;
  14933. /**
  14934. * Set a vec3 in the shader from a Vector3.
  14935. * @param name Define the name of the uniform as defined in the shader
  14936. * @param value Define the value to give to the uniform
  14937. * @return the texture itself allowing "fluent" like uniform updates
  14938. */
  14939. setVector3(name: string, value: Vector3): ProceduralTexture;
  14940. /**
  14941. * Set a mat4 in the shader from a MAtrix.
  14942. * @param name Define the name of the uniform as defined in the shader
  14943. * @param value Define the value to give to the uniform
  14944. * @return the texture itself allowing "fluent" like uniform updates
  14945. */
  14946. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14947. /**
  14948. * Render the texture to its associated render target.
  14949. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14950. */
  14951. render(useCameraPostProcess?: boolean): void;
  14952. /**
  14953. * Clone the texture.
  14954. * @returns the cloned texture
  14955. */
  14956. clone(): ProceduralTexture;
  14957. /**
  14958. * Dispose the texture and release its associated resources.
  14959. */
  14960. dispose(): void;
  14961. }
  14962. }
  14963. declare module BABYLON {
  14964. /**
  14965. * This represents the base class for particle system in Babylon.
  14966. * 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.
  14967. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14968. * @example https://doc.babylonjs.com/babylon101/particles
  14969. */
  14970. export class BaseParticleSystem {
  14971. /**
  14972. * Source color is added to the destination color without alpha affecting the result
  14973. */
  14974. static BLENDMODE_ONEONE: number;
  14975. /**
  14976. * Blend current color and particle color using particle’s alpha
  14977. */
  14978. static BLENDMODE_STANDARD: number;
  14979. /**
  14980. * Add current color and particle color multiplied by particle’s alpha
  14981. */
  14982. static BLENDMODE_ADD: number;
  14983. /**
  14984. * Multiply current color with particle color
  14985. */
  14986. static BLENDMODE_MULTIPLY: number;
  14987. /**
  14988. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14989. */
  14990. static BLENDMODE_MULTIPLYADD: number;
  14991. /**
  14992. * List of animations used by the particle system.
  14993. */
  14994. animations: Animation[];
  14995. /**
  14996. * Gets or sets the unique id of the particle system
  14997. */
  14998. uniqueId: number;
  14999. /**
  15000. * The id of the Particle system.
  15001. */
  15002. id: string;
  15003. /**
  15004. * The friendly name of the Particle system.
  15005. */
  15006. name: string;
  15007. /**
  15008. * Snippet ID if the particle system was created from the snippet server
  15009. */
  15010. snippetId: string;
  15011. /**
  15012. * The rendering group used by the Particle system to chose when to render.
  15013. */
  15014. renderingGroupId: number;
  15015. /**
  15016. * The emitter represents the Mesh or position we are attaching the particle system to.
  15017. */
  15018. emitter: Nullable<AbstractMesh | Vector3>;
  15019. /**
  15020. * The maximum number of particles to emit per frame
  15021. */
  15022. emitRate: number;
  15023. /**
  15024. * If you want to launch only a few particles at once, that can be done, as well.
  15025. */
  15026. manualEmitCount: number;
  15027. /**
  15028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15029. */
  15030. updateSpeed: number;
  15031. /**
  15032. * The amount of time the particle system is running (depends of the overall update speed).
  15033. */
  15034. targetStopDuration: number;
  15035. /**
  15036. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15037. */
  15038. disposeOnStop: boolean;
  15039. /**
  15040. * Minimum power of emitting particles.
  15041. */
  15042. minEmitPower: number;
  15043. /**
  15044. * Maximum power of emitting particles.
  15045. */
  15046. maxEmitPower: number;
  15047. /**
  15048. * Minimum life time of emitting particles.
  15049. */
  15050. minLifeTime: number;
  15051. /**
  15052. * Maximum life time of emitting particles.
  15053. */
  15054. maxLifeTime: number;
  15055. /**
  15056. * Minimum Size of emitting particles.
  15057. */
  15058. minSize: number;
  15059. /**
  15060. * Maximum Size of emitting particles.
  15061. */
  15062. maxSize: number;
  15063. /**
  15064. * Minimum scale of emitting particles on X axis.
  15065. */
  15066. minScaleX: number;
  15067. /**
  15068. * Maximum scale of emitting particles on X axis.
  15069. */
  15070. maxScaleX: number;
  15071. /**
  15072. * Minimum scale of emitting particles on Y axis.
  15073. */
  15074. minScaleY: number;
  15075. /**
  15076. * Maximum scale of emitting particles on Y axis.
  15077. */
  15078. maxScaleY: number;
  15079. /**
  15080. * Gets or sets the minimal initial rotation in radians.
  15081. */
  15082. minInitialRotation: number;
  15083. /**
  15084. * Gets or sets the maximal initial rotation in radians.
  15085. */
  15086. maxInitialRotation: number;
  15087. /**
  15088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15089. */
  15090. minAngularSpeed: number;
  15091. /**
  15092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15093. */
  15094. maxAngularSpeed: number;
  15095. /**
  15096. * The texture used to render each particle. (this can be a spritesheet)
  15097. */
  15098. particleTexture: Nullable<BaseTexture>;
  15099. /**
  15100. * The layer mask we are rendering the particles through.
  15101. */
  15102. layerMask: number;
  15103. /**
  15104. * This can help using your own shader to render the particle system.
  15105. * The according effect will be created
  15106. */
  15107. customShader: any;
  15108. /**
  15109. * By default particle system starts as soon as they are created. This prevents the
  15110. * automatic start to happen and let you decide when to start emitting particles.
  15111. */
  15112. preventAutoStart: boolean;
  15113. protected _rootUrl: string;
  15114. private _noiseTexture;
  15115. /**
  15116. * Gets or sets a texture used to add random noise to particle positions
  15117. */
  15118. get noiseTexture(): Nullable<ProceduralTexture>;
  15119. set noiseTexture(value: Nullable<ProceduralTexture>);
  15120. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15121. noiseStrength: Vector3;
  15122. /**
  15123. * Callback triggered when the particle animation is ending.
  15124. */
  15125. onAnimationEnd: Nullable<() => void>;
  15126. /**
  15127. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15128. */
  15129. blendMode: number;
  15130. /**
  15131. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15132. * to override the particles.
  15133. */
  15134. forceDepthWrite: boolean;
  15135. /** 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 */
  15136. preWarmCycles: number;
  15137. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15138. preWarmStepOffset: number;
  15139. /**
  15140. * 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)
  15141. */
  15142. spriteCellChangeSpeed: number;
  15143. /**
  15144. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15145. */
  15146. startSpriteCellID: number;
  15147. /**
  15148. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15149. */
  15150. endSpriteCellID: number;
  15151. /**
  15152. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15153. */
  15154. spriteCellWidth: number;
  15155. /**
  15156. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15157. */
  15158. spriteCellHeight: number;
  15159. /**
  15160. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15161. */
  15162. spriteRandomStartCell: boolean;
  15163. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15164. translationPivot: Vector2;
  15165. /** @hidden */
  15166. protected _isAnimationSheetEnabled: boolean;
  15167. /**
  15168. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15169. */
  15170. beginAnimationOnStart: boolean;
  15171. /**
  15172. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15173. */
  15174. beginAnimationFrom: number;
  15175. /**
  15176. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15177. */
  15178. beginAnimationTo: number;
  15179. /**
  15180. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15181. */
  15182. beginAnimationLoop: boolean;
  15183. /**
  15184. * Gets or sets a world offset applied to all particles
  15185. */
  15186. worldOffset: Vector3;
  15187. /**
  15188. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15189. */
  15190. get isAnimationSheetEnabled(): boolean;
  15191. set isAnimationSheetEnabled(value: boolean);
  15192. /**
  15193. * Get hosting scene
  15194. * @returns the scene
  15195. */
  15196. getScene(): Nullable<Scene>;
  15197. /**
  15198. * You can use gravity if you want to give an orientation to your particles.
  15199. */
  15200. gravity: Vector3;
  15201. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15202. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15203. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15204. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15205. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15206. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15207. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15208. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15209. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15210. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15211. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15212. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15213. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15214. /**
  15215. * Defines the delay in milliseconds before starting the system (0 by default)
  15216. */
  15217. startDelay: number;
  15218. /**
  15219. * Gets the current list of drag gradients.
  15220. * You must use addDragGradient and removeDragGradient to update this list
  15221. * @returns the list of drag gradients
  15222. */
  15223. getDragGradients(): Nullable<Array<FactorGradient>>;
  15224. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15225. limitVelocityDamping: number;
  15226. /**
  15227. * Gets the current list of limit velocity gradients.
  15228. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  15229. * @returns the list of limit velocity gradients
  15230. */
  15231. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15232. /**
  15233. * Gets the current list of color gradients.
  15234. * You must use addColorGradient and removeColorGradient to update this list
  15235. * @returns the list of color gradients
  15236. */
  15237. getColorGradients(): Nullable<Array<ColorGradient>>;
  15238. /**
  15239. * Gets the current list of size gradients.
  15240. * You must use addSizeGradient and removeSizeGradient to update this list
  15241. * @returns the list of size gradients
  15242. */
  15243. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15244. /**
  15245. * Gets the current list of color remap gradients.
  15246. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  15247. * @returns the list of color remap gradients
  15248. */
  15249. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15250. /**
  15251. * Gets the current list of alpha remap gradients.
  15252. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  15253. * @returns the list of alpha remap gradients
  15254. */
  15255. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15256. /**
  15257. * Gets the current list of life time gradients.
  15258. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  15259. * @returns the list of life time gradients
  15260. */
  15261. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15262. /**
  15263. * Gets the current list of angular speed gradients.
  15264. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  15265. * @returns the list of angular speed gradients
  15266. */
  15267. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15268. /**
  15269. * Gets the current list of velocity gradients.
  15270. * You must use addVelocityGradient and removeVelocityGradient to update this list
  15271. * @returns the list of velocity gradients
  15272. */
  15273. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15274. /**
  15275. * Gets the current list of start size gradients.
  15276. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  15277. * @returns the list of start size gradients
  15278. */
  15279. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15280. /**
  15281. * Gets the current list of emit rate gradients.
  15282. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  15283. * @returns the list of emit rate gradients
  15284. */
  15285. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15286. /**
  15287. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15288. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15289. */
  15290. get direction1(): Vector3;
  15291. set direction1(value: Vector3);
  15292. /**
  15293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15294. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15295. */
  15296. get direction2(): Vector3;
  15297. set direction2(value: Vector3);
  15298. /**
  15299. * 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.
  15300. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15301. */
  15302. get minEmitBox(): Vector3;
  15303. set minEmitBox(value: Vector3);
  15304. /**
  15305. * 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.
  15306. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15307. */
  15308. get maxEmitBox(): Vector3;
  15309. set maxEmitBox(value: Vector3);
  15310. /**
  15311. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15312. */
  15313. color1: Color4;
  15314. /**
  15315. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15316. */
  15317. color2: Color4;
  15318. /**
  15319. * Color the particle will have at the end of its lifetime
  15320. */
  15321. colorDead: Color4;
  15322. /**
  15323. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15324. */
  15325. textureMask: Color4;
  15326. /**
  15327. * The particle emitter type defines the emitter used by the particle system.
  15328. * It can be for example box, sphere, or cone...
  15329. */
  15330. particleEmitterType: IParticleEmitterType;
  15331. /** @hidden */
  15332. _isSubEmitter: boolean;
  15333. /**
  15334. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15335. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15336. */
  15337. billboardMode: number;
  15338. protected _isBillboardBased: boolean;
  15339. /**
  15340. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15341. */
  15342. get isBillboardBased(): boolean;
  15343. set isBillboardBased(value: boolean);
  15344. /**
  15345. * The scene the particle system belongs to.
  15346. */
  15347. protected _scene: Nullable<Scene>;
  15348. /**
  15349. * The engine the particle system belongs to.
  15350. */
  15351. protected _engine: ThinEngine;
  15352. /**
  15353. * Local cache of defines for image processing.
  15354. */
  15355. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15356. /**
  15357. * Default configuration related to image processing available in the standard Material.
  15358. */
  15359. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15360. /**
  15361. * Gets the image processing configuration used either in this material.
  15362. */
  15363. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15364. /**
  15365. * Sets the Default image processing configuration used either in the this material.
  15366. *
  15367. * If sets to null, the scene one is in use.
  15368. */
  15369. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15370. /**
  15371. * Attaches a new image processing configuration to the Standard Material.
  15372. * @param configuration
  15373. */
  15374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15375. /** @hidden */
  15376. protected _reset(): void;
  15377. /** @hidden */
  15378. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15379. /**
  15380. * Instantiates a particle system.
  15381. * 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.
  15382. * @param name The name of the particle system
  15383. */
  15384. constructor(name: string);
  15385. /**
  15386. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15387. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15388. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15389. * @returns the emitter
  15390. */
  15391. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15392. /**
  15393. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15394. * @param radius The radius of the hemisphere to emit from
  15395. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15396. * @returns the emitter
  15397. */
  15398. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15399. /**
  15400. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15401. * @param radius The radius of the sphere to emit from
  15402. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15403. * @returns the emitter
  15404. */
  15405. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15406. /**
  15407. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15408. * @param radius The radius of the sphere to emit from
  15409. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15410. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15411. * @returns the emitter
  15412. */
  15413. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15414. /**
  15415. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15416. * @param radius The radius of the emission cylinder
  15417. * @param height The height of the emission cylinder
  15418. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15419. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15420. * @returns the emitter
  15421. */
  15422. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15423. /**
  15424. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15425. * @param radius The radius of the cylinder to emit from
  15426. * @param height The height of the emission cylinder
  15427. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15430. * @returns the emitter
  15431. */
  15432. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15433. /**
  15434. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15435. * @param radius The radius of the cone to emit from
  15436. * @param angle The base angle of the cone
  15437. * @returns the emitter
  15438. */
  15439. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15440. /**
  15441. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15444. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15445. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15446. * @returns the emitter
  15447. */
  15448. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * Type of sub emitter
  15454. */
  15455. export enum SubEmitterType {
  15456. /**
  15457. * Attached to the particle over it's lifetime
  15458. */
  15459. ATTACHED = 0,
  15460. /**
  15461. * Created when the particle dies
  15462. */
  15463. END = 1
  15464. }
  15465. /**
  15466. * Sub emitter class used to emit particles from an existing particle
  15467. */
  15468. export class SubEmitter {
  15469. /**
  15470. * the particle system to be used by the sub emitter
  15471. */
  15472. particleSystem: ParticleSystem;
  15473. /**
  15474. * Type of the submitter (Default: END)
  15475. */
  15476. type: SubEmitterType;
  15477. /**
  15478. * 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)
  15479. * Note: This only is supported when using an emitter of type Mesh
  15480. */
  15481. inheritDirection: boolean;
  15482. /**
  15483. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15484. */
  15485. inheritedVelocityAmount: number;
  15486. /**
  15487. * Creates a sub emitter
  15488. * @param particleSystem the particle system to be used by the sub emitter
  15489. */
  15490. constructor(
  15491. /**
  15492. * the particle system to be used by the sub emitter
  15493. */
  15494. particleSystem: ParticleSystem);
  15495. /**
  15496. * Clones the sub emitter
  15497. * @returns the cloned sub emitter
  15498. */
  15499. clone(): SubEmitter;
  15500. /**
  15501. * Serialize current object to a JSON object
  15502. * @returns the serialized object
  15503. */
  15504. serialize(): any;
  15505. /** @hidden */
  15506. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15507. /**
  15508. * Creates a new SubEmitter from a serialized JSON version
  15509. * @param serializationObject defines the JSON object to read from
  15510. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15511. * @param rootUrl defines the rootUrl for data loading
  15512. * @returns a new SubEmitter
  15513. */
  15514. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15515. /** Release associated resources */
  15516. dispose(): void;
  15517. }
  15518. }
  15519. declare module BABYLON {
  15520. /** @hidden */
  15521. export var clipPlaneFragmentDeclaration: {
  15522. name: string;
  15523. shader: string;
  15524. };
  15525. }
  15526. declare module BABYLON {
  15527. /** @hidden */
  15528. export var imageProcessingDeclaration: {
  15529. name: string;
  15530. shader: string;
  15531. };
  15532. }
  15533. declare module BABYLON {
  15534. /** @hidden */
  15535. export var imageProcessingFunctions: {
  15536. name: string;
  15537. shader: string;
  15538. };
  15539. }
  15540. declare module BABYLON {
  15541. /** @hidden */
  15542. export var clipPlaneFragment: {
  15543. name: string;
  15544. shader: string;
  15545. };
  15546. }
  15547. declare module BABYLON {
  15548. /** @hidden */
  15549. export var particlesPixelShader: {
  15550. name: string;
  15551. shader: string;
  15552. };
  15553. }
  15554. declare module BABYLON {
  15555. /** @hidden */
  15556. export var clipPlaneVertexDeclaration: {
  15557. name: string;
  15558. shader: string;
  15559. };
  15560. }
  15561. declare module BABYLON {
  15562. /** @hidden */
  15563. export var clipPlaneVertex: {
  15564. name: string;
  15565. shader: string;
  15566. };
  15567. }
  15568. declare module BABYLON {
  15569. /** @hidden */
  15570. export var particlesVertexShader: {
  15571. name: string;
  15572. shader: string;
  15573. };
  15574. }
  15575. declare module BABYLON {
  15576. /**
  15577. * Interface used to define entities containing multiple clip planes
  15578. */
  15579. export interface IClipPlanesHolder {
  15580. /**
  15581. * Gets or sets the active clipplane 1
  15582. */
  15583. clipPlane: Nullable<Plane>;
  15584. /**
  15585. * Gets or sets the active clipplane 2
  15586. */
  15587. clipPlane2: Nullable<Plane>;
  15588. /**
  15589. * Gets or sets the active clipplane 3
  15590. */
  15591. clipPlane3: Nullable<Plane>;
  15592. /**
  15593. * Gets or sets the active clipplane 4
  15594. */
  15595. clipPlane4: Nullable<Plane>;
  15596. /**
  15597. * Gets or sets the active clipplane 5
  15598. */
  15599. clipPlane5: Nullable<Plane>;
  15600. /**
  15601. * Gets or sets the active clipplane 6
  15602. */
  15603. clipPlane6: Nullable<Plane>;
  15604. }
  15605. }
  15606. declare module BABYLON {
  15607. /**
  15608. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15609. *
  15610. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15611. *
  15612. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15613. */
  15614. export class ThinMaterialHelper {
  15615. /**
  15616. * Binds the clip plane information from the holder to the effect.
  15617. * @param effect The effect we are binding the data to
  15618. * @param holder The entity containing the clip plane information
  15619. */
  15620. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15621. }
  15622. }
  15623. declare module BABYLON {
  15624. interface ThinEngine {
  15625. /**
  15626. * Sets alpha constants used by some alpha blending modes
  15627. * @param r defines the red component
  15628. * @param g defines the green component
  15629. * @param b defines the blue component
  15630. * @param a defines the alpha component
  15631. */
  15632. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15633. /**
  15634. * Sets the current alpha mode
  15635. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15636. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15638. */
  15639. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15640. /**
  15641. * Gets the current alpha mode
  15642. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15643. * @returns the current alpha mode
  15644. */
  15645. getAlphaMode(): number;
  15646. /**
  15647. * Sets the current alpha equation
  15648. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15649. */
  15650. setAlphaEquation(equation: number): void;
  15651. /**
  15652. * Gets the current alpha equation.
  15653. * @returns the current alpha equation
  15654. */
  15655. getAlphaEquation(): number;
  15656. }
  15657. }
  15658. declare module BABYLON {
  15659. /**
  15660. * This represents a particle system in Babylon.
  15661. * 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.
  15662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15663. * @example https://doc.babylonjs.com/babylon101/particles
  15664. */
  15665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15666. /**
  15667. * Billboard mode will only apply to Y axis
  15668. */
  15669. static readonly BILLBOARDMODE_Y: number;
  15670. /**
  15671. * Billboard mode will apply to all axes
  15672. */
  15673. static readonly BILLBOARDMODE_ALL: number;
  15674. /**
  15675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15676. */
  15677. static readonly BILLBOARDMODE_STRETCHED: number;
  15678. /**
  15679. * This function can be defined to provide custom update for active particles.
  15680. * This function will be called instead of regular update (age, position, color, etc.).
  15681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15682. */
  15683. updateFunction: (particles: Particle[]) => void;
  15684. private _emitterWorldMatrix;
  15685. /**
  15686. * This function can be defined to specify initial direction for every new particle.
  15687. * It by default use the emitterType defined function
  15688. */
  15689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15690. /**
  15691. * This function can be defined to specify initial position for every new particle.
  15692. * It by default use the emitterType defined function
  15693. */
  15694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15695. /**
  15696. * @hidden
  15697. */
  15698. _inheritedVelocityOffset: Vector3;
  15699. /**
  15700. * An event triggered when the system is disposed
  15701. */
  15702. onDisposeObservable: Observable<IParticleSystem>;
  15703. /**
  15704. * An event triggered when the system is stopped
  15705. */
  15706. onStoppedObservable: Observable<IParticleSystem>;
  15707. private _onDisposeObserver;
  15708. /**
  15709. * Sets a callback that will be triggered when the system is disposed
  15710. */
  15711. set onDispose(callback: () => void);
  15712. private _particles;
  15713. private _epsilon;
  15714. private _capacity;
  15715. private _stockParticles;
  15716. private _newPartsExcess;
  15717. private _vertexData;
  15718. private _vertexBuffer;
  15719. private _vertexBuffers;
  15720. private _spriteBuffer;
  15721. private _indexBuffer;
  15722. private _effect;
  15723. private _customEffect;
  15724. private _cachedDefines;
  15725. private _scaledColorStep;
  15726. private _colorDiff;
  15727. private _scaledDirection;
  15728. private _scaledGravity;
  15729. private _currentRenderId;
  15730. private _alive;
  15731. private _useInstancing;
  15732. private _vertexArrayObject;
  15733. private _started;
  15734. private _stopped;
  15735. private _actualFrame;
  15736. private _scaledUpdateSpeed;
  15737. private _vertexBufferSize;
  15738. /** @hidden */
  15739. _currentEmitRateGradient: Nullable<FactorGradient>;
  15740. /** @hidden */
  15741. _currentEmitRate1: number;
  15742. /** @hidden */
  15743. _currentEmitRate2: number;
  15744. /** @hidden */
  15745. _currentStartSizeGradient: Nullable<FactorGradient>;
  15746. /** @hidden */
  15747. _currentStartSize1: number;
  15748. /** @hidden */
  15749. _currentStartSize2: number;
  15750. private readonly _rawTextureWidth;
  15751. private _rampGradientsTexture;
  15752. private _useRampGradients;
  15753. /** Gets or sets a matrix to use to compute projection */
  15754. defaultProjectionMatrix: Matrix;
  15755. /** Gets or sets a matrix to use to compute view */
  15756. defaultViewMatrix: Matrix;
  15757. /** Gets or sets a boolean indicating that ramp gradients must be used
  15758. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15759. */
  15760. get useRampGradients(): boolean;
  15761. set useRampGradients(value: boolean);
  15762. /**
  15763. * 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.
  15764. * 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: [])
  15765. */
  15766. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15767. private _subEmitters;
  15768. /**
  15769. * @hidden
  15770. * If the particle systems emitter should be disposed when the particle system is disposed
  15771. */
  15772. _disposeEmitterOnDispose: boolean;
  15773. /**
  15774. * The current active Sub-systems, this property is used by the root particle system only.
  15775. */
  15776. activeSubSystems: Array<ParticleSystem>;
  15777. /**
  15778. * Specifies if the particles are updated in emitter local space or world space
  15779. */
  15780. isLocal: boolean;
  15781. private _rootParticleSystem;
  15782. /**
  15783. * Gets the current list of active particles
  15784. */
  15785. get particles(): Particle[];
  15786. /**
  15787. * Gets the number of particles active at the same time.
  15788. * @returns The number of active particles.
  15789. */
  15790. getActiveCount(): number;
  15791. /**
  15792. * Returns the string "ParticleSystem"
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Gets a boolean indicating that the system is stopping
  15798. * @returns true if the system is currently stopping
  15799. */
  15800. isStopping(): boolean;
  15801. /**
  15802. * Gets the custom effect used to render the particles
  15803. * @param blendMode Blend mode for which the effect should be retrieved
  15804. * @returns The effect
  15805. */
  15806. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15807. /**
  15808. * Sets the custom effect used to render the particles
  15809. * @param effect The effect to set
  15810. * @param blendMode Blend mode for which the effect should be set
  15811. */
  15812. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15813. /** @hidden */
  15814. private _onBeforeDrawParticlesObservable;
  15815. /**
  15816. * Observable that will be called just before the particles are drawn
  15817. */
  15818. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15819. /**
  15820. * Gets the name of the particle vertex shader
  15821. */
  15822. get vertexShaderName(): string;
  15823. /**
  15824. * Instantiates a particle system.
  15825. * 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.
  15826. * @param name The name of the particle system
  15827. * @param capacity The max number of particles alive at the same time
  15828. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15829. * @param customEffect a custom effect used to change the way particles are rendered by default
  15830. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15831. * @param epsilon Offset used to render the particles
  15832. */
  15833. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15834. private _addFactorGradient;
  15835. private _removeFactorGradient;
  15836. /**
  15837. * Adds a new life time gradient
  15838. * @param gradient defines the gradient to use (between 0 and 1)
  15839. * @param factor defines the life time factor to affect to the specified gradient
  15840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15841. * @returns the current particle system
  15842. */
  15843. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15844. /**
  15845. * Remove a specific life time gradient
  15846. * @param gradient defines the gradient to remove
  15847. * @returns the current particle system
  15848. */
  15849. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15850. /**
  15851. * Adds a new size gradient
  15852. * @param gradient defines the gradient to use (between 0 and 1)
  15853. * @param factor defines the size factor to affect to the specified gradient
  15854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15855. * @returns the current particle system
  15856. */
  15857. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15858. /**
  15859. * Remove a specific size gradient
  15860. * @param gradient defines the gradient to remove
  15861. * @returns the current particle system
  15862. */
  15863. removeSizeGradient(gradient: number): IParticleSystem;
  15864. /**
  15865. * Adds a new color remap gradient
  15866. * @param gradient defines the gradient to use (between 0 and 1)
  15867. * @param min defines the color remap minimal range
  15868. * @param max defines the color remap maximal range
  15869. * @returns the current particle system
  15870. */
  15871. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15872. /**
  15873. * Remove a specific color remap gradient
  15874. * @param gradient defines the gradient to remove
  15875. * @returns the current particle system
  15876. */
  15877. removeColorRemapGradient(gradient: number): IParticleSystem;
  15878. /**
  15879. * Adds a new alpha remap gradient
  15880. * @param gradient defines the gradient to use (between 0 and 1)
  15881. * @param min defines the alpha remap minimal range
  15882. * @param max defines the alpha remap maximal range
  15883. * @returns the current particle system
  15884. */
  15885. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15886. /**
  15887. * Remove a specific alpha remap gradient
  15888. * @param gradient defines the gradient to remove
  15889. * @returns the current particle system
  15890. */
  15891. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15892. /**
  15893. * Adds a new angular speed gradient
  15894. * @param gradient defines the gradient to use (between 0 and 1)
  15895. * @param factor defines the angular speed to affect to the specified gradient
  15896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15897. * @returns the current particle system
  15898. */
  15899. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15900. /**
  15901. * Remove a specific angular speed gradient
  15902. * @param gradient defines the gradient to remove
  15903. * @returns the current particle system
  15904. */
  15905. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15906. /**
  15907. * Adds a new velocity gradient
  15908. * @param gradient defines the gradient to use (between 0 and 1)
  15909. * @param factor defines the velocity to affect to the specified gradient
  15910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15911. * @returns the current particle system
  15912. */
  15913. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15914. /**
  15915. * Remove a specific velocity gradient
  15916. * @param gradient defines the gradient to remove
  15917. * @returns the current particle system
  15918. */
  15919. removeVelocityGradient(gradient: number): IParticleSystem;
  15920. /**
  15921. * Adds a new limit velocity gradient
  15922. * @param gradient defines the gradient to use (between 0 and 1)
  15923. * @param factor defines the limit velocity value to affect to the specified gradient
  15924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15925. * @returns the current particle system
  15926. */
  15927. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15928. /**
  15929. * Remove a specific limit velocity gradient
  15930. * @param gradient defines the gradient to remove
  15931. * @returns the current particle system
  15932. */
  15933. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15934. /**
  15935. * Adds a new drag gradient
  15936. * @param gradient defines the gradient to use (between 0 and 1)
  15937. * @param factor defines the drag value to affect to the specified gradient
  15938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15939. * @returns the current particle system
  15940. */
  15941. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15942. /**
  15943. * Remove a specific drag gradient
  15944. * @param gradient defines the gradient to remove
  15945. * @returns the current particle system
  15946. */
  15947. removeDragGradient(gradient: number): IParticleSystem;
  15948. /**
  15949. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15950. * @param gradient defines the gradient to use (between 0 and 1)
  15951. * @param factor defines the emit rate value to affect to the specified gradient
  15952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15953. * @returns the current particle system
  15954. */
  15955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15956. /**
  15957. * Remove a specific emit rate gradient
  15958. * @param gradient defines the gradient to remove
  15959. * @returns the current particle system
  15960. */
  15961. removeEmitRateGradient(gradient: number): IParticleSystem;
  15962. /**
  15963. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15964. * @param gradient defines the gradient to use (between 0 and 1)
  15965. * @param factor defines the start size value to affect to the specified gradient
  15966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15967. * @returns the current particle system
  15968. */
  15969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15970. /**
  15971. * Remove a specific start size gradient
  15972. * @param gradient defines the gradient to remove
  15973. * @returns the current particle system
  15974. */
  15975. removeStartSizeGradient(gradient: number): IParticleSystem;
  15976. private _createRampGradientTexture;
  15977. /**
  15978. * Gets the current list of ramp gradients.
  15979. * You must use addRampGradient and removeRampGradient to update this list
  15980. * @returns the list of ramp gradients
  15981. */
  15982. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15983. /** Force the system to rebuild all gradients that need to be resync */
  15984. forceRefreshGradients(): void;
  15985. private _syncRampGradientTexture;
  15986. /**
  15987. * Adds a new ramp gradient used to remap particle colors
  15988. * @param gradient defines the gradient to use (between 0 and 1)
  15989. * @param color defines the color to affect to the specified gradient
  15990. * @returns the current particle system
  15991. */
  15992. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15993. /**
  15994. * Remove a specific ramp gradient
  15995. * @param gradient defines the gradient to remove
  15996. * @returns the current particle system
  15997. */
  15998. removeRampGradient(gradient: number): ParticleSystem;
  15999. /**
  16000. * Adds a new color gradient
  16001. * @param gradient defines the gradient to use (between 0 and 1)
  16002. * @param color1 defines the color to affect to the specified gradient
  16003. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16004. * @returns this particle system
  16005. */
  16006. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16007. /**
  16008. * Remove a specific color gradient
  16009. * @param gradient defines the gradient to remove
  16010. * @returns this particle system
  16011. */
  16012. removeColorGradient(gradient: number): IParticleSystem;
  16013. private _fetchR;
  16014. protected _reset(): void;
  16015. private _resetEffect;
  16016. private _createVertexBuffers;
  16017. private _createIndexBuffer;
  16018. /**
  16019. * Gets the maximum number of particles active at the same time.
  16020. * @returns The max number of active particles.
  16021. */
  16022. getCapacity(): number;
  16023. /**
  16024. * Gets whether there are still active particles in the system.
  16025. * @returns True if it is alive, otherwise false.
  16026. */
  16027. isAlive(): boolean;
  16028. /**
  16029. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16030. * @returns True if it has been started, otherwise false.
  16031. */
  16032. isStarted(): boolean;
  16033. private _prepareSubEmitterInternalArray;
  16034. /**
  16035. * Starts the particle system and begins to emit
  16036. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16037. */
  16038. start(delay?: number): void;
  16039. /**
  16040. * Stops the particle system.
  16041. * @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.
  16042. */
  16043. stop(stopSubEmitters?: boolean): void;
  16044. /**
  16045. * Remove all active particles
  16046. */
  16047. reset(): void;
  16048. /**
  16049. * @hidden (for internal use only)
  16050. */
  16051. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16052. /**
  16053. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16054. * Its lifetime will start back at 0.
  16055. */
  16056. recycleParticle: (particle: Particle) => void;
  16057. private _stopSubEmitters;
  16058. private _createParticle;
  16059. private _removeFromRoot;
  16060. private _emitFromParticle;
  16061. private _update;
  16062. /** @hidden */
  16063. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16064. /** @hidden */
  16065. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16066. /**
  16067. * Fill the defines array according to the current settings of the particle system
  16068. * @param defines Array to be updated
  16069. * @param blendMode blend mode to take into account when updating the array
  16070. */
  16071. fillDefines(defines: Array<string>, blendMode: number): void;
  16072. /**
  16073. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16074. * @param uniforms Uniforms array to fill
  16075. * @param attributes Attributes array to fill
  16076. * @param samplers Samplers array to fill
  16077. */
  16078. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16079. /** @hidden */
  16080. private _getEffect;
  16081. /**
  16082. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16083. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16084. */
  16085. animate(preWarmOnly?: boolean): void;
  16086. private _appendParticleVertices;
  16087. /**
  16088. * Rebuilds the particle system.
  16089. */
  16090. rebuild(): void;
  16091. /**
  16092. * Is this system ready to be used/rendered
  16093. * @return true if the system is ready
  16094. */
  16095. isReady(): boolean;
  16096. private _render;
  16097. /**
  16098. * Renders the particle system in its current state.
  16099. * @returns the current number of particles
  16100. */
  16101. render(): number;
  16102. /**
  16103. * Disposes the particle system and free the associated resources
  16104. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  16105. */
  16106. dispose(disposeTexture?: boolean): void;
  16107. /**
  16108. * Clones the particle system.
  16109. * @param name The name of the cloned object
  16110. * @param newEmitter The new emitter to use
  16111. * @returns the cloned particle system
  16112. */
  16113. clone(name: string, newEmitter: any): ParticleSystem;
  16114. /**
  16115. * Serializes the particle system to a JSON object
  16116. * @param serializeTexture defines if the texture must be serialized as well
  16117. * @returns the JSON object
  16118. */
  16119. serialize(serializeTexture?: boolean): any;
  16120. /** @hidden */
  16121. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16122. /** @hidden */
  16123. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16124. /**
  16125. * Parses a JSON object to create a particle system.
  16126. * @param parsedParticleSystem The JSON object to parse
  16127. * @param sceneOrEngine The scene or the engine to create the particle system in
  16128. * @param rootUrl The root url to use to load external dependencies like texture
  16129. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16130. * @returns the Parsed particle system
  16131. */
  16132. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16133. }
  16134. }
  16135. declare module BABYLON {
  16136. /**
  16137. * A particle represents one of the element emitted by a particle system.
  16138. * This is mainly define by its coordinates, direction, velocity and age.
  16139. */
  16140. export class Particle {
  16141. /**
  16142. * The particle system the particle belongs to.
  16143. */
  16144. particleSystem: ParticleSystem;
  16145. private static _Count;
  16146. /**
  16147. * Unique ID of the particle
  16148. */
  16149. id: number;
  16150. /**
  16151. * The world position of the particle in the scene.
  16152. */
  16153. position: Vector3;
  16154. /**
  16155. * The world direction of the particle in the scene.
  16156. */
  16157. direction: Vector3;
  16158. /**
  16159. * The color of the particle.
  16160. */
  16161. color: Color4;
  16162. /**
  16163. * The color change of the particle per step.
  16164. */
  16165. colorStep: Color4;
  16166. /**
  16167. * Defines how long will the life of the particle be.
  16168. */
  16169. lifeTime: number;
  16170. /**
  16171. * The current age of the particle.
  16172. */
  16173. age: number;
  16174. /**
  16175. * The current size of the particle.
  16176. */
  16177. size: number;
  16178. /**
  16179. * The current scale of the particle.
  16180. */
  16181. scale: Vector2;
  16182. /**
  16183. * The current angle of the particle.
  16184. */
  16185. angle: number;
  16186. /**
  16187. * Defines how fast is the angle changing.
  16188. */
  16189. angularSpeed: number;
  16190. /**
  16191. * Defines the cell index used by the particle to be rendered from a sprite.
  16192. */
  16193. cellIndex: number;
  16194. /**
  16195. * The information required to support color remapping
  16196. */
  16197. remapData: Vector4;
  16198. /** @hidden */
  16199. _randomCellOffset?: number;
  16200. /** @hidden */
  16201. _initialDirection: Nullable<Vector3>;
  16202. /** @hidden */
  16203. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16204. /** @hidden */
  16205. _initialStartSpriteCellID: number;
  16206. /** @hidden */
  16207. _initialEndSpriteCellID: number;
  16208. /** @hidden */
  16209. _currentColorGradient: Nullable<ColorGradient>;
  16210. /** @hidden */
  16211. _currentColor1: Color4;
  16212. /** @hidden */
  16213. _currentColor2: Color4;
  16214. /** @hidden */
  16215. _currentSizeGradient: Nullable<FactorGradient>;
  16216. /** @hidden */
  16217. _currentSize1: number;
  16218. /** @hidden */
  16219. _currentSize2: number;
  16220. /** @hidden */
  16221. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16222. /** @hidden */
  16223. _currentAngularSpeed1: number;
  16224. /** @hidden */
  16225. _currentAngularSpeed2: number;
  16226. /** @hidden */
  16227. _currentVelocityGradient: Nullable<FactorGradient>;
  16228. /** @hidden */
  16229. _currentVelocity1: number;
  16230. /** @hidden */
  16231. _currentVelocity2: number;
  16232. /** @hidden */
  16233. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16234. /** @hidden */
  16235. _currentLimitVelocity1: number;
  16236. /** @hidden */
  16237. _currentLimitVelocity2: number;
  16238. /** @hidden */
  16239. _currentDragGradient: Nullable<FactorGradient>;
  16240. /** @hidden */
  16241. _currentDrag1: number;
  16242. /** @hidden */
  16243. _currentDrag2: number;
  16244. /** @hidden */
  16245. _randomNoiseCoordinates1: Vector3;
  16246. /** @hidden */
  16247. _randomNoiseCoordinates2: Vector3;
  16248. /** @hidden */
  16249. _localPosition?: Vector3;
  16250. /**
  16251. * Creates a new instance Particle
  16252. * @param particleSystem the particle system the particle belongs to
  16253. */
  16254. constructor(
  16255. /**
  16256. * The particle system the particle belongs to.
  16257. */
  16258. particleSystem: ParticleSystem);
  16259. private updateCellInfoFromSystem;
  16260. /**
  16261. * Defines how the sprite cell index is updated for the particle
  16262. */
  16263. updateCellIndex(): void;
  16264. /** @hidden */
  16265. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16266. /** @hidden */
  16267. _inheritParticleInfoToSubEmitters(): void;
  16268. /** @hidden */
  16269. _reset(): void;
  16270. /**
  16271. * Copy the properties of particle to another one.
  16272. * @param other the particle to copy the information to.
  16273. */
  16274. copyTo(other: Particle): void;
  16275. }
  16276. }
  16277. declare module BABYLON {
  16278. /**
  16279. * Particle emitter represents a volume emitting particles.
  16280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16281. */
  16282. export interface IParticleEmitterType {
  16283. /**
  16284. * Called by the particle System when the direction is computed for the created particle.
  16285. * @param worldMatrix is the world matrix of the particle system
  16286. * @param directionToUpdate is the direction vector to update with the result
  16287. * @param particle is the particle we are computed the direction for
  16288. * @param isLocal defines if the direction should be set in local space
  16289. */
  16290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16291. /**
  16292. * Called by the particle System when the position is computed for the created particle.
  16293. * @param worldMatrix is the world matrix of the particle system
  16294. * @param positionToUpdate is the position vector to update with the result
  16295. * @param particle is the particle we are computed the position for
  16296. * @param isLocal defines if the position should be set in local space
  16297. */
  16298. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16299. /**
  16300. * Clones the current emitter and returns a copy of it
  16301. * @returns the new emitter
  16302. */
  16303. clone(): IParticleEmitterType;
  16304. /**
  16305. * Called by the GPUParticleSystem to setup the update shader
  16306. * @param effect defines the update shader
  16307. */
  16308. applyToShader(effect: Effect): void;
  16309. /**
  16310. * Returns a string to use to update the GPU particles update shader
  16311. * @returns the effect defines string
  16312. */
  16313. getEffectDefines(): string;
  16314. /**
  16315. * Returns a string representing the class name
  16316. * @returns a string containing the class name
  16317. */
  16318. getClassName(): string;
  16319. /**
  16320. * Serializes the particle system to a JSON object.
  16321. * @returns the JSON object
  16322. */
  16323. serialize(): any;
  16324. /**
  16325. * Parse properties from a JSON object
  16326. * @param serializationObject defines the JSON object
  16327. * @param scene defines the hosting scene
  16328. */
  16329. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16330. }
  16331. }
  16332. declare module BABYLON {
  16333. /**
  16334. * Particle emitter emitting particles from the inside of a box.
  16335. * It emits the particles randomly between 2 given directions.
  16336. */
  16337. export class BoxParticleEmitter implements IParticleEmitterType {
  16338. /**
  16339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16340. */
  16341. direction1: Vector3;
  16342. /**
  16343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16344. */
  16345. direction2: Vector3;
  16346. /**
  16347. * 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.
  16348. */
  16349. minEmitBox: Vector3;
  16350. /**
  16351. * 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.
  16352. */
  16353. maxEmitBox: Vector3;
  16354. /**
  16355. * Creates a new instance BoxParticleEmitter
  16356. */
  16357. constructor();
  16358. /**
  16359. * Called by the particle System when the direction is computed for the created particle.
  16360. * @param worldMatrix is the world matrix of the particle system
  16361. * @param directionToUpdate is the direction vector to update with the result
  16362. * @param particle is the particle we are computed the direction for
  16363. * @param isLocal defines if the direction should be set in local space
  16364. */
  16365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16366. /**
  16367. * Called by the particle System when the position is computed for the created particle.
  16368. * @param worldMatrix is the world matrix of the particle system
  16369. * @param positionToUpdate is the position vector to update with the result
  16370. * @param particle is the particle we are computed the position for
  16371. * @param isLocal defines if the position should be set in local space
  16372. */
  16373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16374. /**
  16375. * Clones the current emitter and returns a copy of it
  16376. * @returns the new emitter
  16377. */
  16378. clone(): BoxParticleEmitter;
  16379. /**
  16380. * Called by the GPUParticleSystem to setup the update shader
  16381. * @param effect defines the update shader
  16382. */
  16383. applyToShader(effect: Effect): void;
  16384. /**
  16385. * Returns a string to use to update the GPU particles update shader
  16386. * @returns a string containing the defines string
  16387. */
  16388. getEffectDefines(): string;
  16389. /**
  16390. * Returns the string "BoxParticleEmitter"
  16391. * @returns a string containing the class name
  16392. */
  16393. getClassName(): string;
  16394. /**
  16395. * Serializes the particle system to a JSON object.
  16396. * @returns the JSON object
  16397. */
  16398. serialize(): any;
  16399. /**
  16400. * Parse properties from a JSON object
  16401. * @param serializationObject defines the JSON object
  16402. */
  16403. parse(serializationObject: any): void;
  16404. }
  16405. }
  16406. declare module BABYLON {
  16407. /**
  16408. * Particle emitter emitting particles from the inside of a cone.
  16409. * It emits the particles alongside the cone volume from the base to the particle.
  16410. * The emission direction might be randomized.
  16411. */
  16412. export class ConeParticleEmitter implements IParticleEmitterType {
  16413. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16414. directionRandomizer: number;
  16415. private _radius;
  16416. private _angle;
  16417. private _height;
  16418. /**
  16419. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16420. */
  16421. radiusRange: number;
  16422. /**
  16423. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16424. */
  16425. heightRange: number;
  16426. /**
  16427. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16428. */
  16429. emitFromSpawnPointOnly: boolean;
  16430. /**
  16431. * Gets or sets the radius of the emission cone
  16432. */
  16433. get radius(): number;
  16434. set radius(value: number);
  16435. /**
  16436. * Gets or sets the angle of the emission cone
  16437. */
  16438. get angle(): number;
  16439. set angle(value: number);
  16440. private _buildHeight;
  16441. /**
  16442. * Creates a new instance ConeParticleEmitter
  16443. * @param radius the radius of the emission cone (1 by default)
  16444. * @param angle the cone base angle (PI by default)
  16445. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16446. */
  16447. constructor(radius?: number, angle?: number,
  16448. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16449. directionRandomizer?: number);
  16450. /**
  16451. * Called by the particle System when the direction is computed for the created particle.
  16452. * @param worldMatrix is the world matrix of the particle system
  16453. * @param directionToUpdate is the direction vector to update with the result
  16454. * @param particle is the particle we are computed the direction for
  16455. * @param isLocal defines if the direction should be set in local space
  16456. */
  16457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16458. /**
  16459. * Called by the particle System when the position is computed for the created particle.
  16460. * @param worldMatrix is the world matrix of the particle system
  16461. * @param positionToUpdate is the position vector to update with the result
  16462. * @param particle is the particle we are computed the position for
  16463. * @param isLocal defines if the position should be set in local space
  16464. */
  16465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16466. /**
  16467. * Clones the current emitter and returns a copy of it
  16468. * @returns the new emitter
  16469. */
  16470. clone(): ConeParticleEmitter;
  16471. /**
  16472. * Called by the GPUParticleSystem to setup the update shader
  16473. * @param effect defines the update shader
  16474. */
  16475. applyToShader(effect: Effect): void;
  16476. /**
  16477. * Returns a string to use to update the GPU particles update shader
  16478. * @returns a string containing the defines string
  16479. */
  16480. getEffectDefines(): string;
  16481. /**
  16482. * Returns the string "ConeParticleEmitter"
  16483. * @returns a string containing the class name
  16484. */
  16485. getClassName(): string;
  16486. /**
  16487. * Serializes the particle system to a JSON object.
  16488. * @returns the JSON object
  16489. */
  16490. serialize(): any;
  16491. /**
  16492. * Parse properties from a JSON object
  16493. * @param serializationObject defines the JSON object
  16494. */
  16495. parse(serializationObject: any): void;
  16496. }
  16497. }
  16498. declare module BABYLON {
  16499. /**
  16500. * Particle emitter emitting particles from the inside of a cylinder.
  16501. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16502. */
  16503. export class CylinderParticleEmitter implements IParticleEmitterType {
  16504. /**
  16505. * The radius of the emission cylinder.
  16506. */
  16507. radius: number;
  16508. /**
  16509. * The height of the emission cylinder.
  16510. */
  16511. height: number;
  16512. /**
  16513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16514. */
  16515. radiusRange: number;
  16516. /**
  16517. * How much to randomize the particle direction [0-1].
  16518. */
  16519. directionRandomizer: number;
  16520. /**
  16521. * Creates a new instance CylinderParticleEmitter
  16522. * @param radius the radius of the emission cylinder (1 by default)
  16523. * @param height the height of the emission cylinder (1 by default)
  16524. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16525. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16526. */
  16527. constructor(
  16528. /**
  16529. * The radius of the emission cylinder.
  16530. */
  16531. radius?: number,
  16532. /**
  16533. * The height of the emission cylinder.
  16534. */
  16535. height?: number,
  16536. /**
  16537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16538. */
  16539. radiusRange?: number,
  16540. /**
  16541. * How much to randomize the particle direction [0-1].
  16542. */
  16543. directionRandomizer?: number);
  16544. /**
  16545. * Called by the particle System when the direction is computed for the created particle.
  16546. * @param worldMatrix is the world matrix of the particle system
  16547. * @param directionToUpdate is the direction vector to update with the result
  16548. * @param particle is the particle we are computed the direction for
  16549. * @param isLocal defines if the direction should be set in local space
  16550. */
  16551. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16552. /**
  16553. * Called by the particle System when the position is computed for the created particle.
  16554. * @param worldMatrix is the world matrix of the particle system
  16555. * @param positionToUpdate is the position vector to update with the result
  16556. * @param particle is the particle we are computed the position for
  16557. * @param isLocal defines if the position should be set in local space
  16558. */
  16559. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16560. /**
  16561. * Clones the current emitter and returns a copy of it
  16562. * @returns the new emitter
  16563. */
  16564. clone(): CylinderParticleEmitter;
  16565. /**
  16566. * Called by the GPUParticleSystem to setup the update shader
  16567. * @param effect defines the update shader
  16568. */
  16569. applyToShader(effect: Effect): void;
  16570. /**
  16571. * Returns a string to use to update the GPU particles update shader
  16572. * @returns a string containing the defines string
  16573. */
  16574. getEffectDefines(): string;
  16575. /**
  16576. * Returns the string "CylinderParticleEmitter"
  16577. * @returns a string containing the class name
  16578. */
  16579. getClassName(): string;
  16580. /**
  16581. * Serializes the particle system to a JSON object.
  16582. * @returns the JSON object
  16583. */
  16584. serialize(): any;
  16585. /**
  16586. * Parse properties from a JSON object
  16587. * @param serializationObject defines the JSON object
  16588. */
  16589. parse(serializationObject: any): void;
  16590. }
  16591. /**
  16592. * Particle emitter emitting particles from the inside of a cylinder.
  16593. * It emits the particles randomly between two vectors.
  16594. */
  16595. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16596. /**
  16597. * The min limit of the emission direction.
  16598. */
  16599. direction1: Vector3;
  16600. /**
  16601. * The max limit of the emission direction.
  16602. */
  16603. direction2: Vector3;
  16604. /**
  16605. * Creates a new instance CylinderDirectedParticleEmitter
  16606. * @param radius the radius of the emission cylinder (1 by default)
  16607. * @param height the height of the emission cylinder (1 by default)
  16608. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16609. * @param direction1 the min limit of the emission direction (up vector by default)
  16610. * @param direction2 the max limit of the emission direction (up vector by default)
  16611. */
  16612. constructor(radius?: number, height?: number, radiusRange?: number,
  16613. /**
  16614. * The min limit of the emission direction.
  16615. */
  16616. direction1?: Vector3,
  16617. /**
  16618. * The max limit of the emission direction.
  16619. */
  16620. direction2?: Vector3);
  16621. /**
  16622. * Called by the particle System when the direction is computed for the created particle.
  16623. * @param worldMatrix is the world matrix of the particle system
  16624. * @param directionToUpdate is the direction vector to update with the result
  16625. * @param particle is the particle we are computed the direction for
  16626. */
  16627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16628. /**
  16629. * Clones the current emitter and returns a copy of it
  16630. * @returns the new emitter
  16631. */
  16632. clone(): CylinderDirectedParticleEmitter;
  16633. /**
  16634. * Called by the GPUParticleSystem to setup the update shader
  16635. * @param effect defines the update shader
  16636. */
  16637. applyToShader(effect: Effect): void;
  16638. /**
  16639. * Returns a string to use to update the GPU particles update shader
  16640. * @returns a string containing the defines string
  16641. */
  16642. getEffectDefines(): string;
  16643. /**
  16644. * Returns the string "CylinderDirectedParticleEmitter"
  16645. * @returns a string containing the class name
  16646. */
  16647. getClassName(): string;
  16648. /**
  16649. * Serializes the particle system to a JSON object.
  16650. * @returns the JSON object
  16651. */
  16652. serialize(): any;
  16653. /**
  16654. * Parse properties from a JSON object
  16655. * @param serializationObject defines the JSON object
  16656. */
  16657. parse(serializationObject: any): void;
  16658. }
  16659. }
  16660. declare module BABYLON {
  16661. /**
  16662. * Particle emitter emitting particles from the inside of a hemisphere.
  16663. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16664. */
  16665. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16666. /**
  16667. * The radius of the emission hemisphere.
  16668. */
  16669. radius: number;
  16670. /**
  16671. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16672. */
  16673. radiusRange: number;
  16674. /**
  16675. * How much to randomize the particle direction [0-1].
  16676. */
  16677. directionRandomizer: number;
  16678. /**
  16679. * Creates a new instance HemisphericParticleEmitter
  16680. * @param radius the radius of the emission hemisphere (1 by default)
  16681. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16682. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16683. */
  16684. constructor(
  16685. /**
  16686. * The radius of the emission hemisphere.
  16687. */
  16688. radius?: number,
  16689. /**
  16690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16691. */
  16692. radiusRange?: number,
  16693. /**
  16694. * How much to randomize the particle direction [0-1].
  16695. */
  16696. directionRandomizer?: number);
  16697. /**
  16698. * Called by the particle System when the direction is computed for the created particle.
  16699. * @param worldMatrix is the world matrix of the particle system
  16700. * @param directionToUpdate is the direction vector to update with the result
  16701. * @param particle is the particle we are computed the direction for
  16702. * @param isLocal defines if the direction should be set in local space
  16703. */
  16704. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16705. /**
  16706. * Called by the particle System when the position is computed for the created particle.
  16707. * @param worldMatrix is the world matrix of the particle system
  16708. * @param positionToUpdate is the position vector to update with the result
  16709. * @param particle is the particle we are computed the position for
  16710. * @param isLocal defines if the position should be set in local space
  16711. */
  16712. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16713. /**
  16714. * Clones the current emitter and returns a copy of it
  16715. * @returns the new emitter
  16716. */
  16717. clone(): HemisphericParticleEmitter;
  16718. /**
  16719. * Called by the GPUParticleSystem to setup the update shader
  16720. * @param effect defines the update shader
  16721. */
  16722. applyToShader(effect: Effect): void;
  16723. /**
  16724. * Returns a string to use to update the GPU particles update shader
  16725. * @returns a string containing the defines string
  16726. */
  16727. getEffectDefines(): string;
  16728. /**
  16729. * Returns the string "HemisphericParticleEmitter"
  16730. * @returns a string containing the class name
  16731. */
  16732. getClassName(): string;
  16733. /**
  16734. * Serializes the particle system to a JSON object.
  16735. * @returns the JSON object
  16736. */
  16737. serialize(): any;
  16738. /**
  16739. * Parse properties from a JSON object
  16740. * @param serializationObject defines the JSON object
  16741. */
  16742. parse(serializationObject: any): void;
  16743. }
  16744. }
  16745. declare module BABYLON {
  16746. /**
  16747. * Particle emitter emitting particles from a point.
  16748. * It emits the particles randomly between 2 given directions.
  16749. */
  16750. export class PointParticleEmitter implements IParticleEmitterType {
  16751. /**
  16752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16753. */
  16754. direction1: Vector3;
  16755. /**
  16756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16757. */
  16758. direction2: Vector3;
  16759. /**
  16760. * Creates a new instance PointParticleEmitter
  16761. */
  16762. constructor();
  16763. /**
  16764. * Called by the particle System when the direction is computed for the created particle.
  16765. * @param worldMatrix is the world matrix of the particle system
  16766. * @param directionToUpdate is the direction vector to update with the result
  16767. * @param particle is the particle we are computed the direction for
  16768. * @param isLocal defines if the direction should be set in local space
  16769. */
  16770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16771. /**
  16772. * Called by the particle System when the position is computed for the created particle.
  16773. * @param worldMatrix is the world matrix of the particle system
  16774. * @param positionToUpdate is the position vector to update with the result
  16775. * @param particle is the particle we are computed the position for
  16776. * @param isLocal defines if the position should be set in local space
  16777. */
  16778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16779. /**
  16780. * Clones the current emitter and returns a copy of it
  16781. * @returns the new emitter
  16782. */
  16783. clone(): PointParticleEmitter;
  16784. /**
  16785. * Called by the GPUParticleSystem to setup the update shader
  16786. * @param effect defines the update shader
  16787. */
  16788. applyToShader(effect: Effect): void;
  16789. /**
  16790. * Returns a string to use to update the GPU particles update shader
  16791. * @returns a string containing the defines string
  16792. */
  16793. getEffectDefines(): string;
  16794. /**
  16795. * Returns the string "PointParticleEmitter"
  16796. * @returns a string containing the class name
  16797. */
  16798. getClassName(): string;
  16799. /**
  16800. * Serializes the particle system to a JSON object.
  16801. * @returns the JSON object
  16802. */
  16803. serialize(): any;
  16804. /**
  16805. * Parse properties from a JSON object
  16806. * @param serializationObject defines the JSON object
  16807. */
  16808. parse(serializationObject: any): void;
  16809. }
  16810. }
  16811. declare module BABYLON {
  16812. /**
  16813. * Particle emitter emitting particles from the inside of a sphere.
  16814. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16815. */
  16816. export class SphereParticleEmitter implements IParticleEmitterType {
  16817. /**
  16818. * The radius of the emission sphere.
  16819. */
  16820. radius: number;
  16821. /**
  16822. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16823. */
  16824. radiusRange: number;
  16825. /**
  16826. * How much to randomize the particle direction [0-1].
  16827. */
  16828. directionRandomizer: number;
  16829. /**
  16830. * Creates a new instance SphereParticleEmitter
  16831. * @param radius the radius of the emission sphere (1 by default)
  16832. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16833. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16834. */
  16835. constructor(
  16836. /**
  16837. * The radius of the emission sphere.
  16838. */
  16839. radius?: number,
  16840. /**
  16841. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16842. */
  16843. radiusRange?: number,
  16844. /**
  16845. * How much to randomize the particle direction [0-1].
  16846. */
  16847. directionRandomizer?: number);
  16848. /**
  16849. * Called by the particle System when the direction is computed for the created particle.
  16850. * @param worldMatrix is the world matrix of the particle system
  16851. * @param directionToUpdate is the direction vector to update with the result
  16852. * @param particle is the particle we are computed the direction for
  16853. * @param isLocal defines if the direction should be set in local space
  16854. */
  16855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16856. /**
  16857. * Called by the particle System when the position is computed for the created particle.
  16858. * @param worldMatrix is the world matrix of the particle system
  16859. * @param positionToUpdate is the position vector to update with the result
  16860. * @param particle is the particle we are computed the position for
  16861. * @param isLocal defines if the position should be set in local space
  16862. */
  16863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16864. /**
  16865. * Clones the current emitter and returns a copy of it
  16866. * @returns the new emitter
  16867. */
  16868. clone(): SphereParticleEmitter;
  16869. /**
  16870. * Called by the GPUParticleSystem to setup the update shader
  16871. * @param effect defines the update shader
  16872. */
  16873. applyToShader(effect: Effect): void;
  16874. /**
  16875. * Returns a string to use to update the GPU particles update shader
  16876. * @returns a string containing the defines string
  16877. */
  16878. getEffectDefines(): string;
  16879. /**
  16880. * Returns the string "SphereParticleEmitter"
  16881. * @returns a string containing the class name
  16882. */
  16883. getClassName(): string;
  16884. /**
  16885. * Serializes the particle system to a JSON object.
  16886. * @returns the JSON object
  16887. */
  16888. serialize(): any;
  16889. /**
  16890. * Parse properties from a JSON object
  16891. * @param serializationObject defines the JSON object
  16892. */
  16893. parse(serializationObject: any): void;
  16894. }
  16895. /**
  16896. * Particle emitter emitting particles from the inside of a sphere.
  16897. * It emits the particles randomly between two vectors.
  16898. */
  16899. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16900. /**
  16901. * The min limit of the emission direction.
  16902. */
  16903. direction1: Vector3;
  16904. /**
  16905. * The max limit of the emission direction.
  16906. */
  16907. direction2: Vector3;
  16908. /**
  16909. * Creates a new instance SphereDirectedParticleEmitter
  16910. * @param radius the radius of the emission sphere (1 by default)
  16911. * @param direction1 the min limit of the emission direction (up vector by default)
  16912. * @param direction2 the max limit of the emission direction (up vector by default)
  16913. */
  16914. constructor(radius?: number,
  16915. /**
  16916. * The min limit of the emission direction.
  16917. */
  16918. direction1?: Vector3,
  16919. /**
  16920. * The max limit of the emission direction.
  16921. */
  16922. direction2?: Vector3);
  16923. /**
  16924. * Called by the particle System when the direction is computed for the created particle.
  16925. * @param worldMatrix is the world matrix of the particle system
  16926. * @param directionToUpdate is the direction vector to update with the result
  16927. * @param particle is the particle we are computed the direction for
  16928. */
  16929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16930. /**
  16931. * Clones the current emitter and returns a copy of it
  16932. * @returns the new emitter
  16933. */
  16934. clone(): SphereDirectedParticleEmitter;
  16935. /**
  16936. * Called by the GPUParticleSystem to setup the update shader
  16937. * @param effect defines the update shader
  16938. */
  16939. applyToShader(effect: Effect): void;
  16940. /**
  16941. * Returns a string to use to update the GPU particles update shader
  16942. * @returns a string containing the defines string
  16943. */
  16944. getEffectDefines(): string;
  16945. /**
  16946. * Returns the string "SphereDirectedParticleEmitter"
  16947. * @returns a string containing the class name
  16948. */
  16949. getClassName(): string;
  16950. /**
  16951. * Serializes the particle system to a JSON object.
  16952. * @returns the JSON object
  16953. */
  16954. serialize(): any;
  16955. /**
  16956. * Parse properties from a JSON object
  16957. * @param serializationObject defines the JSON object
  16958. */
  16959. parse(serializationObject: any): void;
  16960. }
  16961. }
  16962. declare module BABYLON {
  16963. /**
  16964. * Particle emitter emitting particles from a custom list of positions.
  16965. */
  16966. export class CustomParticleEmitter implements IParticleEmitterType {
  16967. /**
  16968. * Gets or sets the position generator that will create the initial position of each particle.
  16969. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16970. */
  16971. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16972. /**
  16973. * Gets or sets the destination generator that will create the final destination of each particle.
  16974. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16975. */
  16976. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16977. /**
  16978. * Creates a new instance CustomParticleEmitter
  16979. */
  16980. constructor();
  16981. /**
  16982. * Called by the particle System when the direction is computed for the created particle.
  16983. * @param worldMatrix is the world matrix of the particle system
  16984. * @param directionToUpdate is the direction vector to update with the result
  16985. * @param particle is the particle we are computed the direction for
  16986. * @param isLocal defines if the direction should be set in local space
  16987. */
  16988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16989. /**
  16990. * Called by the particle System when the position is computed for the created particle.
  16991. * @param worldMatrix is the world matrix of the particle system
  16992. * @param positionToUpdate is the position vector to update with the result
  16993. * @param particle is the particle we are computed the position for
  16994. * @param isLocal defines if the position should be set in local space
  16995. */
  16996. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16997. /**
  16998. * Clones the current emitter and returns a copy of it
  16999. * @returns the new emitter
  17000. */
  17001. clone(): CustomParticleEmitter;
  17002. /**
  17003. * Called by the GPUParticleSystem to setup the update shader
  17004. * @param effect defines the update shader
  17005. */
  17006. applyToShader(effect: Effect): void;
  17007. /**
  17008. * Returns a string to use to update the GPU particles update shader
  17009. * @returns a string containing the defines string
  17010. */
  17011. getEffectDefines(): string;
  17012. /**
  17013. * Returns the string "PointParticleEmitter"
  17014. * @returns a string containing the class name
  17015. */
  17016. getClassName(): string;
  17017. /**
  17018. * Serializes the particle system to a JSON object.
  17019. * @returns the JSON object
  17020. */
  17021. serialize(): any;
  17022. /**
  17023. * Parse properties from a JSON object
  17024. * @param serializationObject defines the JSON object
  17025. */
  17026. parse(serializationObject: any): void;
  17027. }
  17028. }
  17029. declare module BABYLON {
  17030. /**
  17031. * Particle emitter emitting particles from the inside of a box.
  17032. * It emits the particles randomly between 2 given directions.
  17033. */
  17034. export class MeshParticleEmitter implements IParticleEmitterType {
  17035. private _indices;
  17036. private _positions;
  17037. private _normals;
  17038. private _storedNormal;
  17039. private _mesh;
  17040. /**
  17041. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17042. */
  17043. direction1: Vector3;
  17044. /**
  17045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17046. */
  17047. direction2: Vector3;
  17048. /**
  17049. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  17050. */
  17051. useMeshNormalsForDirection: boolean;
  17052. /** Defines the mesh to use as source */
  17053. get mesh(): Nullable<AbstractMesh>;
  17054. set mesh(value: Nullable<AbstractMesh>);
  17055. /**
  17056. * Creates a new instance MeshParticleEmitter
  17057. * @param mesh defines the mesh to use as source
  17058. */
  17059. constructor(mesh?: Nullable<AbstractMesh>);
  17060. /**
  17061. * Called by the particle System when the direction is computed for the created particle.
  17062. * @param worldMatrix is the world matrix of the particle system
  17063. * @param directionToUpdate is the direction vector to update with the result
  17064. * @param particle is the particle we are computed the direction for
  17065. * @param isLocal defines if the direction should be set in local space
  17066. */
  17067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17068. /**
  17069. * Called by the particle System when the position is computed for the created particle.
  17070. * @param worldMatrix is the world matrix of the particle system
  17071. * @param positionToUpdate is the position vector to update with the result
  17072. * @param particle is the particle we are computed the position for
  17073. * @param isLocal defines if the position should be set in local space
  17074. */
  17075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  17076. /**
  17077. * Clones the current emitter and returns a copy of it
  17078. * @returns the new emitter
  17079. */
  17080. clone(): MeshParticleEmitter;
  17081. /**
  17082. * Called by the GPUParticleSystem to setup the update shader
  17083. * @param effect defines the update shader
  17084. */
  17085. applyToShader(effect: Effect): void;
  17086. /**
  17087. * Returns a string to use to update the GPU particles update shader
  17088. * @returns a string containing the defines string
  17089. */
  17090. getEffectDefines(): string;
  17091. /**
  17092. * Returns the string "BoxParticleEmitter"
  17093. * @returns a string containing the class name
  17094. */
  17095. getClassName(): string;
  17096. /**
  17097. * Serializes the particle system to a JSON object.
  17098. * @returns the JSON object
  17099. */
  17100. serialize(): any;
  17101. /**
  17102. * Parse properties from a JSON object
  17103. * @param serializationObject defines the JSON object
  17104. * @param scene defines the hosting scene
  17105. */
  17106. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17107. }
  17108. }
  17109. declare module BABYLON {
  17110. /**
  17111. * Interface representing a particle system in Babylon.js.
  17112. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17113. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17114. */
  17115. export interface IParticleSystem {
  17116. /**
  17117. * List of animations used by the particle system.
  17118. */
  17119. animations: Animation[];
  17120. /**
  17121. * The id of the Particle system.
  17122. */
  17123. id: string;
  17124. /**
  17125. * The name of the Particle system.
  17126. */
  17127. name: string;
  17128. /**
  17129. * The emitter represents the Mesh or position we are attaching the particle system to.
  17130. */
  17131. emitter: Nullable<AbstractMesh | Vector3>;
  17132. /**
  17133. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17134. */
  17135. isBillboardBased: boolean;
  17136. /**
  17137. * The rendering group used by the Particle system to chose when to render.
  17138. */
  17139. renderingGroupId: number;
  17140. /**
  17141. * The layer mask we are rendering the particles through.
  17142. */
  17143. layerMask: number;
  17144. /**
  17145. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17146. */
  17147. updateSpeed: number;
  17148. /**
  17149. * The amount of time the particle system is running (depends of the overall update speed).
  17150. */
  17151. targetStopDuration: number;
  17152. /**
  17153. * The texture used to render each particle. (this can be a spritesheet)
  17154. */
  17155. particleTexture: Nullable<BaseTexture>;
  17156. /**
  17157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17158. */
  17159. blendMode: number;
  17160. /**
  17161. * Minimum life time of emitting particles.
  17162. */
  17163. minLifeTime: number;
  17164. /**
  17165. * Maximum life time of emitting particles.
  17166. */
  17167. maxLifeTime: number;
  17168. /**
  17169. * Minimum Size of emitting particles.
  17170. */
  17171. minSize: number;
  17172. /**
  17173. * Maximum Size of emitting particles.
  17174. */
  17175. maxSize: number;
  17176. /**
  17177. * Minimum scale of emitting particles on X axis.
  17178. */
  17179. minScaleX: number;
  17180. /**
  17181. * Maximum scale of emitting particles on X axis.
  17182. */
  17183. maxScaleX: number;
  17184. /**
  17185. * Minimum scale of emitting particles on Y axis.
  17186. */
  17187. minScaleY: number;
  17188. /**
  17189. * Maximum scale of emitting particles on Y axis.
  17190. */
  17191. maxScaleY: number;
  17192. /**
  17193. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17194. */
  17195. color1: Color4;
  17196. /**
  17197. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17198. */
  17199. color2: Color4;
  17200. /**
  17201. * Color the particle will have at the end of its lifetime.
  17202. */
  17203. colorDead: Color4;
  17204. /**
  17205. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17206. */
  17207. emitRate: number;
  17208. /**
  17209. * You can use gravity if you want to give an orientation to your particles.
  17210. */
  17211. gravity: Vector3;
  17212. /**
  17213. * Minimum power of emitting particles.
  17214. */
  17215. minEmitPower: number;
  17216. /**
  17217. * Maximum power of emitting particles.
  17218. */
  17219. maxEmitPower: number;
  17220. /**
  17221. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17222. */
  17223. minAngularSpeed: number;
  17224. /**
  17225. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17226. */
  17227. maxAngularSpeed: number;
  17228. /**
  17229. * Gets or sets the minimal initial rotation in radians.
  17230. */
  17231. minInitialRotation: number;
  17232. /**
  17233. * Gets or sets the maximal initial rotation in radians.
  17234. */
  17235. maxInitialRotation: number;
  17236. /**
  17237. * The particle emitter type defines the emitter used by the particle system.
  17238. * It can be for example box, sphere, or cone...
  17239. */
  17240. particleEmitterType: Nullable<IParticleEmitterType>;
  17241. /**
  17242. * Defines the delay in milliseconds before starting the system (0 by default)
  17243. */
  17244. startDelay: number;
  17245. /**
  17246. * 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
  17247. */
  17248. preWarmCycles: number;
  17249. /**
  17250. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17251. */
  17252. preWarmStepOffset: number;
  17253. /**
  17254. * 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)
  17255. */
  17256. spriteCellChangeSpeed: number;
  17257. /**
  17258. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17259. */
  17260. startSpriteCellID: number;
  17261. /**
  17262. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17263. */
  17264. endSpriteCellID: number;
  17265. /**
  17266. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17267. */
  17268. spriteCellWidth: number;
  17269. /**
  17270. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17271. */
  17272. spriteCellHeight: number;
  17273. /**
  17274. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17275. */
  17276. spriteRandomStartCell: boolean;
  17277. /**
  17278. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17279. */
  17280. isAnimationSheetEnabled: boolean;
  17281. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17282. translationPivot: Vector2;
  17283. /**
  17284. * Gets or sets a texture used to add random noise to particle positions
  17285. */
  17286. noiseTexture: Nullable<BaseTexture>;
  17287. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17288. noiseStrength: Vector3;
  17289. /**
  17290. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17291. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17292. */
  17293. billboardMode: number;
  17294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17295. limitVelocityDamping: number;
  17296. /**
  17297. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17298. */
  17299. beginAnimationOnStart: boolean;
  17300. /**
  17301. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17302. */
  17303. beginAnimationFrom: number;
  17304. /**
  17305. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17306. */
  17307. beginAnimationTo: number;
  17308. /**
  17309. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17310. */
  17311. beginAnimationLoop: boolean;
  17312. /**
  17313. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17314. */
  17315. disposeOnStop: boolean;
  17316. /**
  17317. * If you want to launch only a few particles at once, that can be done, as well.
  17318. */
  17319. manualEmitCount: number;
  17320. /**
  17321. * Specifies if the particles are updated in emitter local space or world space
  17322. */
  17323. isLocal: boolean;
  17324. /** Snippet ID if the particle system was created from the snippet server */
  17325. snippetId: string;
  17326. /** Gets or sets a matrix to use to compute projection */
  17327. defaultProjectionMatrix: Matrix;
  17328. /**
  17329. * Gets the maximum number of particles active at the same time.
  17330. * @returns The max number of active particles.
  17331. */
  17332. getCapacity(): number;
  17333. /**
  17334. * Gets the number of particles active at the same time.
  17335. * @returns The number of active particles.
  17336. */
  17337. getActiveCount(): number;
  17338. /**
  17339. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17340. * @returns True if it has been started, otherwise false.
  17341. */
  17342. isStarted(): boolean;
  17343. /**
  17344. * Animates the particle system for this frame.
  17345. */
  17346. animate(): void;
  17347. /**
  17348. * Renders the particle system in its current state.
  17349. * @returns the current number of particles
  17350. */
  17351. render(): number;
  17352. /**
  17353. * Dispose the particle system and frees its associated resources.
  17354. * @param disposeTexture defines if the particle texture must be disposed as well (true by default)
  17355. */
  17356. dispose(disposeTexture?: boolean): void;
  17357. /**
  17358. * An event triggered when the system is disposed
  17359. */
  17360. onDisposeObservable: Observable<IParticleSystem>;
  17361. /**
  17362. * An event triggered when the system is stopped
  17363. */
  17364. onStoppedObservable: Observable<IParticleSystem>;
  17365. /**
  17366. * Clones the particle system.
  17367. * @param name The name of the cloned object
  17368. * @param newEmitter The new emitter to use
  17369. * @returns the cloned particle system
  17370. */
  17371. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17372. /**
  17373. * Serializes the particle system to a JSON object
  17374. * @param serializeTexture defines if the texture must be serialized as well
  17375. * @returns the JSON object
  17376. */
  17377. serialize(serializeTexture: boolean): any;
  17378. /**
  17379. * Rebuild the particle system
  17380. */
  17381. rebuild(): void;
  17382. /** Force the system to rebuild all gradients that need to be resync */
  17383. forceRefreshGradients(): void;
  17384. /**
  17385. * Starts the particle system and begins to emit
  17386. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17387. */
  17388. start(delay?: number): void;
  17389. /**
  17390. * Stops the particle system.
  17391. */
  17392. stop(): void;
  17393. /**
  17394. * Remove all active particles
  17395. */
  17396. reset(): void;
  17397. /**
  17398. * Gets a boolean indicating that the system is stopping
  17399. * @returns true if the system is currently stopping
  17400. */
  17401. isStopping(): boolean;
  17402. /**
  17403. * Is this system ready to be used/rendered
  17404. * @return true if the system is ready
  17405. */
  17406. isReady(): boolean;
  17407. /**
  17408. * Returns the string "ParticleSystem"
  17409. * @returns a string containing the class name
  17410. */
  17411. getClassName(): string;
  17412. /**
  17413. * Gets the custom effect used to render the particles
  17414. * @param blendMode Blend mode for which the effect should be retrieved
  17415. * @returns The effect
  17416. */
  17417. getCustomEffect(blendMode: number): Nullable<Effect>;
  17418. /**
  17419. * Sets the custom effect used to render the particles
  17420. * @param effect The effect to set
  17421. * @param blendMode Blend mode for which the effect should be set
  17422. */
  17423. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17424. /**
  17425. * Fill the defines array according to the current settings of the particle system
  17426. * @param defines Array to be updated
  17427. * @param blendMode blend mode to take into account when updating the array
  17428. */
  17429. fillDefines(defines: Array<string>, blendMode: number): void;
  17430. /**
  17431. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17432. * @param uniforms Uniforms array to fill
  17433. * @param attributes Attributes array to fill
  17434. * @param samplers Samplers array to fill
  17435. */
  17436. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17437. /**
  17438. * Observable that will be called just before the particles are drawn
  17439. */
  17440. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17441. /**
  17442. * Gets the name of the particle vertex shader
  17443. */
  17444. vertexShaderName: string;
  17445. /**
  17446. * Adds a new color gradient
  17447. * @param gradient defines the gradient to use (between 0 and 1)
  17448. * @param color1 defines the color to affect to the specified gradient
  17449. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17450. * @returns the current particle system
  17451. */
  17452. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17453. /**
  17454. * Remove a specific color gradient
  17455. * @param gradient defines the gradient to remove
  17456. * @returns the current particle system
  17457. */
  17458. removeColorGradient(gradient: number): IParticleSystem;
  17459. /**
  17460. * Adds a new size gradient
  17461. * @param gradient defines the gradient to use (between 0 and 1)
  17462. * @param factor defines the size factor to affect to the specified gradient
  17463. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17464. * @returns the current particle system
  17465. */
  17466. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17467. /**
  17468. * Remove a specific size gradient
  17469. * @param gradient defines the gradient to remove
  17470. * @returns the current particle system
  17471. */
  17472. removeSizeGradient(gradient: number): IParticleSystem;
  17473. /**
  17474. * Gets the current list of color gradients.
  17475. * You must use addColorGradient and removeColorGradient to update this list
  17476. * @returns the list of color gradients
  17477. */
  17478. getColorGradients(): Nullable<Array<ColorGradient>>;
  17479. /**
  17480. * Gets the current list of size gradients.
  17481. * You must use addSizeGradient and removeSizeGradient to update this list
  17482. * @returns the list of size gradients
  17483. */
  17484. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17485. /**
  17486. * Gets the current list of angular speed gradients.
  17487. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list
  17488. * @returns the list of angular speed gradients
  17489. */
  17490. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17491. /**
  17492. * Adds a new angular speed gradient
  17493. * @param gradient defines the gradient to use (between 0 and 1)
  17494. * @param factor defines the angular speed to affect to the specified gradient
  17495. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17496. * @returns the current particle system
  17497. */
  17498. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17499. /**
  17500. * Remove a specific angular speed gradient
  17501. * @param gradient defines the gradient to remove
  17502. * @returns the current particle system
  17503. */
  17504. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17505. /**
  17506. * Gets the current list of velocity gradients.
  17507. * You must use addVelocityGradient and removeVelocityGradient to update this list
  17508. * @returns the list of velocity gradients
  17509. */
  17510. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17511. /**
  17512. * Adds a new velocity gradient
  17513. * @param gradient defines the gradient to use (between 0 and 1)
  17514. * @param factor defines the velocity to affect to the specified gradient
  17515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17516. * @returns the current particle system
  17517. */
  17518. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17519. /**
  17520. * Remove a specific velocity gradient
  17521. * @param gradient defines the gradient to remove
  17522. * @returns the current particle system
  17523. */
  17524. removeVelocityGradient(gradient: number): IParticleSystem;
  17525. /**
  17526. * Gets the current list of limit velocity gradients.
  17527. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list
  17528. * @returns the list of limit velocity gradients
  17529. */
  17530. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17531. /**
  17532. * Adds a new limit velocity gradient
  17533. * @param gradient defines the gradient to use (between 0 and 1)
  17534. * @param factor defines the limit velocity to affect to the specified gradient
  17535. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17536. * @returns the current particle system
  17537. */
  17538. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17539. /**
  17540. * Remove a specific limit velocity gradient
  17541. * @param gradient defines the gradient to remove
  17542. * @returns the current particle system
  17543. */
  17544. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17545. /**
  17546. * Adds a new drag gradient
  17547. * @param gradient defines the gradient to use (between 0 and 1)
  17548. * @param factor defines the drag to affect to the specified gradient
  17549. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17550. * @returns the current particle system
  17551. */
  17552. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17553. /**
  17554. * Remove a specific drag gradient
  17555. * @param gradient defines the gradient to remove
  17556. * @returns the current particle system
  17557. */
  17558. removeDragGradient(gradient: number): IParticleSystem;
  17559. /**
  17560. * Gets the current list of drag gradients.
  17561. * You must use addDragGradient and removeDragGradient to update this list
  17562. * @returns the list of drag gradients
  17563. */
  17564. getDragGradients(): Nullable<Array<FactorGradient>>;
  17565. /**
  17566. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17567. * @param gradient defines the gradient to use (between 0 and 1)
  17568. * @param factor defines the emit rate to affect to the specified gradient
  17569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17570. * @returns the current particle system
  17571. */
  17572. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17573. /**
  17574. * Remove a specific emit rate gradient
  17575. * @param gradient defines the gradient to remove
  17576. * @returns the current particle system
  17577. */
  17578. removeEmitRateGradient(gradient: number): IParticleSystem;
  17579. /**
  17580. * Gets the current list of emit rate gradients.
  17581. * You must use addEmitRateGradient and removeEmitRateGradient to update this list
  17582. * @returns the list of emit rate gradients
  17583. */
  17584. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17585. /**
  17586. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17587. * @param gradient defines the gradient to use (between 0 and 1)
  17588. * @param factor defines the start size to affect to the specified gradient
  17589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17590. * @returns the current particle system
  17591. */
  17592. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17593. /**
  17594. * Remove a specific start size gradient
  17595. * @param gradient defines the gradient to remove
  17596. * @returns the current particle system
  17597. */
  17598. removeStartSizeGradient(gradient: number): IParticleSystem;
  17599. /**
  17600. * Gets the current list of start size gradients.
  17601. * You must use addStartSizeGradient and removeStartSizeGradient to update this list
  17602. * @returns the list of start size gradients
  17603. */
  17604. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17605. /**
  17606. * Adds a new life time gradient
  17607. * @param gradient defines the gradient to use (between 0 and 1)
  17608. * @param factor defines the life time factor to affect to the specified gradient
  17609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17610. * @returns the current particle system
  17611. */
  17612. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17613. /**
  17614. * Remove a specific life time gradient
  17615. * @param gradient defines the gradient to remove
  17616. * @returns the current particle system
  17617. */
  17618. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17619. /**
  17620. * Gets the current list of life time gradients.
  17621. * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list
  17622. * @returns the list of life time gradients
  17623. */
  17624. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17625. /**
  17626. * Gets the current list of color gradients.
  17627. * You must use addColorGradient and removeColorGradient to update this list
  17628. * @returns the list of color gradients
  17629. */
  17630. getColorGradients(): Nullable<Array<ColorGradient>>;
  17631. /**
  17632. * Adds a new ramp gradient used to remap particle colors
  17633. * @param gradient defines the gradient to use (between 0 and 1)
  17634. * @param color defines the color to affect to the specified gradient
  17635. * @returns the current particle system
  17636. */
  17637. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17638. /**
  17639. * Gets the current list of ramp gradients.
  17640. * You must use addRampGradient and removeRampGradient to update this list
  17641. * @returns the list of ramp gradients
  17642. */
  17643. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17644. /** Gets or sets a boolean indicating that ramp gradients must be used
  17645. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17646. */
  17647. useRampGradients: boolean;
  17648. /**
  17649. * Adds a new color remap gradient
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param min defines the color remap minimal range
  17652. * @param max defines the color remap maximal range
  17653. * @returns the current particle system
  17654. */
  17655. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17656. /**
  17657. * Gets the current list of color remap gradients.
  17658. * You must use addColorRemapGradient and removeColorRemapGradient to update this list
  17659. * @returns the list of color remap gradients
  17660. */
  17661. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17662. /**
  17663. * Adds a new alpha remap gradient
  17664. * @param gradient defines the gradient to use (between 0 and 1)
  17665. * @param min defines the alpha remap minimal range
  17666. * @param max defines the alpha remap maximal range
  17667. * @returns the current particle system
  17668. */
  17669. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17670. /**
  17671. * Gets the current list of alpha remap gradients.
  17672. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list
  17673. * @returns the list of alpha remap gradients
  17674. */
  17675. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17676. /**
  17677. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17680. * @returns the emitter
  17681. */
  17682. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17683. /**
  17684. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17685. * @param radius The radius of the hemisphere to emit from
  17686. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17687. * @returns the emitter
  17688. */
  17689. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17690. /**
  17691. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17692. * @param radius The radius of the sphere to emit from
  17693. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17694. * @returns the emitter
  17695. */
  17696. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17697. /**
  17698. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17699. * @param radius The radius of the sphere to emit from
  17700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17702. * @returns the emitter
  17703. */
  17704. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17705. /**
  17706. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17707. * @param radius The radius of the emission cylinder
  17708. * @param height The height of the emission cylinder
  17709. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17710. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17711. * @returns the emitter
  17712. */
  17713. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17714. /**
  17715. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17716. * @param radius The radius of the cylinder to emit from
  17717. * @param height The height of the emission cylinder
  17718. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17721. * @returns the emitter
  17722. */
  17723. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17724. /**
  17725. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17726. * @param radius The radius of the cone to emit from
  17727. * @param angle The base angle of the cone
  17728. * @returns the emitter
  17729. */
  17730. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17731. /**
  17732. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17733. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17734. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17735. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17736. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17737. * @returns the emitter
  17738. */
  17739. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17740. /**
  17741. * Get hosting scene
  17742. * @returns the scene
  17743. */
  17744. getScene(): Nullable<Scene>;
  17745. }
  17746. }
  17747. declare module BABYLON {
  17748. /**
  17749. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17750. */
  17751. export class ColorSplitterBlock extends NodeMaterialBlock {
  17752. /**
  17753. * Create a new ColorSplitterBlock
  17754. * @param name defines the block name
  17755. */
  17756. constructor(name: string);
  17757. /**
  17758. * Gets the current class name
  17759. * @returns the class name
  17760. */
  17761. getClassName(): string;
  17762. /**
  17763. * Gets the rgba component (input)
  17764. */
  17765. get rgba(): NodeMaterialConnectionPoint;
  17766. /**
  17767. * Gets the rgb component (input)
  17768. */
  17769. get rgbIn(): NodeMaterialConnectionPoint;
  17770. /**
  17771. * Gets the rgb component (output)
  17772. */
  17773. get rgbOut(): NodeMaterialConnectionPoint;
  17774. /**
  17775. * Gets the r component (output)
  17776. */
  17777. get r(): NodeMaterialConnectionPoint;
  17778. /**
  17779. * Gets the g component (output)
  17780. */
  17781. get g(): NodeMaterialConnectionPoint;
  17782. /**
  17783. * Gets the b component (output)
  17784. */
  17785. get b(): NodeMaterialConnectionPoint;
  17786. /**
  17787. * Gets the a component (output)
  17788. */
  17789. get a(): NodeMaterialConnectionPoint;
  17790. protected _inputRename(name: string): string;
  17791. protected _outputRename(name: string): string;
  17792. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17793. }
  17794. }
  17795. declare module BABYLON {
  17796. /**
  17797. * Operations supported by the Trigonometry block
  17798. */
  17799. export enum TrigonometryBlockOperations {
  17800. /** Cos */
  17801. Cos = 0,
  17802. /** Sin */
  17803. Sin = 1,
  17804. /** Abs */
  17805. Abs = 2,
  17806. /** Exp */
  17807. Exp = 3,
  17808. /** Exp2 */
  17809. Exp2 = 4,
  17810. /** Round */
  17811. Round = 5,
  17812. /** Floor */
  17813. Floor = 6,
  17814. /** Ceiling */
  17815. Ceiling = 7,
  17816. /** Square root */
  17817. Sqrt = 8,
  17818. /** Log */
  17819. Log = 9,
  17820. /** Tangent */
  17821. Tan = 10,
  17822. /** Arc tangent */
  17823. ArcTan = 11,
  17824. /** Arc cosinus */
  17825. ArcCos = 12,
  17826. /** Arc sinus */
  17827. ArcSin = 13,
  17828. /** Fraction */
  17829. Fract = 14,
  17830. /** Sign */
  17831. Sign = 15,
  17832. /** To radians (from degrees) */
  17833. Radians = 16,
  17834. /** To degrees (from radians) */
  17835. Degrees = 17
  17836. }
  17837. /**
  17838. * Block used to apply trigonometry operation to floats
  17839. */
  17840. export class TrigonometryBlock extends NodeMaterialBlock {
  17841. /**
  17842. * Gets or sets the operation applied by the block
  17843. */
  17844. operation: TrigonometryBlockOperations;
  17845. /**
  17846. * Creates a new TrigonometryBlock
  17847. * @param name defines the block name
  17848. */
  17849. constructor(name: string);
  17850. /**
  17851. * Gets the current class name
  17852. * @returns the class name
  17853. */
  17854. getClassName(): string;
  17855. /**
  17856. * Gets the input component
  17857. */
  17858. get input(): NodeMaterialConnectionPoint;
  17859. /**
  17860. * Gets the output component
  17861. */
  17862. get output(): NodeMaterialConnectionPoint;
  17863. protected _buildBlock(state: NodeMaterialBuildState): this;
  17864. serialize(): any;
  17865. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17866. protected _dumpPropertiesCode(): string;
  17867. }
  17868. }
  17869. declare module BABYLON {
  17870. /**
  17871. * Interface used to configure the node material editor
  17872. */
  17873. export interface INodeMaterialEditorOptions {
  17874. /** Define the URl to load node editor script */
  17875. editorURL?: string;
  17876. }
  17877. /** @hidden */
  17878. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17879. NORMAL: boolean;
  17880. TANGENT: boolean;
  17881. UV1: boolean;
  17882. /** BONES */
  17883. NUM_BONE_INFLUENCERS: number;
  17884. BonesPerMesh: number;
  17885. BONETEXTURE: boolean;
  17886. /** MORPH TARGETS */
  17887. MORPHTARGETS: boolean;
  17888. MORPHTARGETS_NORMAL: boolean;
  17889. MORPHTARGETS_TANGENT: boolean;
  17890. MORPHTARGETS_UV: boolean;
  17891. NUM_MORPH_INFLUENCERS: number;
  17892. MORPHTARGETS_TEXTURE: boolean;
  17893. /** IMAGE PROCESSING */
  17894. IMAGEPROCESSING: boolean;
  17895. VIGNETTE: boolean;
  17896. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17897. VIGNETTEBLENDMODEOPAQUE: boolean;
  17898. TONEMAPPING: boolean;
  17899. TONEMAPPING_ACES: boolean;
  17900. CONTRAST: boolean;
  17901. EXPOSURE: boolean;
  17902. COLORCURVES: boolean;
  17903. COLORGRADING: boolean;
  17904. COLORGRADING3D: boolean;
  17905. SAMPLER3DGREENDEPTH: boolean;
  17906. SAMPLER3DBGRMAP: boolean;
  17907. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17908. /** MISC. */
  17909. BUMPDIRECTUV: number;
  17910. constructor();
  17911. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17912. }
  17913. /**
  17914. * Class used to configure NodeMaterial
  17915. */
  17916. export interface INodeMaterialOptions {
  17917. /**
  17918. * Defines if blocks should emit comments
  17919. */
  17920. emitComments: boolean;
  17921. }
  17922. /**
  17923. * Class used to create a node based material built by assembling shader blocks
  17924. */
  17925. export class NodeMaterial extends PushMaterial {
  17926. private static _BuildIdGenerator;
  17927. private _options;
  17928. private _vertexCompilationState;
  17929. private _fragmentCompilationState;
  17930. private _sharedData;
  17931. private _buildId;
  17932. private _buildWasSuccessful;
  17933. private _cachedWorldViewMatrix;
  17934. private _cachedWorldViewProjectionMatrix;
  17935. private _optimizers;
  17936. private _animationFrame;
  17937. /** Define the Url to load node editor script */
  17938. static EditorURL: string;
  17939. /** Define the Url to load snippets */
  17940. static SnippetUrl: string;
  17941. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17942. static IgnoreTexturesAtLoadTime: boolean;
  17943. private BJSNODEMATERIALEDITOR;
  17944. /** Get the inspector from bundle or global */
  17945. private _getGlobalNodeMaterialEditor;
  17946. /**
  17947. * Snippet ID if the material was created from the snippet server
  17948. */
  17949. snippetId: string;
  17950. /**
  17951. * Gets or sets data used by visual editor
  17952. * @see https://nme.babylonjs.com
  17953. */
  17954. editorData: any;
  17955. /**
  17956. * 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)
  17957. */
  17958. ignoreAlpha: boolean;
  17959. /**
  17960. * Defines the maximum number of lights that can be used in the material
  17961. */
  17962. maxSimultaneousLights: number;
  17963. /**
  17964. * Observable raised when the material is built
  17965. */
  17966. onBuildObservable: Observable<NodeMaterial>;
  17967. /**
  17968. * Gets or sets the root nodes of the material vertex shader
  17969. */
  17970. _vertexOutputNodes: NodeMaterialBlock[];
  17971. /**
  17972. * Gets or sets the root nodes of the material fragment (pixel) shader
  17973. */
  17974. _fragmentOutputNodes: NodeMaterialBlock[];
  17975. /** Gets or sets options to control the node material overall behavior */
  17976. get options(): INodeMaterialOptions;
  17977. set options(options: INodeMaterialOptions);
  17978. /**
  17979. * Default configuration related to image processing available in the standard Material.
  17980. */
  17981. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17982. /**
  17983. * Gets the image processing configuration used either in this material.
  17984. */
  17985. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17986. /**
  17987. * Sets the Default image processing configuration used either in the this material.
  17988. *
  17989. * If sets to null, the scene one is in use.
  17990. */
  17991. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17992. /**
  17993. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17994. */
  17995. attachedBlocks: NodeMaterialBlock[];
  17996. /**
  17997. * Specifies the mode of the node material
  17998. * @hidden
  17999. */
  18000. _mode: NodeMaterialModes;
  18001. /**
  18002. * Gets the mode property
  18003. */
  18004. get mode(): NodeMaterialModes;
  18005. /**
  18006. * A free comment about the material
  18007. */
  18008. comment: string;
  18009. /**
  18010. * Create a new node based material
  18011. * @param name defines the material name
  18012. * @param scene defines the hosting scene
  18013. * @param options defines creation option
  18014. */
  18015. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  18016. /**
  18017. * Gets the current class name of the material e.g. "NodeMaterial"
  18018. * @returns the class name
  18019. */
  18020. getClassName(): string;
  18021. /**
  18022. * Keep track of the image processing observer to allow dispose and replace.
  18023. */
  18024. private _imageProcessingObserver;
  18025. /**
  18026. * Attaches a new image processing configuration to the Standard Material.
  18027. * @param configuration
  18028. */
  18029. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18030. /**
  18031. * Get a block by its name
  18032. * @param name defines the name of the block to retrieve
  18033. * @returns the required block or null if not found
  18034. */
  18035. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  18036. /**
  18037. * Get a block by its name
  18038. * @param predicate defines the predicate used to find the good candidate
  18039. * @returns the required block or null if not found
  18040. */
  18041. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  18042. /**
  18043. * Get an input block by its name
  18044. * @param predicate defines the predicate used to find the good candidate
  18045. * @returns the required input block or null if not found
  18046. */
  18047. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  18048. /**
  18049. * Gets the list of input blocks attached to this material
  18050. * @returns an array of InputBlocks
  18051. */
  18052. getInputBlocks(): InputBlock[];
  18053. /**
  18054. * Adds a new optimizer to the list of optimizers
  18055. * @param optimizer defines the optimizers to add
  18056. * @returns the current material
  18057. */
  18058. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18059. /**
  18060. * Remove an optimizer from the list of optimizers
  18061. * @param optimizer defines the optimizers to remove
  18062. * @returns the current material
  18063. */
  18064. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  18065. /**
  18066. * Add a new block to the list of output nodes
  18067. * @param node defines the node to add
  18068. * @returns the current material
  18069. */
  18070. addOutputNode(node: NodeMaterialBlock): this;
  18071. /**
  18072. * Remove a block from the list of root nodes
  18073. * @param node defines the node to remove
  18074. * @returns the current material
  18075. */
  18076. removeOutputNode(node: NodeMaterialBlock): this;
  18077. private _addVertexOutputNode;
  18078. private _removeVertexOutputNode;
  18079. private _addFragmentOutputNode;
  18080. private _removeFragmentOutputNode;
  18081. /**
  18082. * Specifies if the material will require alpha blending
  18083. * @returns a boolean specifying if alpha blending is needed
  18084. */
  18085. needAlphaBlending(): boolean;
  18086. /**
  18087. * Specifies if this material should be rendered in alpha test mode
  18088. * @returns a boolean specifying if an alpha test is needed.
  18089. */
  18090. needAlphaTesting(): boolean;
  18091. private _initializeBlock;
  18092. private _resetDualBlocks;
  18093. /**
  18094. * Remove a block from the current node material
  18095. * @param block defines the block to remove
  18096. */
  18097. removeBlock(block: NodeMaterialBlock): void;
  18098. /**
  18099. * Build the material and generates the inner effect
  18100. * @param verbose defines if the build should log activity
  18101. */
  18102. build(verbose?: boolean): void;
  18103. /**
  18104. * Runs an otpimization phase to try to improve the shader code
  18105. */
  18106. optimize(): void;
  18107. private _prepareDefinesForAttributes;
  18108. /**
  18109. * Create a post process from the material
  18110. * @param camera The camera to apply the render pass to.
  18111. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18113. * @param engine The engine which the post process will be applied. (default: current engine)
  18114. * @param reusable If the post process can be reused on the same frame. (default: false)
  18115. * @param textureType Type of textures used when performing the post process. (default: 0)
  18116. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18117. * @returns the post process created
  18118. */
  18119. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18120. /**
  18121. * Create the post process effect from the material
  18122. * @param postProcess The post process to create the effect for
  18123. */
  18124. createEffectForPostProcess(postProcess: PostProcess): void;
  18125. private _createEffectForPostProcess;
  18126. /**
  18127. * Create a new procedural texture based on this node material
  18128. * @param size defines the size of the texture
  18129. * @param scene defines the hosting scene
  18130. * @returns the new procedural texture attached to this node material
  18131. */
  18132. createProceduralTexture(size: number | {
  18133. width: number;
  18134. height: number;
  18135. layers?: number;
  18136. }, scene: Scene): Nullable<ProceduralTexture>;
  18137. private _createEffectForParticles;
  18138. private _checkInternals;
  18139. /**
  18140. * Create the effect to be used as the custom effect for a particle system
  18141. * @param particleSystem Particle system to create the effect for
  18142. * @param onCompiled defines a function to call when the effect creation is successful
  18143. * @param onError defines a function to call when the effect creation has failed
  18144. */
  18145. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18146. private _processDefines;
  18147. /**
  18148. * Get if the submesh is ready to be used and all its information available.
  18149. * Child classes can use it to update shaders
  18150. * @param mesh defines the mesh to check
  18151. * @param subMesh defines which submesh to check
  18152. * @param useInstances specifies that instances should be used
  18153. * @returns a boolean indicating that the submesh is ready or not
  18154. */
  18155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18156. /**
  18157. * Get a string representing the shaders built by the current node graph
  18158. */
  18159. get compiledShaders(): string;
  18160. /**
  18161. * Binds the world matrix to the material
  18162. * @param world defines the world transformation matrix
  18163. */
  18164. bindOnlyWorldMatrix(world: Matrix): void;
  18165. /**
  18166. * Binds the submesh to this material by preparing the effect and shader to draw
  18167. * @param world defines the world transformation matrix
  18168. * @param mesh defines the mesh containing the submesh
  18169. * @param subMesh defines the submesh to bind the material to
  18170. */
  18171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18172. /**
  18173. * Gets the active textures from the material
  18174. * @returns an array of textures
  18175. */
  18176. getActiveTextures(): BaseTexture[];
  18177. /**
  18178. * Gets the list of texture blocks
  18179. * @returns an array of texture blocks
  18180. */
  18181. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18182. /**
  18183. * Specifies if the material uses a texture
  18184. * @param texture defines the texture to check against the material
  18185. * @returns a boolean specifying if the material uses the texture
  18186. */
  18187. hasTexture(texture: BaseTexture): boolean;
  18188. /**
  18189. * Disposes the material
  18190. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18191. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18192. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18193. */
  18194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18195. /** Creates the node editor window. */
  18196. private _createNodeEditor;
  18197. /**
  18198. * Launch the node material editor
  18199. * @param config Define the configuration of the editor
  18200. * @return a promise fulfilled when the node editor is visible
  18201. */
  18202. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18203. /**
  18204. * Clear the current material
  18205. */
  18206. clear(): void;
  18207. /**
  18208. * Clear the current material and set it to a default state
  18209. */
  18210. setToDefault(): void;
  18211. /**
  18212. * Clear the current material and set it to a default state for post process
  18213. */
  18214. setToDefaultPostProcess(): void;
  18215. /**
  18216. * Clear the current material and set it to a default state for procedural texture
  18217. */
  18218. setToDefaultProceduralTexture(): void;
  18219. /**
  18220. * Clear the current material and set it to a default state for particle
  18221. */
  18222. setToDefaultParticle(): void;
  18223. /**
  18224. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18225. * @param url defines the url to load from
  18226. * @returns a promise that will fulfil when the material is fully loaded
  18227. */
  18228. loadAsync(url: string): Promise<void>;
  18229. private _gatherBlocks;
  18230. /**
  18231. * Generate a string containing the code declaration required to create an equivalent of this material
  18232. * @returns a string
  18233. */
  18234. generateCode(): string;
  18235. /**
  18236. * Serializes this material in a JSON representation
  18237. * @returns the serialized material object
  18238. */
  18239. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18240. private _restoreConnections;
  18241. /**
  18242. * Clear the current graph and load a new one from a serialization object
  18243. * @param source defines the JSON representation of the material
  18244. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18245. * @param merge defines whether or not the source must be merged or replace the current content
  18246. */
  18247. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18248. /**
  18249. * Makes a duplicate of the current material.
  18250. * @param name - name to use for the new material.
  18251. */
  18252. clone(name: string): NodeMaterial;
  18253. /**
  18254. * Creates a node material from parsed material data
  18255. * @param source defines the JSON representation of the material
  18256. * @param scene defines the hosting scene
  18257. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18258. * @returns a new node material
  18259. */
  18260. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18261. /**
  18262. * Creates a node material from a snippet saved in a remote file
  18263. * @param name defines the name of the material to create
  18264. * @param url defines the url to load from
  18265. * @param scene defines the hosting scene
  18266. * @returns a promise that will resolve to the new node material
  18267. */
  18268. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18269. /**
  18270. * Creates a node material from a snippet saved by the node material editor
  18271. * @param snippetId defines the snippet to load
  18272. * @param scene defines the hosting scene
  18273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18274. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18275. * @returns a promise that will resolve to the new node material
  18276. */
  18277. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18278. /**
  18279. * Creates a new node material set to default basic configuration
  18280. * @param name defines the name of the material
  18281. * @param scene defines the hosting scene
  18282. * @returns a new NodeMaterial
  18283. */
  18284. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18285. }
  18286. }
  18287. declare module BABYLON {
  18288. interface ThinEngine {
  18289. /**
  18290. * Unbind a list of render target textures from the webGL context
  18291. * This is used only when drawBuffer extension or webGL2 are active
  18292. * @param textures defines the render target textures to unbind
  18293. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18294. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18295. */
  18296. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18297. /**
  18298. * Create a multi render target texture
  18299. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18300. * @param size defines the size of the texture
  18301. * @param options defines the creation options
  18302. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18303. * @returns the cube texture as an InternalTexture
  18304. */
  18305. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions, initializeBuffers?: boolean): InternalTexture[];
  18306. /**
  18307. * Update the sample count for a given multiple render target texture
  18308. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18309. * @param textures defines the textures to update
  18310. * @param samples defines the sample count to set
  18311. * @param initializeBuffers if set to true, the engine will make an initializing call of drawBuffers
  18312. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18313. */
  18314. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number, initializeBuffers?: boolean): number;
  18315. /**
  18316. * Select a subsets of attachments to draw to.
  18317. * @param attachments gl attachments
  18318. */
  18319. bindAttachments(attachments: number[]): void;
  18320. /**
  18321. * Creates a layout object to draw/clear on specific textures in a MRT
  18322. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18323. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18324. */
  18325. buildTextureLayout(textureStatus: boolean[]): number[];
  18326. /**
  18327. * Restores the webgl state to only draw on the main color attachment
  18328. * when the frame buffer associated is the canvas frame buffer
  18329. */
  18330. restoreSingleAttachment(): void;
  18331. /**
  18332. * Restores the webgl state to only draw on the main color attachment
  18333. * when the frame buffer associated is not the canvas frame buffer
  18334. */
  18335. restoreSingleAttachmentForRenderTarget(): void;
  18336. /**
  18337. * Clears a list of attachments
  18338. * @param attachments list of the attachments
  18339. * @param colorMain clear color for the main attachment (the first one)
  18340. * @param colorOthers clear color for the other attachments
  18341. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18342. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18343. */
  18344. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18345. }
  18346. }
  18347. declare module BABYLON {
  18348. /**
  18349. * Creation options of the multi render target texture.
  18350. */
  18351. export interface IMultiRenderTargetOptions {
  18352. /**
  18353. * Define if the texture needs to create mip maps after render.
  18354. */
  18355. generateMipMaps?: boolean;
  18356. /**
  18357. * Define the types of all the draw buffers we want to create
  18358. */
  18359. types?: number[];
  18360. /**
  18361. * Define the sampling modes of all the draw buffers we want to create
  18362. */
  18363. samplingModes?: number[];
  18364. /**
  18365. * Define if a depth buffer is required
  18366. */
  18367. generateDepthBuffer?: boolean;
  18368. /**
  18369. * Define if a stencil buffer is required
  18370. */
  18371. generateStencilBuffer?: boolean;
  18372. /**
  18373. * Define if a depth texture is required instead of a depth buffer
  18374. */
  18375. generateDepthTexture?: boolean;
  18376. /**
  18377. * Define the number of desired draw buffers
  18378. */
  18379. textureCount?: number;
  18380. /**
  18381. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18382. */
  18383. doNotChangeAspectRatio?: boolean;
  18384. /**
  18385. * Define the default type of the buffers we are creating
  18386. */
  18387. defaultType?: number;
  18388. /**
  18389. * Define the default type of the buffers we are creating
  18390. */
  18391. drawOnlyOnFirstAttachmentByDefault?: boolean;
  18392. }
  18393. /**
  18394. * A multi render target, like a render target provides the ability to render to a texture.
  18395. * Unlike the render target, it can render to several draw buffers in one draw.
  18396. * This is specially interesting in deferred rendering or for any effects requiring more than
  18397. * just one color from a single pass.
  18398. */
  18399. export class MultiRenderTarget extends RenderTargetTexture {
  18400. private _internalTextures;
  18401. private _textures;
  18402. private _multiRenderTargetOptions;
  18403. private _count;
  18404. private _drawOnlyOnFirstAttachmentByDefault;
  18405. /**
  18406. * Get if draw buffers are currently supported by the used hardware and browser.
  18407. */
  18408. get isSupported(): boolean;
  18409. /**
  18410. * Get the list of textures generated by the multi render target.
  18411. */
  18412. get textures(): Texture[];
  18413. /**
  18414. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18415. */
  18416. get count(): number;
  18417. /**
  18418. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18419. */
  18420. get depthTexture(): Texture;
  18421. /**
  18422. * Set the wrapping mode on U of all the textures we are rendering to.
  18423. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18424. */
  18425. set wrapU(wrap: number);
  18426. /**
  18427. * Set the wrapping mode on V of all the textures we are rendering to.
  18428. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18429. */
  18430. set wrapV(wrap: number);
  18431. /**
  18432. * Instantiate a new multi render target texture.
  18433. * A multi render target, like a render target provides the ability to render to a texture.
  18434. * Unlike the render target, it can render to several draw buffers in one draw.
  18435. * This is specially interesting in deferred rendering or for any effects requiring more than
  18436. * just one color from a single pass.
  18437. * @param name Define the name of the texture
  18438. * @param size Define the size of the buffers to render to
  18439. * @param count Define the number of target we are rendering into
  18440. * @param scene Define the scene the texture belongs to
  18441. * @param options Define the options used to create the multi render target
  18442. */
  18443. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18444. private _initTypes;
  18445. /** @hidden */
  18446. _rebuild(forceFullRebuild?: boolean): void;
  18447. private _createInternalTextures;
  18448. private _createTextures;
  18449. /**
  18450. * Replaces a texture within the MRT.
  18451. * @param texture The new texture to insert in the MRT
  18452. * @param index The index of the texture to replace
  18453. */
  18454. replaceTexture(texture: Texture, index: number): void;
  18455. /**
  18456. * Define the number of samples used if MSAA is enabled.
  18457. */
  18458. get samples(): number;
  18459. set samples(value: number);
  18460. /**
  18461. * Resize all the textures in the multi render target.
  18462. * Be careful as it will recreate all the data in the new texture.
  18463. * @param size Define the new size
  18464. */
  18465. resize(size: any): void;
  18466. /**
  18467. * Changes the number of render targets in this MRT
  18468. * Be careful as it will recreate all the data in the new texture.
  18469. * @param count new texture count
  18470. * @param options Specifies texture types and sampling modes for new textures
  18471. */
  18472. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18473. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18474. /**
  18475. * Dispose the render targets and their associated resources
  18476. */
  18477. dispose(): void;
  18478. /**
  18479. * Release all the underlying texture used as draw buffers.
  18480. */
  18481. releaseInternalTextures(): void;
  18482. }
  18483. }
  18484. declare module BABYLON {
  18485. /** @hidden */
  18486. export var imageProcessingPixelShader: {
  18487. name: string;
  18488. shader: string;
  18489. };
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * ImageProcessingPostProcess
  18494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18495. */
  18496. export class ImageProcessingPostProcess extends PostProcess {
  18497. /**
  18498. * Default configuration related to image processing available in the PBR Material.
  18499. */
  18500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18501. /**
  18502. * Gets the image processing configuration used either in this material.
  18503. */
  18504. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18505. /**
  18506. * Sets the Default image processing configuration used either in the this material.
  18507. *
  18508. * If sets to null, the scene one is in use.
  18509. */
  18510. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18511. /**
  18512. * Keep track of the image processing observer to allow dispose and replace.
  18513. */
  18514. private _imageProcessingObserver;
  18515. /**
  18516. * Attaches a new image processing configuration to the PBR Material.
  18517. * @param configuration
  18518. */
  18519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18520. /**
  18521. * If the post process is supported.
  18522. */
  18523. get isSupported(): boolean;
  18524. /**
  18525. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18526. */
  18527. get colorCurves(): Nullable<ColorCurves>;
  18528. /**
  18529. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18530. */
  18531. set colorCurves(value: Nullable<ColorCurves>);
  18532. /**
  18533. * Gets whether the color curves effect is enabled.
  18534. */
  18535. get colorCurvesEnabled(): boolean;
  18536. /**
  18537. * Sets whether the color curves effect is enabled.
  18538. */
  18539. set colorCurvesEnabled(value: boolean);
  18540. /**
  18541. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18542. */
  18543. get colorGradingTexture(): Nullable<BaseTexture>;
  18544. /**
  18545. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18546. */
  18547. set colorGradingTexture(value: Nullable<BaseTexture>);
  18548. /**
  18549. * Gets whether the color grading effect is enabled.
  18550. */
  18551. get colorGradingEnabled(): boolean;
  18552. /**
  18553. * Gets whether the color grading effect is enabled.
  18554. */
  18555. set colorGradingEnabled(value: boolean);
  18556. /**
  18557. * Gets exposure used in the effect.
  18558. */
  18559. get exposure(): number;
  18560. /**
  18561. * Sets exposure used in the effect.
  18562. */
  18563. set exposure(value: number);
  18564. /**
  18565. * Gets whether tonemapping is enabled or not.
  18566. */
  18567. get toneMappingEnabled(): boolean;
  18568. /**
  18569. * Sets whether tonemapping is enabled or not
  18570. */
  18571. set toneMappingEnabled(value: boolean);
  18572. /**
  18573. * Gets the type of tone mapping effect.
  18574. */
  18575. get toneMappingType(): number;
  18576. /**
  18577. * Sets the type of tone mapping effect.
  18578. */
  18579. set toneMappingType(value: number);
  18580. /**
  18581. * Gets contrast used in the effect.
  18582. */
  18583. get contrast(): number;
  18584. /**
  18585. * Sets contrast used in the effect.
  18586. */
  18587. set contrast(value: number);
  18588. /**
  18589. * Gets Vignette stretch size.
  18590. */
  18591. get vignetteStretch(): number;
  18592. /**
  18593. * Sets Vignette stretch size.
  18594. */
  18595. set vignetteStretch(value: number);
  18596. /**
  18597. * Gets Vignette centre X Offset.
  18598. */
  18599. get vignetteCentreX(): number;
  18600. /**
  18601. * Sets Vignette centre X Offset.
  18602. */
  18603. set vignetteCentreX(value: number);
  18604. /**
  18605. * Gets Vignette centre Y Offset.
  18606. */
  18607. get vignetteCentreY(): number;
  18608. /**
  18609. * Sets Vignette centre Y Offset.
  18610. */
  18611. set vignetteCentreY(value: number);
  18612. /**
  18613. * Gets Vignette weight or intensity of the vignette effect.
  18614. */
  18615. get vignetteWeight(): number;
  18616. /**
  18617. * Sets Vignette weight or intensity of the vignette effect.
  18618. */
  18619. set vignetteWeight(value: number);
  18620. /**
  18621. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18622. * if vignetteEnabled is set to true.
  18623. */
  18624. get vignetteColor(): Color4;
  18625. /**
  18626. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18627. * if vignetteEnabled is set to true.
  18628. */
  18629. set vignetteColor(value: Color4);
  18630. /**
  18631. * Gets Camera field of view used by the Vignette effect.
  18632. */
  18633. get vignetteCameraFov(): number;
  18634. /**
  18635. * Sets Camera field of view used by the Vignette effect.
  18636. */
  18637. set vignetteCameraFov(value: number);
  18638. /**
  18639. * Gets the vignette blend mode allowing different kind of effect.
  18640. */
  18641. get vignetteBlendMode(): number;
  18642. /**
  18643. * Sets the vignette blend mode allowing different kind of effect.
  18644. */
  18645. set vignetteBlendMode(value: number);
  18646. /**
  18647. * Gets whether the vignette effect is enabled.
  18648. */
  18649. get vignetteEnabled(): boolean;
  18650. /**
  18651. * Sets whether the vignette effect is enabled.
  18652. */
  18653. set vignetteEnabled(value: boolean);
  18654. private _fromLinearSpace;
  18655. /**
  18656. * Gets whether the input of the processing is in Gamma or Linear Space.
  18657. */
  18658. get fromLinearSpace(): boolean;
  18659. /**
  18660. * Sets whether the input of the processing is in Gamma or Linear Space.
  18661. */
  18662. set fromLinearSpace(value: boolean);
  18663. /**
  18664. * Defines cache preventing GC.
  18665. */
  18666. private _defines;
  18667. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18668. /**
  18669. * "ImageProcessingPostProcess"
  18670. * @returns "ImageProcessingPostProcess"
  18671. */
  18672. getClassName(): string;
  18673. /**
  18674. * @hidden
  18675. */
  18676. _updateParameters(): void;
  18677. dispose(camera?: Camera): void;
  18678. }
  18679. }
  18680. declare module BABYLON {
  18681. /**
  18682. * A multi render target designed to render the prepass.
  18683. * Prepass is a scene component used to render information in multiple textures
  18684. * alongside with the scene materials rendering.
  18685. * Note : This is an internal class, and you should NOT need to instanciate this.
  18686. * Only the `PrePassRenderer` should instanciate this class.
  18687. * It is more likely that you need a regular `MultiRenderTarget`
  18688. * @hidden
  18689. */
  18690. export class PrePassRenderTarget extends MultiRenderTarget {
  18691. /**
  18692. * @hidden
  18693. */
  18694. _beforeCompositionPostProcesses: PostProcess[];
  18695. /**
  18696. * Image processing post process for composition
  18697. */
  18698. imageProcessingPostProcess: ImageProcessingPostProcess;
  18699. /**
  18700. * @hidden
  18701. */
  18702. _engine: Engine;
  18703. /**
  18704. * @hidden
  18705. */
  18706. _scene: Scene;
  18707. /**
  18708. * @hidden
  18709. */
  18710. _outputPostProcess: Nullable<PostProcess>;
  18711. /**
  18712. * @hidden
  18713. */
  18714. _internalTextureDirty: boolean;
  18715. /**
  18716. * Is this render target enabled for prepass rendering
  18717. */
  18718. enabled: boolean;
  18719. /**
  18720. * Render target associated with this prePassRenderTarget
  18721. * If this is `null`, it means this prePassRenderTarget is associated with the scene
  18722. */
  18723. renderTargetTexture: Nullable<RenderTargetTexture>;
  18724. constructor(name: string, renderTargetTexture: Nullable<RenderTargetTexture>, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions | undefined);
  18725. /**
  18726. * Creates a composition effect for this RT
  18727. * @hidden
  18728. */
  18729. _createCompositionEffect(): void;
  18730. /**
  18731. * Checks that the size of this RT is still adapted to the desired render size.
  18732. * @hidden
  18733. */
  18734. _checkSize(): void;
  18735. /**
  18736. * Changes the number of render targets in this MRT
  18737. * Be careful as it will recreate all the data in the new texture.
  18738. * @param count new texture count
  18739. * @param options Specifies texture types and sampling modes for new textures
  18740. */
  18741. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18742. /**
  18743. * Resets the post processes chains applied to this RT.
  18744. * @hidden
  18745. */
  18746. _resetPostProcessChain(): void;
  18747. /**
  18748. * Diposes this render target
  18749. */
  18750. dispose(): void;
  18751. }
  18752. }
  18753. declare module BABYLON {
  18754. /**
  18755. * Interface for defining prepass effects in the prepass post-process pipeline
  18756. */
  18757. export interface PrePassEffectConfiguration {
  18758. /**
  18759. * Name of the effect
  18760. */
  18761. name: string;
  18762. /**
  18763. * Post process to attach for this effect
  18764. */
  18765. postProcess?: PostProcess;
  18766. /**
  18767. * Textures required in the MRT
  18768. */
  18769. texturesRequired: number[];
  18770. /**
  18771. * Is the effect enabled
  18772. */
  18773. enabled: boolean;
  18774. /**
  18775. * Does the output of this prepass need to go through imageprocessing
  18776. */
  18777. needsImageProcessing?: boolean;
  18778. /**
  18779. * Disposes the effect configuration
  18780. */
  18781. dispose?: () => void;
  18782. /**
  18783. * Creates the associated post process
  18784. */
  18785. createPostProcess?: () => PostProcess;
  18786. }
  18787. }
  18788. declare module BABYLON {
  18789. /**
  18790. * Options to be used when creating a FresnelParameters.
  18791. */
  18792. export type IFresnelParametersCreationOptions = {
  18793. /**
  18794. * Define the color used on edges (grazing angle)
  18795. */
  18796. leftColor?: Color3;
  18797. /**
  18798. * Define the color used on center
  18799. */
  18800. rightColor?: Color3;
  18801. /**
  18802. * Define bias applied to computed fresnel term
  18803. */
  18804. bias?: number;
  18805. /**
  18806. * Defined the power exponent applied to fresnel term
  18807. */
  18808. power?: number;
  18809. /**
  18810. * Define if the fresnel effect is enable or not.
  18811. */
  18812. isEnabled?: boolean;
  18813. };
  18814. /**
  18815. * Serialized format for FresnelParameters.
  18816. */
  18817. export type IFresnelParametersSerialized = {
  18818. /**
  18819. * Define the color used on edges (grazing angle) [as an array]
  18820. */
  18821. leftColor: number[];
  18822. /**
  18823. * Define the color used on center [as an array]
  18824. */
  18825. rightColor: number[];
  18826. /**
  18827. * Define bias applied to computed fresnel term
  18828. */
  18829. bias: number;
  18830. /**
  18831. * Defined the power exponent applied to fresnel term
  18832. */
  18833. power?: number;
  18834. /**
  18835. * Define if the fresnel effect is enable or not.
  18836. */
  18837. isEnabled: boolean;
  18838. };
  18839. /**
  18840. * This represents all the required information to add a fresnel effect on a material:
  18841. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18842. */
  18843. export class FresnelParameters {
  18844. private _isEnabled;
  18845. /**
  18846. * Define if the fresnel effect is enable or not.
  18847. */
  18848. get isEnabled(): boolean;
  18849. set isEnabled(value: boolean);
  18850. /**
  18851. * Define the color used on edges (grazing angle)
  18852. */
  18853. leftColor: Color3;
  18854. /**
  18855. * Define the color used on center
  18856. */
  18857. rightColor: Color3;
  18858. /**
  18859. * Define bias applied to computed fresnel term
  18860. */
  18861. bias: number;
  18862. /**
  18863. * Defined the power exponent applied to fresnel term
  18864. */
  18865. power: number;
  18866. /**
  18867. * Creates a new FresnelParameters object.
  18868. *
  18869. * @param options provide your own settings to optionally to override defaults
  18870. */
  18871. constructor(options?: IFresnelParametersCreationOptions);
  18872. /**
  18873. * Clones the current fresnel and its values
  18874. * @returns a clone fresnel configuration
  18875. */
  18876. clone(): FresnelParameters;
  18877. /**
  18878. * Determines equality between FresnelParameters objects
  18879. * @param otherFresnelParameters defines the second operand
  18880. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18881. */
  18882. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18883. /**
  18884. * Serializes the current fresnel parameters to a JSON representation.
  18885. * @return the JSON serialization
  18886. */
  18887. serialize(): IFresnelParametersSerialized;
  18888. /**
  18889. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18890. * @param parsedFresnelParameters Define the JSON representation
  18891. * @returns the parsed parameters
  18892. */
  18893. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18894. }
  18895. }
  18896. declare module BABYLON {
  18897. /**
  18898. * This groups all the flags used to control the materials channel.
  18899. */
  18900. export class MaterialFlags {
  18901. private static _DiffuseTextureEnabled;
  18902. /**
  18903. * Are diffuse textures enabled in the application.
  18904. */
  18905. static get DiffuseTextureEnabled(): boolean;
  18906. static set DiffuseTextureEnabled(value: boolean);
  18907. private static _DetailTextureEnabled;
  18908. /**
  18909. * Are detail textures enabled in the application.
  18910. */
  18911. static get DetailTextureEnabled(): boolean;
  18912. static set DetailTextureEnabled(value: boolean);
  18913. private static _AmbientTextureEnabled;
  18914. /**
  18915. * Are ambient textures enabled in the application.
  18916. */
  18917. static get AmbientTextureEnabled(): boolean;
  18918. static set AmbientTextureEnabled(value: boolean);
  18919. private static _OpacityTextureEnabled;
  18920. /**
  18921. * Are opacity textures enabled in the application.
  18922. */
  18923. static get OpacityTextureEnabled(): boolean;
  18924. static set OpacityTextureEnabled(value: boolean);
  18925. private static _ReflectionTextureEnabled;
  18926. /**
  18927. * Are reflection textures enabled in the application.
  18928. */
  18929. static get ReflectionTextureEnabled(): boolean;
  18930. static set ReflectionTextureEnabled(value: boolean);
  18931. private static _EmissiveTextureEnabled;
  18932. /**
  18933. * Are emissive textures enabled in the application.
  18934. */
  18935. static get EmissiveTextureEnabled(): boolean;
  18936. static set EmissiveTextureEnabled(value: boolean);
  18937. private static _SpecularTextureEnabled;
  18938. /**
  18939. * Are specular textures enabled in the application.
  18940. */
  18941. static get SpecularTextureEnabled(): boolean;
  18942. static set SpecularTextureEnabled(value: boolean);
  18943. private static _BumpTextureEnabled;
  18944. /**
  18945. * Are bump textures enabled in the application.
  18946. */
  18947. static get BumpTextureEnabled(): boolean;
  18948. static set BumpTextureEnabled(value: boolean);
  18949. private static _LightmapTextureEnabled;
  18950. /**
  18951. * Are lightmap textures enabled in the application.
  18952. */
  18953. static get LightmapTextureEnabled(): boolean;
  18954. static set LightmapTextureEnabled(value: boolean);
  18955. private static _RefractionTextureEnabled;
  18956. /**
  18957. * Are refraction textures enabled in the application.
  18958. */
  18959. static get RefractionTextureEnabled(): boolean;
  18960. static set RefractionTextureEnabled(value: boolean);
  18961. private static _ColorGradingTextureEnabled;
  18962. /**
  18963. * Are color grading textures enabled in the application.
  18964. */
  18965. static get ColorGradingTextureEnabled(): boolean;
  18966. static set ColorGradingTextureEnabled(value: boolean);
  18967. private static _FresnelEnabled;
  18968. /**
  18969. * Are fresnels enabled in the application.
  18970. */
  18971. static get FresnelEnabled(): boolean;
  18972. static set FresnelEnabled(value: boolean);
  18973. private static _ClearCoatTextureEnabled;
  18974. /**
  18975. * Are clear coat textures enabled in the application.
  18976. */
  18977. static get ClearCoatTextureEnabled(): boolean;
  18978. static set ClearCoatTextureEnabled(value: boolean);
  18979. private static _ClearCoatBumpTextureEnabled;
  18980. /**
  18981. * Are clear coat bump textures enabled in the application.
  18982. */
  18983. static get ClearCoatBumpTextureEnabled(): boolean;
  18984. static set ClearCoatBumpTextureEnabled(value: boolean);
  18985. private static _ClearCoatTintTextureEnabled;
  18986. /**
  18987. * Are clear coat tint textures enabled in the application.
  18988. */
  18989. static get ClearCoatTintTextureEnabled(): boolean;
  18990. static set ClearCoatTintTextureEnabled(value: boolean);
  18991. private static _SheenTextureEnabled;
  18992. /**
  18993. * Are sheen textures enabled in the application.
  18994. */
  18995. static get SheenTextureEnabled(): boolean;
  18996. static set SheenTextureEnabled(value: boolean);
  18997. private static _AnisotropicTextureEnabled;
  18998. /**
  18999. * Are anisotropic textures enabled in the application.
  19000. */
  19001. static get AnisotropicTextureEnabled(): boolean;
  19002. static set AnisotropicTextureEnabled(value: boolean);
  19003. private static _ThicknessTextureEnabled;
  19004. /**
  19005. * Are thickness textures enabled in the application.
  19006. */
  19007. static get ThicknessTextureEnabled(): boolean;
  19008. static set ThicknessTextureEnabled(value: boolean);
  19009. }
  19010. }
  19011. declare module BABYLON {
  19012. /** @hidden */
  19013. export var defaultFragmentDeclaration: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module BABYLON {
  19019. /** @hidden */
  19020. export var sceneUboDeclaration: {
  19021. name: string;
  19022. shader: string;
  19023. };
  19024. }
  19025. declare module BABYLON {
  19026. /** @hidden */
  19027. export var meshUboDeclaration: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module BABYLON {
  19033. /** @hidden */
  19034. export var defaultUboDeclaration: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module BABYLON {
  19040. /** @hidden */
  19041. export var prePassDeclaration: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module BABYLON {
  19047. /** @hidden */
  19048. export var lightFragmentDeclaration: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module BABYLON {
  19054. /** @hidden */
  19055. export var lightUboDeclaration: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var lightsFragmentFunctions: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var shadowsFragmentFunctions: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /** @hidden */
  19076. export var fresnelFunction: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module BABYLON {
  19082. /** @hidden */
  19083. export var bumpFragmentMainFunctions: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module BABYLON {
  19089. /** @hidden */
  19090. export var bumpFragmentFunctions: {
  19091. name: string;
  19092. shader: string;
  19093. };
  19094. }
  19095. declare module BABYLON {
  19096. /** @hidden */
  19097. export var logDepthDeclaration: {
  19098. name: string;
  19099. shader: string;
  19100. };
  19101. }
  19102. declare module BABYLON {
  19103. /** @hidden */
  19104. export var fogFragmentDeclaration: {
  19105. name: string;
  19106. shader: string;
  19107. };
  19108. }
  19109. declare module BABYLON {
  19110. /** @hidden */
  19111. export var bumpFragment: {
  19112. name: string;
  19113. shader: string;
  19114. };
  19115. }
  19116. declare module BABYLON {
  19117. /** @hidden */
  19118. export var depthPrePass: {
  19119. name: string;
  19120. shader: string;
  19121. };
  19122. }
  19123. declare module BABYLON {
  19124. /** @hidden */
  19125. export var lightFragment: {
  19126. name: string;
  19127. shader: string;
  19128. };
  19129. }
  19130. declare module BABYLON {
  19131. /** @hidden */
  19132. export var logDepthFragment: {
  19133. name: string;
  19134. shader: string;
  19135. };
  19136. }
  19137. declare module BABYLON {
  19138. /** @hidden */
  19139. export var fogFragment: {
  19140. name: string;
  19141. shader: string;
  19142. };
  19143. }
  19144. declare module BABYLON {
  19145. /** @hidden */
  19146. export var defaultPixelShader: {
  19147. name: string;
  19148. shader: string;
  19149. };
  19150. }
  19151. declare module BABYLON {
  19152. /** @hidden */
  19153. export var defaultVertexDeclaration: {
  19154. name: string;
  19155. shader: string;
  19156. };
  19157. }
  19158. declare module BABYLON {
  19159. /** @hidden */
  19160. export var bonesDeclaration: {
  19161. name: string;
  19162. shader: string;
  19163. };
  19164. }
  19165. declare module BABYLON {
  19166. /** @hidden */
  19167. export var prePassVertexDeclaration: {
  19168. name: string;
  19169. shader: string;
  19170. };
  19171. }
  19172. declare module BABYLON {
  19173. /** @hidden */
  19174. export var bumpVertexDeclaration: {
  19175. name: string;
  19176. shader: string;
  19177. };
  19178. }
  19179. declare module BABYLON {
  19180. /** @hidden */
  19181. export var fogVertexDeclaration: {
  19182. name: string;
  19183. shader: string;
  19184. };
  19185. }
  19186. declare module BABYLON {
  19187. /** @hidden */
  19188. export var lightVxFragmentDeclaration: {
  19189. name: string;
  19190. shader: string;
  19191. };
  19192. }
  19193. declare module BABYLON {
  19194. /** @hidden */
  19195. export var lightVxUboDeclaration: {
  19196. name: string;
  19197. shader: string;
  19198. };
  19199. }
  19200. declare module BABYLON {
  19201. /** @hidden */
  19202. export var morphTargetsVertexGlobalDeclaration: {
  19203. name: string;
  19204. shader: string;
  19205. };
  19206. }
  19207. declare module BABYLON {
  19208. /** @hidden */
  19209. export var morphTargetsVertexDeclaration: {
  19210. name: string;
  19211. shader: string;
  19212. };
  19213. }
  19214. declare module BABYLON {
  19215. /** @hidden */
  19216. export var morphTargetsVertexGlobal: {
  19217. name: string;
  19218. shader: string;
  19219. };
  19220. }
  19221. declare module BABYLON {
  19222. /** @hidden */
  19223. export var morphTargetsVertex: {
  19224. name: string;
  19225. shader: string;
  19226. };
  19227. }
  19228. declare module BABYLON {
  19229. /** @hidden */
  19230. export var instancesVertex: {
  19231. name: string;
  19232. shader: string;
  19233. };
  19234. }
  19235. declare module BABYLON {
  19236. /** @hidden */
  19237. export var bonesVertex: {
  19238. name: string;
  19239. shader: string;
  19240. };
  19241. }
  19242. declare module BABYLON {
  19243. /** @hidden */
  19244. export var prePassVertex: {
  19245. name: string;
  19246. shader: string;
  19247. };
  19248. }
  19249. declare module BABYLON {
  19250. /** @hidden */
  19251. export var bumpVertex: {
  19252. name: string;
  19253. shader: string;
  19254. };
  19255. }
  19256. declare module BABYLON {
  19257. /** @hidden */
  19258. export var fogVertex: {
  19259. name: string;
  19260. shader: string;
  19261. };
  19262. }
  19263. declare module BABYLON {
  19264. /** @hidden */
  19265. export var shadowsVertex: {
  19266. name: string;
  19267. shader: string;
  19268. };
  19269. }
  19270. declare module BABYLON {
  19271. /** @hidden */
  19272. export var pointCloudVertex: {
  19273. name: string;
  19274. shader: string;
  19275. };
  19276. }
  19277. declare module BABYLON {
  19278. /** @hidden */
  19279. export var logDepthVertex: {
  19280. name: string;
  19281. shader: string;
  19282. };
  19283. }
  19284. declare module BABYLON {
  19285. /** @hidden */
  19286. export var defaultVertexShader: {
  19287. name: string;
  19288. shader: string;
  19289. };
  19290. }
  19291. declare module BABYLON {
  19292. /**
  19293. * @hidden
  19294. */
  19295. export interface IMaterialDetailMapDefines {
  19296. DETAIL: boolean;
  19297. DETAILDIRECTUV: number;
  19298. DETAIL_NORMALBLENDMETHOD: number;
  19299. /** @hidden */
  19300. _areTexturesDirty: boolean;
  19301. }
  19302. /**
  19303. * Define the code related to the detail map parameters of a material
  19304. *
  19305. * Inspired from:
  19306. * 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
  19307. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19308. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19309. */
  19310. export class DetailMapConfiguration {
  19311. private _texture;
  19312. /**
  19313. * The detail texture of the material.
  19314. */
  19315. texture: Nullable<BaseTexture>;
  19316. /**
  19317. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19318. * Bigger values mean stronger blending
  19319. */
  19320. diffuseBlendLevel: number;
  19321. /**
  19322. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19323. * Bigger values mean stronger blending. Only used with PBR materials
  19324. */
  19325. roughnessBlendLevel: number;
  19326. /**
  19327. * Defines how strong the bump effect from the detail map is
  19328. * Bigger values mean stronger effect
  19329. */
  19330. bumpLevel: number;
  19331. private _normalBlendMethod;
  19332. /**
  19333. * The method used to blend the bump and detail normals together
  19334. */
  19335. normalBlendMethod: number;
  19336. private _isEnabled;
  19337. /**
  19338. * Enable or disable the detail map on this material
  19339. */
  19340. isEnabled: boolean;
  19341. /** @hidden */
  19342. private _internalMarkAllSubMeshesAsTexturesDirty;
  19343. /** @hidden */
  19344. _markAllSubMeshesAsTexturesDirty(): void;
  19345. /**
  19346. * Instantiate a new detail map
  19347. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19348. */
  19349. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19350. /**
  19351. * Gets whether the submesh is ready to be used or not.
  19352. * @param defines the list of "defines" to update.
  19353. * @param scene defines the scene the material belongs to.
  19354. * @returns - boolean indicating that the submesh is ready or not.
  19355. */
  19356. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19357. /**
  19358. * Update the defines for detail map usage
  19359. * @param defines the list of "defines" to update.
  19360. * @param scene defines the scene the material belongs to.
  19361. */
  19362. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19363. /**
  19364. * Binds the material data.
  19365. * @param uniformBuffer defines the Uniform buffer to fill in.
  19366. * @param scene defines the scene the material belongs to.
  19367. * @param isFrozen defines whether the material is frozen or not.
  19368. */
  19369. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19370. /**
  19371. * Checks to see if a texture is used in the material.
  19372. * @param texture - Base texture to use.
  19373. * @returns - Boolean specifying if a texture is used in the material.
  19374. */
  19375. hasTexture(texture: BaseTexture): boolean;
  19376. /**
  19377. * Returns an array of the actively used textures.
  19378. * @param activeTextures Array of BaseTextures
  19379. */
  19380. getActiveTextures(activeTextures: BaseTexture[]): void;
  19381. /**
  19382. * Returns the animatable textures.
  19383. * @param animatables Array of animatable textures.
  19384. */
  19385. getAnimatables(animatables: IAnimatable[]): void;
  19386. /**
  19387. * Disposes the resources of the material.
  19388. * @param forceDisposeTextures - Forces the disposal of all textures.
  19389. */
  19390. dispose(forceDisposeTextures?: boolean): void;
  19391. /**
  19392. * Get the current class name useful for serialization or dynamic coding.
  19393. * @returns "DetailMap"
  19394. */
  19395. getClassName(): string;
  19396. /**
  19397. * Add the required uniforms to the current list.
  19398. * @param uniforms defines the current uniform list.
  19399. */
  19400. static AddUniforms(uniforms: string[]): void;
  19401. /**
  19402. * Add the required samplers to the current list.
  19403. * @param samplers defines the current sampler list.
  19404. */
  19405. static AddSamplers(samplers: string[]): void;
  19406. /**
  19407. * Add the required uniforms to the current buffer.
  19408. * @param uniformBuffer defines the current uniform buffer.
  19409. */
  19410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19411. /**
  19412. * Makes a duplicate of the current instance into another one.
  19413. * @param detailMap define the instance where to copy the info
  19414. */
  19415. copyTo(detailMap: DetailMapConfiguration): void;
  19416. /**
  19417. * Serializes this detail map instance
  19418. * @returns - An object with the serialized instance.
  19419. */
  19420. serialize(): any;
  19421. /**
  19422. * Parses a detail map setting from a serialized object.
  19423. * @param source - Serialized object.
  19424. * @param scene Defines the scene we are parsing for
  19425. * @param rootUrl Defines the rootUrl to load from
  19426. */
  19427. parse(source: any, scene: Scene, rootUrl: string): void;
  19428. }
  19429. }
  19430. declare module BABYLON {
  19431. /** @hidden */
  19432. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19433. MAINUV1: boolean;
  19434. MAINUV2: boolean;
  19435. DIFFUSE: boolean;
  19436. DIFFUSEDIRECTUV: number;
  19437. DETAIL: boolean;
  19438. DETAILDIRECTUV: number;
  19439. DETAIL_NORMALBLENDMETHOD: number;
  19440. AMBIENT: boolean;
  19441. AMBIENTDIRECTUV: number;
  19442. OPACITY: boolean;
  19443. OPACITYDIRECTUV: number;
  19444. OPACITYRGB: boolean;
  19445. REFLECTION: boolean;
  19446. EMISSIVE: boolean;
  19447. EMISSIVEDIRECTUV: number;
  19448. SPECULAR: boolean;
  19449. SPECULARDIRECTUV: number;
  19450. BUMP: boolean;
  19451. BUMPDIRECTUV: number;
  19452. PARALLAX: boolean;
  19453. PARALLAXOCCLUSION: boolean;
  19454. SPECULAROVERALPHA: boolean;
  19455. CLIPPLANE: boolean;
  19456. CLIPPLANE2: boolean;
  19457. CLIPPLANE3: boolean;
  19458. CLIPPLANE4: boolean;
  19459. CLIPPLANE5: boolean;
  19460. CLIPPLANE6: boolean;
  19461. ALPHATEST: boolean;
  19462. DEPTHPREPASS: boolean;
  19463. ALPHAFROMDIFFUSE: boolean;
  19464. POINTSIZE: boolean;
  19465. FOG: boolean;
  19466. SPECULARTERM: boolean;
  19467. DIFFUSEFRESNEL: boolean;
  19468. OPACITYFRESNEL: boolean;
  19469. REFLECTIONFRESNEL: boolean;
  19470. REFRACTIONFRESNEL: boolean;
  19471. EMISSIVEFRESNEL: boolean;
  19472. FRESNEL: boolean;
  19473. NORMAL: boolean;
  19474. UV1: boolean;
  19475. UV2: boolean;
  19476. VERTEXCOLOR: boolean;
  19477. VERTEXALPHA: boolean;
  19478. NUM_BONE_INFLUENCERS: number;
  19479. BonesPerMesh: number;
  19480. BONETEXTURE: boolean;
  19481. BONES_VELOCITY_ENABLED: boolean;
  19482. INSTANCES: boolean;
  19483. THIN_INSTANCES: boolean;
  19484. GLOSSINESS: boolean;
  19485. ROUGHNESS: boolean;
  19486. EMISSIVEASILLUMINATION: boolean;
  19487. LINKEMISSIVEWITHDIFFUSE: boolean;
  19488. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19489. LIGHTMAP: boolean;
  19490. LIGHTMAPDIRECTUV: number;
  19491. OBJECTSPACE_NORMALMAP: boolean;
  19492. USELIGHTMAPASSHADOWMAP: boolean;
  19493. REFLECTIONMAP_3D: boolean;
  19494. REFLECTIONMAP_SPHERICAL: boolean;
  19495. REFLECTIONMAP_PLANAR: boolean;
  19496. REFLECTIONMAP_CUBIC: boolean;
  19497. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19498. REFLECTIONMAP_PROJECTION: boolean;
  19499. REFLECTIONMAP_SKYBOX: boolean;
  19500. REFLECTIONMAP_EXPLICIT: boolean;
  19501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19504. REFLECTIONMAP_OPPOSITEZ: boolean;
  19505. INVERTCUBICMAP: boolean;
  19506. LOGARITHMICDEPTH: boolean;
  19507. REFRACTION: boolean;
  19508. REFRACTIONMAP_3D: boolean;
  19509. REFLECTIONOVERALPHA: boolean;
  19510. TWOSIDEDLIGHTING: boolean;
  19511. SHADOWFLOAT: boolean;
  19512. MORPHTARGETS: boolean;
  19513. MORPHTARGETS_NORMAL: boolean;
  19514. MORPHTARGETS_TANGENT: boolean;
  19515. MORPHTARGETS_UV: boolean;
  19516. NUM_MORPH_INFLUENCERS: number;
  19517. MORPHTARGETS_TEXTURE: boolean;
  19518. NONUNIFORMSCALING: boolean;
  19519. PREMULTIPLYALPHA: boolean;
  19520. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19521. ALPHABLEND: boolean;
  19522. PREPASS: boolean;
  19523. PREPASS_IRRADIANCE: boolean;
  19524. PREPASS_IRRADIANCE_INDEX: number;
  19525. PREPASS_ALBEDO: boolean;
  19526. PREPASS_ALBEDO_INDEX: number;
  19527. PREPASS_DEPTH: boolean;
  19528. PREPASS_DEPTH_INDEX: number;
  19529. PREPASS_NORMAL: boolean;
  19530. PREPASS_NORMAL_INDEX: number;
  19531. PREPASS_POSITION: boolean;
  19532. PREPASS_POSITION_INDEX: number;
  19533. PREPASS_VELOCITY: boolean;
  19534. PREPASS_VELOCITY_INDEX: number;
  19535. PREPASS_REFLECTIVITY: boolean;
  19536. PREPASS_REFLECTIVITY_INDEX: number;
  19537. SCENE_MRT_COUNT: number;
  19538. RGBDLIGHTMAP: boolean;
  19539. RGBDREFLECTION: boolean;
  19540. RGBDREFRACTION: boolean;
  19541. IMAGEPROCESSING: boolean;
  19542. VIGNETTE: boolean;
  19543. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19544. VIGNETTEBLENDMODEOPAQUE: boolean;
  19545. TONEMAPPING: boolean;
  19546. TONEMAPPING_ACES: boolean;
  19547. CONTRAST: boolean;
  19548. COLORCURVES: boolean;
  19549. COLORGRADING: boolean;
  19550. COLORGRADING3D: boolean;
  19551. SAMPLER3DGREENDEPTH: boolean;
  19552. SAMPLER3DBGRMAP: boolean;
  19553. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19554. MULTIVIEW: boolean;
  19555. /**
  19556. * If the reflection texture on this material is in linear color space
  19557. * @hidden
  19558. */
  19559. IS_REFLECTION_LINEAR: boolean;
  19560. /**
  19561. * If the refraction texture on this material is in linear color space
  19562. * @hidden
  19563. */
  19564. IS_REFRACTION_LINEAR: boolean;
  19565. EXPOSURE: boolean;
  19566. constructor();
  19567. setReflectionMode(modeToEnable: string): void;
  19568. }
  19569. /**
  19570. * This is the default material used in Babylon. It is the best trade off between quality
  19571. * and performances.
  19572. * @see https://doc.babylonjs.com/babylon101/materials
  19573. */
  19574. export class StandardMaterial extends PushMaterial {
  19575. private _diffuseTexture;
  19576. /**
  19577. * The basic texture of the material as viewed under a light.
  19578. */
  19579. diffuseTexture: Nullable<BaseTexture>;
  19580. private _ambientTexture;
  19581. /**
  19582. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19583. */
  19584. ambientTexture: Nullable<BaseTexture>;
  19585. private _opacityTexture;
  19586. /**
  19587. * Define the transparency of the material from a texture.
  19588. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19589. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19590. */
  19591. opacityTexture: Nullable<BaseTexture>;
  19592. private _reflectionTexture;
  19593. /**
  19594. * Define the texture used to display the reflection.
  19595. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19596. */
  19597. reflectionTexture: Nullable<BaseTexture>;
  19598. private _emissiveTexture;
  19599. /**
  19600. * Define texture of the material as if self lit.
  19601. * This will be mixed in the final result even in the absence of light.
  19602. */
  19603. emissiveTexture: Nullable<BaseTexture>;
  19604. private _specularTexture;
  19605. /**
  19606. * Define how the color and intensity of the highlight given by the light in the material.
  19607. */
  19608. specularTexture: Nullable<BaseTexture>;
  19609. private _bumpTexture;
  19610. /**
  19611. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19612. * 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.
  19613. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19614. */
  19615. bumpTexture: Nullable<BaseTexture>;
  19616. private _lightmapTexture;
  19617. /**
  19618. * Complex lighting can be computationally expensive to compute at runtime.
  19619. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19620. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19621. */
  19622. lightmapTexture: Nullable<BaseTexture>;
  19623. private _refractionTexture;
  19624. /**
  19625. * Define the texture used to display the refraction.
  19626. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19627. */
  19628. refractionTexture: Nullable<BaseTexture>;
  19629. /**
  19630. * The color of the material lit by the environmental background lighting.
  19631. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19632. */
  19633. ambientColor: Color3;
  19634. /**
  19635. * The basic color of the material as viewed under a light.
  19636. */
  19637. diffuseColor: Color3;
  19638. /**
  19639. * Define how the color and intensity of the highlight given by the light in the material.
  19640. */
  19641. specularColor: Color3;
  19642. /**
  19643. * Define the color of the material as if self lit.
  19644. * This will be mixed in the final result even in the absence of light.
  19645. */
  19646. emissiveColor: Color3;
  19647. /**
  19648. * Defines how sharp are the highlights in the material.
  19649. * The bigger the value the sharper giving a more glossy feeling to the result.
  19650. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19651. */
  19652. specularPower: number;
  19653. private _useAlphaFromDiffuseTexture;
  19654. /**
  19655. * Does the transparency come from the diffuse texture alpha channel.
  19656. */
  19657. useAlphaFromDiffuseTexture: boolean;
  19658. private _useEmissiveAsIllumination;
  19659. /**
  19660. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19661. */
  19662. useEmissiveAsIllumination: boolean;
  19663. private _linkEmissiveWithDiffuse;
  19664. /**
  19665. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19666. * the emissive level when the final color is close to one.
  19667. */
  19668. linkEmissiveWithDiffuse: boolean;
  19669. private _useSpecularOverAlpha;
  19670. /**
  19671. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  19672. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19673. */
  19674. useSpecularOverAlpha: boolean;
  19675. private _useReflectionOverAlpha;
  19676. /**
  19677. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  19678. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19679. */
  19680. useReflectionOverAlpha: boolean;
  19681. private _disableLighting;
  19682. /**
  19683. * Does lights from the scene impacts this material.
  19684. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19685. */
  19686. disableLighting: boolean;
  19687. private _useObjectSpaceNormalMap;
  19688. /**
  19689. * Allows using an object space normal map (instead of tangent space).
  19690. */
  19691. useObjectSpaceNormalMap: boolean;
  19692. private _useParallax;
  19693. /**
  19694. * Is parallax enabled or not.
  19695. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19696. */
  19697. useParallax: boolean;
  19698. private _useParallaxOcclusion;
  19699. /**
  19700. * Is parallax occlusion enabled or not.
  19701. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19702. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19703. */
  19704. useParallaxOcclusion: boolean;
  19705. /**
  19706. * 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.
  19707. */
  19708. parallaxScaleBias: number;
  19709. private _roughness;
  19710. /**
  19711. * Helps to define how blurry the reflections should appears in the material.
  19712. */
  19713. roughness: number;
  19714. /**
  19715. * In case of refraction, define the value of the index of refraction.
  19716. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19717. */
  19718. indexOfRefraction: number;
  19719. /**
  19720. * Invert the refraction texture alongside the y axis.
  19721. * It can be useful with procedural textures or probe for instance.
  19722. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19723. */
  19724. invertRefractionY: boolean;
  19725. /**
  19726. * Defines the alpha limits in alpha test mode.
  19727. */
  19728. alphaCutOff: number;
  19729. private _useLightmapAsShadowmap;
  19730. /**
  19731. * In case of light mapping, define whether the map contains light or shadow informations.
  19732. */
  19733. useLightmapAsShadowmap: boolean;
  19734. private _diffuseFresnelParameters;
  19735. /**
  19736. * Define the diffuse fresnel parameters of the material.
  19737. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19738. */
  19739. diffuseFresnelParameters: FresnelParameters;
  19740. private _opacityFresnelParameters;
  19741. /**
  19742. * Define the opacity fresnel parameters of the material.
  19743. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19744. */
  19745. opacityFresnelParameters: FresnelParameters;
  19746. private _reflectionFresnelParameters;
  19747. /**
  19748. * Define the reflection fresnel parameters of the material.
  19749. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19750. */
  19751. reflectionFresnelParameters: FresnelParameters;
  19752. private _refractionFresnelParameters;
  19753. /**
  19754. * Define the refraction fresnel parameters of the material.
  19755. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19756. */
  19757. refractionFresnelParameters: FresnelParameters;
  19758. private _emissiveFresnelParameters;
  19759. /**
  19760. * Define the emissive fresnel parameters of the material.
  19761. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19762. */
  19763. emissiveFresnelParameters: FresnelParameters;
  19764. private _useReflectionFresnelFromSpecular;
  19765. /**
  19766. * If true automatically deducts the fresnels values from the material specularity.
  19767. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19768. */
  19769. useReflectionFresnelFromSpecular: boolean;
  19770. private _useGlossinessFromSpecularMapAlpha;
  19771. /**
  19772. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19773. */
  19774. useGlossinessFromSpecularMapAlpha: boolean;
  19775. private _maxSimultaneousLights;
  19776. /**
  19777. * Defines the maximum number of lights that can be used in the material
  19778. */
  19779. maxSimultaneousLights: number;
  19780. private _invertNormalMapX;
  19781. /**
  19782. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19783. */
  19784. invertNormalMapX: boolean;
  19785. private _invertNormalMapY;
  19786. /**
  19787. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19788. */
  19789. invertNormalMapY: boolean;
  19790. private _twoSidedLighting;
  19791. /**
  19792. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19793. */
  19794. twoSidedLighting: boolean;
  19795. /**
  19796. * Default configuration related to image processing available in the standard Material.
  19797. */
  19798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19799. /**
  19800. * Gets the image processing configuration used either in this material.
  19801. */
  19802. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19803. /**
  19804. * Sets the Default image processing configuration used either in the this material.
  19805. *
  19806. * If sets to null, the scene one is in use.
  19807. */
  19808. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19809. /**
  19810. * Keep track of the image processing observer to allow dispose and replace.
  19811. */
  19812. private _imageProcessingObserver;
  19813. /**
  19814. * Attaches a new image processing configuration to the Standard Material.
  19815. * @param configuration
  19816. */
  19817. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19818. /**
  19819. * Defines additional PrePass parameters for the material.
  19820. */
  19821. readonly prePassConfiguration: PrePassConfiguration;
  19822. /**
  19823. * Can this material render to prepass
  19824. */
  19825. get isPrePassCapable(): boolean;
  19826. /**
  19827. * Gets whether the color curves effect is enabled.
  19828. */
  19829. get cameraColorCurvesEnabled(): boolean;
  19830. /**
  19831. * Sets whether the color curves effect is enabled.
  19832. */
  19833. set cameraColorCurvesEnabled(value: boolean);
  19834. /**
  19835. * Gets whether the color grading effect is enabled.
  19836. */
  19837. get cameraColorGradingEnabled(): boolean;
  19838. /**
  19839. * Gets whether the color grading effect is enabled.
  19840. */
  19841. set cameraColorGradingEnabled(value: boolean);
  19842. /**
  19843. * Gets whether tonemapping is enabled or not.
  19844. */
  19845. get cameraToneMappingEnabled(): boolean;
  19846. /**
  19847. * Sets whether tonemapping is enabled or not
  19848. */
  19849. set cameraToneMappingEnabled(value: boolean);
  19850. /**
  19851. * The camera exposure used on this material.
  19852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19853. * This corresponds to a photographic exposure.
  19854. */
  19855. get cameraExposure(): number;
  19856. /**
  19857. * The camera exposure used on this material.
  19858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19859. * This corresponds to a photographic exposure.
  19860. */
  19861. set cameraExposure(value: number);
  19862. /**
  19863. * Gets The camera contrast used on this material.
  19864. */
  19865. get cameraContrast(): number;
  19866. /**
  19867. * Sets The camera contrast used on this material.
  19868. */
  19869. set cameraContrast(value: number);
  19870. /**
  19871. * Gets the Color Grading 2D Lookup Texture.
  19872. */
  19873. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19874. /**
  19875. * Sets the Color Grading 2D Lookup Texture.
  19876. */
  19877. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19878. /**
  19879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19881. * 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;
  19882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19883. */
  19884. get cameraColorCurves(): Nullable<ColorCurves>;
  19885. /**
  19886. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  19887. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19888. * 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;
  19889. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19890. */
  19891. set cameraColorCurves(value: Nullable<ColorCurves>);
  19892. /**
  19893. * Can this material render to several textures at once
  19894. */
  19895. get canRenderToMRT(): boolean;
  19896. /**
  19897. * Defines the detail map parameters for the material.
  19898. */
  19899. readonly detailMap: DetailMapConfiguration;
  19900. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19901. protected _worldViewProjectionMatrix: Matrix;
  19902. protected _globalAmbientColor: Color3;
  19903. protected _useLogarithmicDepth: boolean;
  19904. protected _rebuildInParallel: boolean;
  19905. /**
  19906. * Instantiates a new standard material.
  19907. * This is the default material used in Babylon. It is the best trade off between quality
  19908. * and performances.
  19909. * @see https://doc.babylonjs.com/babylon101/materials
  19910. * @param name Define the name of the material in the scene
  19911. * @param scene Define the scene the material belong to
  19912. */
  19913. constructor(name: string, scene: Scene);
  19914. /**
  19915. * Gets a boolean indicating that current material needs to register RTT
  19916. */
  19917. get hasRenderTargetTextures(): boolean;
  19918. /**
  19919. * Gets the current class name of the material e.g. "StandardMaterial"
  19920. * Mainly use in serialization.
  19921. * @returns the class name
  19922. */
  19923. getClassName(): string;
  19924. /**
  19925. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19926. * You can try switching to logarithmic depth.
  19927. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19928. */
  19929. get useLogarithmicDepth(): boolean;
  19930. set useLogarithmicDepth(value: boolean);
  19931. /**
  19932. * Specifies if the material will require alpha blending
  19933. * @returns a boolean specifying if alpha blending is needed
  19934. */
  19935. needAlphaBlending(): boolean;
  19936. /**
  19937. * Specifies if this material should be rendered in alpha test mode
  19938. * @returns a boolean specifying if an alpha test is needed.
  19939. */
  19940. needAlphaTesting(): boolean;
  19941. /**
  19942. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19943. */
  19944. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19945. /**
  19946. * Specifies whether or not there is a usable alpha channel for transparency.
  19947. */
  19948. protected _hasAlphaChannel(): boolean;
  19949. /**
  19950. * Get the texture used for alpha test purpose.
  19951. * @returns the diffuse texture in case of the standard material.
  19952. */
  19953. getAlphaTestTexture(): Nullable<BaseTexture>;
  19954. /**
  19955. * Get if the submesh is ready to be used and all its information available.
  19956. * Child classes can use it to update shaders
  19957. * @param mesh defines the mesh to check
  19958. * @param subMesh defines which submesh to check
  19959. * @param useInstances specifies that instances should be used
  19960. * @returns a boolean indicating that the submesh is ready or not
  19961. */
  19962. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19963. /**
  19964. * Builds the material UBO layouts.
  19965. * Used internally during the effect preparation.
  19966. */
  19967. buildUniformLayout(): void;
  19968. /**
  19969. * Unbinds the material from the mesh
  19970. */
  19971. unbind(): void;
  19972. /**
  19973. * Binds the submesh to this material by preparing the effect and shader to draw
  19974. * @param world defines the world transformation matrix
  19975. * @param mesh defines the mesh containing the submesh
  19976. * @param subMesh defines the submesh to bind the material to
  19977. */
  19978. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19979. /**
  19980. * Get the list of animatables in the material.
  19981. * @returns the list of animatables object used in the material
  19982. */
  19983. getAnimatables(): IAnimatable[];
  19984. /**
  19985. * Gets the active textures from the material
  19986. * @returns an array of textures
  19987. */
  19988. getActiveTextures(): BaseTexture[];
  19989. /**
  19990. * Specifies if the material uses a texture
  19991. * @param texture defines the texture to check against the material
  19992. * @returns a boolean specifying if the material uses the texture
  19993. */
  19994. hasTexture(texture: BaseTexture): boolean;
  19995. /**
  19996. * Disposes the material
  19997. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19998. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19999. */
  20000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20001. /**
  20002. * Makes a duplicate of the material, and gives it a new name
  20003. * @param name defines the new name for the duplicated material
  20004. * @returns the cloned material
  20005. */
  20006. clone(name: string): StandardMaterial;
  20007. /**
  20008. * Serializes this material in a JSON representation
  20009. * @returns the serialized material object
  20010. */
  20011. serialize(): any;
  20012. /**
  20013. * Creates a standard material from parsed material data
  20014. * @param source defines the JSON representation of the material
  20015. * @param scene defines the hosting scene
  20016. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20017. * @returns a new standard material
  20018. */
  20019. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  20020. /**
  20021. * Are diffuse textures enabled in the application.
  20022. */
  20023. static get DiffuseTextureEnabled(): boolean;
  20024. static set DiffuseTextureEnabled(value: boolean);
  20025. /**
  20026. * Are detail textures enabled in the application.
  20027. */
  20028. static get DetailTextureEnabled(): boolean;
  20029. static set DetailTextureEnabled(value: boolean);
  20030. /**
  20031. * Are ambient textures enabled in the application.
  20032. */
  20033. static get AmbientTextureEnabled(): boolean;
  20034. static set AmbientTextureEnabled(value: boolean);
  20035. /**
  20036. * Are opacity textures enabled in the application.
  20037. */
  20038. static get OpacityTextureEnabled(): boolean;
  20039. static set OpacityTextureEnabled(value: boolean);
  20040. /**
  20041. * Are reflection textures enabled in the application.
  20042. */
  20043. static get ReflectionTextureEnabled(): boolean;
  20044. static set ReflectionTextureEnabled(value: boolean);
  20045. /**
  20046. * Are emissive textures enabled in the application.
  20047. */
  20048. static get EmissiveTextureEnabled(): boolean;
  20049. static set EmissiveTextureEnabled(value: boolean);
  20050. /**
  20051. * Are specular textures enabled in the application.
  20052. */
  20053. static get SpecularTextureEnabled(): boolean;
  20054. static set SpecularTextureEnabled(value: boolean);
  20055. /**
  20056. * Are bump textures enabled in the application.
  20057. */
  20058. static get BumpTextureEnabled(): boolean;
  20059. static set BumpTextureEnabled(value: boolean);
  20060. /**
  20061. * Are lightmap textures enabled in the application.
  20062. */
  20063. static get LightmapTextureEnabled(): boolean;
  20064. static set LightmapTextureEnabled(value: boolean);
  20065. /**
  20066. * Are refraction textures enabled in the application.
  20067. */
  20068. static get RefractionTextureEnabled(): boolean;
  20069. static set RefractionTextureEnabled(value: boolean);
  20070. /**
  20071. * Are color grading textures enabled in the application.
  20072. */
  20073. static get ColorGradingTextureEnabled(): boolean;
  20074. static set ColorGradingTextureEnabled(value: boolean);
  20075. /**
  20076. * Are fresnels enabled in the application.
  20077. */
  20078. static get FresnelEnabled(): boolean;
  20079. static set FresnelEnabled(value: boolean);
  20080. }
  20081. }
  20082. declare module BABYLON {
  20083. /** @hidden */
  20084. export var rgbdDecodePixelShader: {
  20085. name: string;
  20086. shader: string;
  20087. };
  20088. }
  20089. declare module BABYLON {
  20090. /** @hidden */
  20091. export var passPixelShader: {
  20092. name: string;
  20093. shader: string;
  20094. };
  20095. }
  20096. declare module BABYLON {
  20097. /** @hidden */
  20098. export var passCubePixelShader: {
  20099. name: string;
  20100. shader: string;
  20101. };
  20102. }
  20103. declare module BABYLON {
  20104. /**
  20105. * PassPostProcess which produces an output the same as it's input
  20106. */
  20107. export class PassPostProcess extends PostProcess {
  20108. /**
  20109. * Gets a string identifying the name of the class
  20110. * @returns "PassPostProcess" string
  20111. */
  20112. getClassName(): string;
  20113. /**
  20114. * Creates the PassPostProcess
  20115. * @param name The name of the effect.
  20116. * @param options The required width/height ratio to downsize to before computing the render pass.
  20117. * @param camera The camera to apply the render pass to.
  20118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20119. * @param engine The engine which the post process will be applied. (default: current engine)
  20120. * @param reusable If the post process can be reused on the same frame. (default: false)
  20121. * @param textureType The type of texture to be used when performing the post processing.
  20122. * @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)
  20123. */
  20124. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20125. /** @hidden */
  20126. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  20127. }
  20128. /**
  20129. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  20130. */
  20131. export class PassCubePostProcess extends PostProcess {
  20132. private _face;
  20133. /**
  20134. * Gets or sets the cube face to display.
  20135. * * 0 is +X
  20136. * * 1 is -X
  20137. * * 2 is +Y
  20138. * * 3 is -Y
  20139. * * 4 is +Z
  20140. * * 5 is -Z
  20141. */
  20142. get face(): number;
  20143. set face(value: number);
  20144. /**
  20145. * Gets a string identifying the name of the class
  20146. * @returns "PassCubePostProcess" string
  20147. */
  20148. getClassName(): string;
  20149. /**
  20150. * Creates the PassCubePostProcess
  20151. * @param name The name of the effect.
  20152. * @param options The required width/height ratio to downsize to before computing the render pass.
  20153. * @param camera The camera to apply the render pass to.
  20154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20155. * @param engine The engine which the post process will be applied. (default: current engine)
  20156. * @param reusable If the post process can be reused on the same frame. (default: false)
  20157. * @param textureType The type of texture to be used when performing the post processing.
  20158. * @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)
  20159. */
  20160. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  20161. /** @hidden */
  20162. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  20163. }
  20164. }
  20165. declare module BABYLON {
  20166. /**
  20167. * Class used to host texture specific utilities
  20168. */
  20169. export class TextureTools {
  20170. /**
  20171. * Uses the GPU to create a copy texture rescaled at a given size
  20172. * @param texture Texture to copy from
  20173. * @param width defines the desired width
  20174. * @param height defines the desired height
  20175. * @param useBilinearMode defines if bilinear mode has to be used
  20176. * @return the generated texture
  20177. */
  20178. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  20179. /**
  20180. * Apply a post process to a texture
  20181. * @param postProcessName name of the fragment post process
  20182. * @param internalTexture the texture to encode
  20183. * @param scene the scene hosting the texture
  20184. * @param type type of the output texture. If not provided, use the one from internalTexture
  20185. * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
  20186. * @param format format of the output texture. If not provided, use the one from internalTexture
  20187. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20188. */
  20189. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  20190. }
  20191. }
  20192. declare module BABYLON {
  20193. /**
  20194. * Class used to host RGBD texture specific utilities
  20195. */
  20196. export class RGBDTextureTools {
  20197. /**
  20198. * Expand the RGBD Texture from RGBD to Half Float if possible.
  20199. * @param texture the texture to expand.
  20200. */
  20201. static ExpandRGBDTexture(texture: Texture): void;
  20202. /**
  20203. * Encode the texture to RGBD if possible.
  20204. * @param internalTexture the texture to encode
  20205. * @param scene the scene hosting the texture
  20206. * @param outputTextureType type of the texture in which the encoding is performed
  20207. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  20208. */
  20209. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  20210. }
  20211. }
  20212. declare module BABYLON {
  20213. /**
  20214. * Class used to host texture specific utilities
  20215. */
  20216. export class BRDFTextureTools {
  20217. /**
  20218. * Prevents texture cache collision
  20219. */
  20220. private static _instanceNumber;
  20221. /**
  20222. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20223. * @param scene defines the hosting scene
  20224. * @returns the environment BRDF texture
  20225. */
  20226. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20227. private static _environmentBRDFBase64Texture;
  20228. }
  20229. }
  20230. declare module BABYLON {
  20231. /**
  20232. * @hidden
  20233. */
  20234. export interface IMaterialClearCoatDefines {
  20235. CLEARCOAT: boolean;
  20236. CLEARCOAT_DEFAULTIOR: boolean;
  20237. CLEARCOAT_TEXTURE: boolean;
  20238. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20239. CLEARCOAT_TEXTUREDIRECTUV: number;
  20240. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20241. CLEARCOAT_BUMP: boolean;
  20242. CLEARCOAT_BUMPDIRECTUV: number;
  20243. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20244. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20245. CLEARCOAT_REMAP_F0: boolean;
  20246. CLEARCOAT_TINT: boolean;
  20247. CLEARCOAT_TINT_TEXTURE: boolean;
  20248. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20249. /** @hidden */
  20250. _areTexturesDirty: boolean;
  20251. }
  20252. /**
  20253. * Define the code related to the clear coat parameters of the pbr material.
  20254. */
  20255. export class PBRClearCoatConfiguration {
  20256. /**
  20257. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20258. * The default fits with a polyurethane material.
  20259. * @hidden
  20260. */
  20261. static readonly _DefaultIndexOfRefraction: number;
  20262. private _isEnabled;
  20263. /**
  20264. * Defines if the clear coat is enabled in the material.
  20265. */
  20266. isEnabled: boolean;
  20267. /**
  20268. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20269. */
  20270. intensity: number;
  20271. /**
  20272. * Defines the clear coat layer roughness.
  20273. */
  20274. roughness: number;
  20275. private _indexOfRefraction;
  20276. /**
  20277. * Defines the index of refraction of the clear coat.
  20278. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20279. * The default fits with a polyurethane material.
  20280. * Changing the default value is more performance intensive.
  20281. */
  20282. indexOfRefraction: number;
  20283. private _texture;
  20284. /**
  20285. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20286. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20287. * if textureRoughness is not empty, else no texture roughness is used
  20288. */
  20289. texture: Nullable<BaseTexture>;
  20290. private _useRoughnessFromMainTexture;
  20291. /**
  20292. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20293. * If false, the green channel from textureRoughness is used for roughness
  20294. */
  20295. useRoughnessFromMainTexture: boolean;
  20296. private _textureRoughness;
  20297. /**
  20298. * Stores the clear coat roughness in a texture (green channel)
  20299. * Not used if useRoughnessFromMainTexture is true
  20300. */
  20301. textureRoughness: Nullable<BaseTexture>;
  20302. private _remapF0OnInterfaceChange;
  20303. /**
  20304. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20305. */
  20306. remapF0OnInterfaceChange: boolean;
  20307. private _bumpTexture;
  20308. /**
  20309. * Define the clear coat specific bump texture.
  20310. */
  20311. bumpTexture: Nullable<BaseTexture>;
  20312. private _isTintEnabled;
  20313. /**
  20314. * Defines if the clear coat tint is enabled in the material.
  20315. */
  20316. isTintEnabled: boolean;
  20317. /**
  20318. * Defines the clear coat tint of the material.
  20319. * This is only use if tint is enabled
  20320. */
  20321. tintColor: Color3;
  20322. /**
  20323. * Defines the distance at which the tint color should be found in the
  20324. * clear coat media.
  20325. * This is only use if tint is enabled
  20326. */
  20327. tintColorAtDistance: number;
  20328. /**
  20329. * Defines the clear coat layer thickness.
  20330. * This is only use if tint is enabled
  20331. */
  20332. tintThickness: number;
  20333. private _tintTexture;
  20334. /**
  20335. * Stores the clear tint values in a texture.
  20336. * rgb is tint
  20337. * a is a thickness factor
  20338. */
  20339. tintTexture: Nullable<BaseTexture>;
  20340. /** @hidden */
  20341. private _internalMarkAllSubMeshesAsTexturesDirty;
  20342. /** @hidden */
  20343. _markAllSubMeshesAsTexturesDirty(): void;
  20344. /**
  20345. * Instantiate a new instance of clear coat configuration.
  20346. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20347. */
  20348. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20349. /**
  20350. * Gets whether the submesh is ready to be used or not.
  20351. * @param defines the list of "defines" to update.
  20352. * @param scene defines the scene the material belongs to.
  20353. * @param engine defines the engine the material belongs to.
  20354. * @param disableBumpMap defines whether the material disables bump or not.
  20355. * @returns - boolean indicating that the submesh is ready or not.
  20356. */
  20357. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20358. /**
  20359. * Checks to see if a texture is used in the material.
  20360. * @param defines the list of "defines" to update.
  20361. * @param scene defines the scene to the material belongs to.
  20362. */
  20363. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20364. /**
  20365. * Binds the material data.
  20366. * @param uniformBuffer defines the Uniform buffer to fill in.
  20367. * @param scene defines the scene the material belongs to.
  20368. * @param engine defines the engine the material belongs to.
  20369. * @param disableBumpMap defines whether the material disables bump or not.
  20370. * @param isFrozen defines whether the material is frozen or not.
  20371. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20372. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20373. * @param subMesh the submesh to bind data for
  20374. */
  20375. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20376. /**
  20377. * Checks to see if a texture is used in the material.
  20378. * @param texture - Base texture to use.
  20379. * @returns - Boolean specifying if a texture is used in the material.
  20380. */
  20381. hasTexture(texture: BaseTexture): boolean;
  20382. /**
  20383. * Returns an array of the actively used textures.
  20384. * @param activeTextures Array of BaseTextures
  20385. */
  20386. getActiveTextures(activeTextures: BaseTexture[]): void;
  20387. /**
  20388. * Returns the animatable textures.
  20389. * @param animatables Array of animatable textures.
  20390. */
  20391. getAnimatables(animatables: IAnimatable[]): void;
  20392. /**
  20393. * Disposes the resources of the material.
  20394. * @param forceDisposeTextures - Forces the disposal of all textures.
  20395. */
  20396. dispose(forceDisposeTextures?: boolean): void;
  20397. /**
  20398. * Get the current class name of the texture useful for serialization or dynamic coding.
  20399. * @returns "PBRClearCoatConfiguration"
  20400. */
  20401. getClassName(): string;
  20402. /**
  20403. * Add fallbacks to the effect fallbacks list.
  20404. * @param defines defines the Base texture to use.
  20405. * @param fallbacks defines the current fallback list.
  20406. * @param currentRank defines the current fallback rank.
  20407. * @returns the new fallback rank.
  20408. */
  20409. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20410. /**
  20411. * Add the required uniforms to the current list.
  20412. * @param uniforms defines the current uniform list.
  20413. */
  20414. static AddUniforms(uniforms: string[]): void;
  20415. /**
  20416. * Add the required samplers to the current list.
  20417. * @param samplers defines the current sampler list.
  20418. */
  20419. static AddSamplers(samplers: string[]): void;
  20420. /**
  20421. * Add the required uniforms to the current buffer.
  20422. * @param uniformBuffer defines the current uniform buffer.
  20423. */
  20424. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20425. /**
  20426. * Makes a duplicate of the current configuration into another one.
  20427. * @param clearCoatConfiguration define the config where to copy the info
  20428. */
  20429. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20430. /**
  20431. * Serializes this clear coat configuration.
  20432. * @returns - An object with the serialized config.
  20433. */
  20434. serialize(): any;
  20435. /**
  20436. * Parses a anisotropy Configuration from a serialized object.
  20437. * @param source - Serialized object.
  20438. * @param scene Defines the scene we are parsing for
  20439. * @param rootUrl Defines the rootUrl to load from
  20440. */
  20441. parse(source: any, scene: Scene, rootUrl: string): void;
  20442. }
  20443. }
  20444. declare module BABYLON {
  20445. /**
  20446. * @hidden
  20447. */
  20448. export interface IMaterialAnisotropicDefines {
  20449. ANISOTROPIC: boolean;
  20450. ANISOTROPIC_TEXTURE: boolean;
  20451. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20452. MAINUV1: boolean;
  20453. _areTexturesDirty: boolean;
  20454. _needUVs: boolean;
  20455. }
  20456. /**
  20457. * Define the code related to the anisotropic parameters of the pbr material.
  20458. */
  20459. export class PBRAnisotropicConfiguration {
  20460. private _isEnabled;
  20461. /**
  20462. * Defines if the anisotropy is enabled in the material.
  20463. */
  20464. isEnabled: boolean;
  20465. /**
  20466. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20467. */
  20468. intensity: number;
  20469. /**
  20470. * Defines if the effect is along the tangents, bitangents or in between.
  20471. * By default, the effect is "stretching" the highlights along the tangents.
  20472. */
  20473. direction: Vector2;
  20474. private _texture;
  20475. /**
  20476. * Stores the anisotropy values in a texture.
  20477. * rg is direction (like normal from -1 to 1)
  20478. * b is a intensity
  20479. */
  20480. texture: Nullable<BaseTexture>;
  20481. /** @hidden */
  20482. private _internalMarkAllSubMeshesAsTexturesDirty;
  20483. /** @hidden */
  20484. _markAllSubMeshesAsTexturesDirty(): void;
  20485. /**
  20486. * Instantiate a new instance of anisotropy configuration.
  20487. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20488. */
  20489. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20490. /**
  20491. * Specifies that the submesh is ready to be used.
  20492. * @param defines the list of "defines" to update.
  20493. * @param scene defines the scene the material belongs to.
  20494. * @returns - boolean indicating that the submesh is ready or not.
  20495. */
  20496. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20497. /**
  20498. * Checks to see if a texture is used in the material.
  20499. * @param defines the list of "defines" to update.
  20500. * @param mesh the mesh we are preparing the defines for.
  20501. * @param scene defines the scene the material belongs to.
  20502. */
  20503. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20504. /**
  20505. * Binds the material data.
  20506. * @param uniformBuffer defines the Uniform buffer to fill in.
  20507. * @param scene defines the scene the material belongs to.
  20508. * @param isFrozen defines whether the material is frozen or not.
  20509. */
  20510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20511. /**
  20512. * Checks to see if a texture is used in the material.
  20513. * @param texture - Base texture to use.
  20514. * @returns - Boolean specifying if a texture is used in the material.
  20515. */
  20516. hasTexture(texture: BaseTexture): boolean;
  20517. /**
  20518. * Returns an array of the actively used textures.
  20519. * @param activeTextures Array of BaseTextures
  20520. */
  20521. getActiveTextures(activeTextures: BaseTexture[]): void;
  20522. /**
  20523. * Returns the animatable textures.
  20524. * @param animatables Array of animatable textures.
  20525. */
  20526. getAnimatables(animatables: IAnimatable[]): void;
  20527. /**
  20528. * Disposes the resources of the material.
  20529. * @param forceDisposeTextures - Forces the disposal of all textures.
  20530. */
  20531. dispose(forceDisposeTextures?: boolean): void;
  20532. /**
  20533. * Get the current class name of the texture useful for serialization or dynamic coding.
  20534. * @returns "PBRAnisotropicConfiguration"
  20535. */
  20536. getClassName(): string;
  20537. /**
  20538. * Add fallbacks to the effect fallbacks list.
  20539. * @param defines defines the Base texture to use.
  20540. * @param fallbacks defines the current fallback list.
  20541. * @param currentRank defines the current fallback rank.
  20542. * @returns the new fallback rank.
  20543. */
  20544. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20545. /**
  20546. * Add the required uniforms to the current list.
  20547. * @param uniforms defines the current uniform list.
  20548. */
  20549. static AddUniforms(uniforms: string[]): void;
  20550. /**
  20551. * Add the required uniforms to the current buffer.
  20552. * @param uniformBuffer defines the current uniform buffer.
  20553. */
  20554. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20555. /**
  20556. * Add the required samplers to the current list.
  20557. * @param samplers defines the current sampler list.
  20558. */
  20559. static AddSamplers(samplers: string[]): void;
  20560. /**
  20561. * Makes a duplicate of the current configuration into another one.
  20562. * @param anisotropicConfiguration define the config where to copy the info
  20563. */
  20564. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20565. /**
  20566. * Serializes this anisotropy configuration.
  20567. * @returns - An object with the serialized config.
  20568. */
  20569. serialize(): any;
  20570. /**
  20571. * Parses a anisotropy Configuration from a serialized object.
  20572. * @param source - Serialized object.
  20573. * @param scene Defines the scene we are parsing for
  20574. * @param rootUrl Defines the rootUrl to load from
  20575. */
  20576. parse(source: any, scene: Scene, rootUrl: string): void;
  20577. }
  20578. }
  20579. declare module BABYLON {
  20580. /**
  20581. * @hidden
  20582. */
  20583. export interface IMaterialBRDFDefines {
  20584. BRDF_V_HEIGHT_CORRELATED: boolean;
  20585. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20586. SPHERICAL_HARMONICS: boolean;
  20587. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20588. /** @hidden */
  20589. _areMiscDirty: boolean;
  20590. }
  20591. /**
  20592. * Define the code related to the BRDF parameters of the pbr material.
  20593. */
  20594. export class PBRBRDFConfiguration {
  20595. /**
  20596. * Default value used for the energy conservation.
  20597. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20598. */
  20599. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20600. /**
  20601. * Default value used for the Smith Visibility Height Correlated mode.
  20602. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20603. */
  20604. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20605. /**
  20606. * Default value used for the IBL diffuse part.
  20607. * This can help switching back to the polynomials mode globally which is a tiny bit
  20608. * less GPU intensive at the drawback of a lower quality.
  20609. */
  20610. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20611. /**
  20612. * Default value used for activating energy conservation for the specular workflow.
  20613. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20614. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20615. */
  20616. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20617. private _useEnergyConservation;
  20618. /**
  20619. * Defines if the material uses energy conservation.
  20620. */
  20621. useEnergyConservation: boolean;
  20622. private _useSmithVisibilityHeightCorrelated;
  20623. /**
  20624. * LEGACY Mode set to false
  20625. * Defines if the material uses height smith correlated visibility term.
  20626. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20627. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20628. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20629. * Not relying on height correlated will also disable energy conservation.
  20630. */
  20631. useSmithVisibilityHeightCorrelated: boolean;
  20632. private _useSphericalHarmonics;
  20633. /**
  20634. * LEGACY Mode set to false
  20635. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20636. * diffuse part of the IBL.
  20637. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20638. * to the ground truth.
  20639. */
  20640. useSphericalHarmonics: boolean;
  20641. private _useSpecularGlossinessInputEnergyConservation;
  20642. /**
  20643. * Defines if the material uses energy conservation, when the specular workflow is active.
  20644. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20645. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20646. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20647. */
  20648. useSpecularGlossinessInputEnergyConservation: boolean;
  20649. /** @hidden */
  20650. private _internalMarkAllSubMeshesAsMiscDirty;
  20651. /** @hidden */
  20652. _markAllSubMeshesAsMiscDirty(): void;
  20653. /**
  20654. * Instantiate a new instance of clear coat configuration.
  20655. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20656. */
  20657. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20658. /**
  20659. * Checks to see if a texture is used in the material.
  20660. * @param defines the list of "defines" to update.
  20661. */
  20662. prepareDefines(defines: IMaterialBRDFDefines): void;
  20663. /**
  20664. * Get the current class name of the texture useful for serialization or dynamic coding.
  20665. * @returns "PBRClearCoatConfiguration"
  20666. */
  20667. getClassName(): string;
  20668. /**
  20669. * Makes a duplicate of the current configuration into another one.
  20670. * @param brdfConfiguration define the config where to copy the info
  20671. */
  20672. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20673. /**
  20674. * Serializes this BRDF configuration.
  20675. * @returns - An object with the serialized config.
  20676. */
  20677. serialize(): any;
  20678. /**
  20679. * Parses a anisotropy Configuration from a serialized object.
  20680. * @param source - Serialized object.
  20681. * @param scene Defines the scene we are parsing for
  20682. * @param rootUrl Defines the rootUrl to load from
  20683. */
  20684. parse(source: any, scene: Scene, rootUrl: string): void;
  20685. }
  20686. }
  20687. declare module BABYLON {
  20688. /**
  20689. * @hidden
  20690. */
  20691. export interface IMaterialSheenDefines {
  20692. SHEEN: boolean;
  20693. SHEEN_TEXTURE: boolean;
  20694. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20695. SHEEN_TEXTUREDIRECTUV: number;
  20696. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20697. SHEEN_LINKWITHALBEDO: boolean;
  20698. SHEEN_ROUGHNESS: boolean;
  20699. SHEEN_ALBEDOSCALING: boolean;
  20700. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20701. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20702. /** @hidden */
  20703. _areTexturesDirty: boolean;
  20704. }
  20705. /**
  20706. * Define the code related to the Sheen parameters of the pbr material.
  20707. */
  20708. export class PBRSheenConfiguration {
  20709. private _isEnabled;
  20710. /**
  20711. * Defines if the material uses sheen.
  20712. */
  20713. isEnabled: boolean;
  20714. private _linkSheenWithAlbedo;
  20715. /**
  20716. * Defines if the sheen is linked to the sheen color.
  20717. */
  20718. linkSheenWithAlbedo: boolean;
  20719. /**
  20720. * Defines the sheen intensity.
  20721. */
  20722. intensity: number;
  20723. /**
  20724. * Defines the sheen color.
  20725. */
  20726. color: Color3;
  20727. private _texture;
  20728. /**
  20729. * Stores the sheen tint values in a texture.
  20730. * rgb is tint
  20731. * 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)
  20732. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20733. */
  20734. texture: Nullable<BaseTexture>;
  20735. private _useRoughnessFromMainTexture;
  20736. /**
  20737. * Indicates that the alpha channel of the texture property will be used for roughness.
  20738. * Has no effect if the roughness (and texture!) property is not defined
  20739. */
  20740. useRoughnessFromMainTexture: boolean;
  20741. private _roughness;
  20742. /**
  20743. * Defines the sheen roughness.
  20744. * It is not taken into account if linkSheenWithAlbedo is true.
  20745. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20746. */
  20747. roughness: Nullable<number>;
  20748. private _textureRoughness;
  20749. /**
  20750. * Stores the sheen roughness in a texture.
  20751. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20752. */
  20753. textureRoughness: Nullable<BaseTexture>;
  20754. private _albedoScaling;
  20755. /**
  20756. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20757. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20758. * making it easier to setup and tweak the effect
  20759. */
  20760. albedoScaling: boolean;
  20761. /** @hidden */
  20762. private _internalMarkAllSubMeshesAsTexturesDirty;
  20763. /** @hidden */
  20764. _markAllSubMeshesAsTexturesDirty(): void;
  20765. /**
  20766. * Instantiate a new instance of clear coat configuration.
  20767. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20768. */
  20769. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20770. /**
  20771. * Specifies that the submesh is ready to be used.
  20772. * @param defines the list of "defines" to update.
  20773. * @param scene defines the scene the material belongs to.
  20774. * @returns - boolean indicating that the submesh is ready or not.
  20775. */
  20776. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20777. /**
  20778. * Checks to see if a texture is used in the material.
  20779. * @param defines the list of "defines" to update.
  20780. * @param scene defines the scene the material belongs to.
  20781. */
  20782. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20783. /**
  20784. * Binds the material data.
  20785. * @param uniformBuffer defines the Uniform buffer to fill in.
  20786. * @param scene defines the scene the material belongs to.
  20787. * @param isFrozen defines whether the material is frozen or not.
  20788. * @param subMesh the submesh to bind data for
  20789. */
  20790. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20791. /**
  20792. * Checks to see if a texture is used in the material.
  20793. * @param texture - Base texture to use.
  20794. * @returns - Boolean specifying if a texture is used in the material.
  20795. */
  20796. hasTexture(texture: BaseTexture): boolean;
  20797. /**
  20798. * Returns an array of the actively used textures.
  20799. * @param activeTextures Array of BaseTextures
  20800. */
  20801. getActiveTextures(activeTextures: BaseTexture[]): void;
  20802. /**
  20803. * Returns the animatable textures.
  20804. * @param animatables Array of animatable textures.
  20805. */
  20806. getAnimatables(animatables: IAnimatable[]): void;
  20807. /**
  20808. * Disposes the resources of the material.
  20809. * @param forceDisposeTextures - Forces the disposal of all textures.
  20810. */
  20811. dispose(forceDisposeTextures?: boolean): void;
  20812. /**
  20813. * Get the current class name of the texture useful for serialization or dynamic coding.
  20814. * @returns "PBRSheenConfiguration"
  20815. */
  20816. getClassName(): string;
  20817. /**
  20818. * Add fallbacks to the effect fallbacks list.
  20819. * @param defines defines the Base texture to use.
  20820. * @param fallbacks defines the current fallback list.
  20821. * @param currentRank defines the current fallback rank.
  20822. * @returns the new fallback rank.
  20823. */
  20824. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20825. /**
  20826. * Add the required uniforms to the current list.
  20827. * @param uniforms defines the current uniform list.
  20828. */
  20829. static AddUniforms(uniforms: string[]): void;
  20830. /**
  20831. * Add the required uniforms to the current buffer.
  20832. * @param uniformBuffer defines the current uniform buffer.
  20833. */
  20834. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20835. /**
  20836. * Add the required samplers to the current list.
  20837. * @param samplers defines the current sampler list.
  20838. */
  20839. static AddSamplers(samplers: string[]): void;
  20840. /**
  20841. * Makes a duplicate of the current configuration into another one.
  20842. * @param sheenConfiguration define the config where to copy the info
  20843. */
  20844. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20845. /**
  20846. * Serializes this BRDF configuration.
  20847. * @returns - An object with the serialized config.
  20848. */
  20849. serialize(): any;
  20850. /**
  20851. * Parses a anisotropy Configuration from a serialized object.
  20852. * @param source - Serialized object.
  20853. * @param scene Defines the scene we are parsing for
  20854. * @param rootUrl Defines the rootUrl to load from
  20855. */
  20856. parse(source: any, scene: Scene, rootUrl: string): void;
  20857. }
  20858. }
  20859. declare module BABYLON {
  20860. /**
  20861. * @hidden
  20862. */
  20863. export interface IMaterialSubSurfaceDefines {
  20864. SUBSURFACE: boolean;
  20865. SS_REFRACTION: boolean;
  20866. SS_TRANSLUCENCY: boolean;
  20867. SS_SCATTERING: boolean;
  20868. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20869. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20870. SS_REFRACTIONMAP_3D: boolean;
  20871. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20872. SS_LODINREFRACTIONALPHA: boolean;
  20873. SS_GAMMAREFRACTION: boolean;
  20874. SS_RGBDREFRACTION: boolean;
  20875. SS_LINEARSPECULARREFRACTION: boolean;
  20876. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20877. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20878. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20879. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20880. /** @hidden */
  20881. _areTexturesDirty: boolean;
  20882. }
  20883. /**
  20884. * Define the code related to the sub surface parameters of the pbr material.
  20885. */
  20886. export class PBRSubSurfaceConfiguration {
  20887. private _isRefractionEnabled;
  20888. /**
  20889. * Defines if the refraction is enabled in the material.
  20890. */
  20891. isRefractionEnabled: boolean;
  20892. private _isTranslucencyEnabled;
  20893. /**
  20894. * Defines if the translucency is enabled in the material.
  20895. */
  20896. isTranslucencyEnabled: boolean;
  20897. private _isScatteringEnabled;
  20898. /**
  20899. * Defines if the sub surface scattering is enabled in the material.
  20900. */
  20901. isScatteringEnabled: boolean;
  20902. private _scatteringDiffusionProfileIndex;
  20903. /**
  20904. * Diffusion profile for subsurface scattering.
  20905. * Useful for better scattering in the skins or foliages.
  20906. */
  20907. get scatteringDiffusionProfile(): Nullable<Color3>;
  20908. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20909. /**
  20910. * Defines the refraction intensity of the material.
  20911. * The refraction when enabled replaces the Diffuse part of the material.
  20912. * The intensity helps transitioning between diffuse and refraction.
  20913. */
  20914. refractionIntensity: number;
  20915. /**
  20916. * Defines the translucency intensity of the material.
  20917. * When translucency has been enabled, this defines how much of the "translucency"
  20918. * is added to the diffuse part of the material.
  20919. */
  20920. translucencyIntensity: number;
  20921. /**
  20922. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20923. */
  20924. useAlbedoToTintRefraction: boolean;
  20925. private _thicknessTexture;
  20926. /**
  20927. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20928. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20929. * 0 would mean minimumThickness
  20930. * 1 would mean maximumThickness
  20931. * The other channels might be use as a mask to vary the different effects intensity.
  20932. */
  20933. thicknessTexture: Nullable<BaseTexture>;
  20934. private _refractionTexture;
  20935. /**
  20936. * Defines the texture to use for refraction.
  20937. */
  20938. refractionTexture: Nullable<BaseTexture>;
  20939. private _indexOfRefraction;
  20940. /**
  20941. * Index of refraction of the material base layer.
  20942. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20943. *
  20944. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20945. *
  20946. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20947. */
  20948. indexOfRefraction: number;
  20949. private _volumeIndexOfRefraction;
  20950. /**
  20951. * Index of refraction of the material's volume.
  20952. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20953. *
  20954. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20955. * the volume will use the same IOR as the surface.
  20956. */
  20957. get volumeIndexOfRefraction(): number;
  20958. set volumeIndexOfRefraction(value: number);
  20959. private _invertRefractionY;
  20960. /**
  20961. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20962. */
  20963. invertRefractionY: boolean;
  20964. private _linkRefractionWithTransparency;
  20965. /**
  20966. * This parameters will make the material used its opacity to control how much it is refracting against not.
  20967. * Materials half opaque for instance using refraction could benefit from this control.
  20968. */
  20969. linkRefractionWithTransparency: boolean;
  20970. /**
  20971. * Defines the minimum thickness stored in the thickness map.
  20972. * If no thickness map is defined, this value will be used to simulate thickness.
  20973. */
  20974. minimumThickness: number;
  20975. /**
  20976. * Defines the maximum thickness stored in the thickness map.
  20977. */
  20978. maximumThickness: number;
  20979. /**
  20980. * Defines the volume tint of the material.
  20981. * This is used for both translucency and scattering.
  20982. */
  20983. tintColor: Color3;
  20984. /**
  20985. * Defines the distance at which the tint color should be found in the media.
  20986. * This is used for refraction only.
  20987. */
  20988. tintColorAtDistance: number;
  20989. /**
  20990. * Defines how far each channel transmit through the media.
  20991. * It is defined as a color to simplify it selection.
  20992. */
  20993. diffusionDistance: Color3;
  20994. private _useMaskFromThicknessTexture;
  20995. /**
  20996. * Stores the intensity of the different subsurface effects in the thickness texture.
  20997. * * the green channel is the translucency intensity.
  20998. * * the blue channel is the scattering intensity.
  20999. * * the alpha channel is the refraction intensity.
  21000. */
  21001. useMaskFromThicknessTexture: boolean;
  21002. private _scene;
  21003. private _useMaskFromThicknessTextureGltf;
  21004. /**
  21005. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  21006. * matches the channel-packing that is used by glTF.
  21007. * * the red channel is the transmission/translucency intensity.
  21008. * * the green channel is the thickness.
  21009. */
  21010. useMaskFromThicknessTextureGltf: boolean;
  21011. /** @hidden */
  21012. private _internalMarkAllSubMeshesAsTexturesDirty;
  21013. private _internalMarkScenePrePassDirty;
  21014. /** @hidden */
  21015. _markAllSubMeshesAsTexturesDirty(): void;
  21016. /** @hidden */
  21017. _markScenePrePassDirty(): void;
  21018. /**
  21019. * Instantiate a new instance of sub surface configuration.
  21020. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  21021. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  21022. * @param scene The scene
  21023. */
  21024. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  21025. /**
  21026. * Gets whether the submesh is ready to be used or not.
  21027. * @param defines the list of "defines" to update.
  21028. * @param scene defines the scene the material belongs to.
  21029. * @returns - boolean indicating that the submesh is ready or not.
  21030. */
  21031. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  21032. /**
  21033. * Checks to see if a texture is used in the material.
  21034. * @param defines the list of "defines" to update.
  21035. * @param scene defines the scene to the material belongs to.
  21036. */
  21037. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  21038. /**
  21039. * Binds the material data.
  21040. * @param uniformBuffer defines the Uniform buffer to fill in.
  21041. * @param scene defines the scene the material belongs to.
  21042. * @param engine defines the engine the material belongs to.
  21043. * @param isFrozen defines whether the material is frozen or not.
  21044. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  21045. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  21046. */
  21047. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  21048. /**
  21049. * Unbinds the material from the mesh.
  21050. * @param activeEffect defines the effect that should be unbound from.
  21051. * @returns true if unbound, otherwise false
  21052. */
  21053. unbind(activeEffect: Effect): boolean;
  21054. /**
  21055. * Returns the texture used for refraction or null if none is used.
  21056. * @param scene defines the scene the material belongs to.
  21057. * @returns - Refraction texture if present. If no refraction texture and refraction
  21058. * is linked with transparency, returns environment texture. Otherwise, returns null.
  21059. */
  21060. private _getRefractionTexture;
  21061. /**
  21062. * Returns true if alpha blending should be disabled.
  21063. */
  21064. get disableAlphaBlending(): boolean;
  21065. /**
  21066. * Fills the list of render target textures.
  21067. * @param renderTargets the list of render targets to update
  21068. */
  21069. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  21070. /**
  21071. * Checks to see if a texture is used in the material.
  21072. * @param texture - Base texture to use.
  21073. * @returns - Boolean specifying if a texture is used in the material.
  21074. */
  21075. hasTexture(texture: BaseTexture): boolean;
  21076. /**
  21077. * Gets a boolean indicating that current material needs to register RTT
  21078. * @returns true if this uses a render target otherwise false.
  21079. */
  21080. hasRenderTargetTextures(): boolean;
  21081. /**
  21082. * Returns an array of the actively used textures.
  21083. * @param activeTextures Array of BaseTextures
  21084. */
  21085. getActiveTextures(activeTextures: BaseTexture[]): void;
  21086. /**
  21087. * Returns the animatable textures.
  21088. * @param animatables Array of animatable textures.
  21089. */
  21090. getAnimatables(animatables: IAnimatable[]): void;
  21091. /**
  21092. * Disposes the resources of the material.
  21093. * @param forceDisposeTextures - Forces the disposal of all textures.
  21094. */
  21095. dispose(forceDisposeTextures?: boolean): void;
  21096. /**
  21097. * Get the current class name of the texture useful for serialization or dynamic coding.
  21098. * @returns "PBRSubSurfaceConfiguration"
  21099. */
  21100. getClassName(): string;
  21101. /**
  21102. * Add fallbacks to the effect fallbacks list.
  21103. * @param defines defines the Base texture to use.
  21104. * @param fallbacks defines the current fallback list.
  21105. * @param currentRank defines the current fallback rank.
  21106. * @returns the new fallback rank.
  21107. */
  21108. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  21109. /**
  21110. * Add the required uniforms to the current list.
  21111. * @param uniforms defines the current uniform list.
  21112. */
  21113. static AddUniforms(uniforms: string[]): void;
  21114. /**
  21115. * Add the required samplers to the current list.
  21116. * @param samplers defines the current sampler list.
  21117. */
  21118. static AddSamplers(samplers: string[]): void;
  21119. /**
  21120. * Add the required uniforms to the current buffer.
  21121. * @param uniformBuffer defines the current uniform buffer.
  21122. */
  21123. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  21124. /**
  21125. * Makes a duplicate of the current configuration into another one.
  21126. * @param configuration define the config where to copy the info
  21127. */
  21128. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  21129. /**
  21130. * Serializes this Sub Surface configuration.
  21131. * @returns - An object with the serialized config.
  21132. */
  21133. serialize(): any;
  21134. /**
  21135. * Parses a anisotropy Configuration from a serialized object.
  21136. * @param source - Serialized object.
  21137. * @param scene Defines the scene we are parsing for
  21138. * @param rootUrl Defines the rootUrl to load from
  21139. */
  21140. parse(source: any, scene: Scene, rootUrl: string): void;
  21141. }
  21142. }
  21143. declare module BABYLON {
  21144. /**
  21145. * Class representing spherical harmonics coefficients to the 3rd degree
  21146. */
  21147. export class SphericalHarmonics {
  21148. /**
  21149. * Defines whether or not the harmonics have been prescaled for rendering.
  21150. */
  21151. preScaled: boolean;
  21152. /**
  21153. * The l0,0 coefficients of the spherical harmonics
  21154. */
  21155. l00: Vector3;
  21156. /**
  21157. * The l1,-1 coefficients of the spherical harmonics
  21158. */
  21159. l1_1: Vector3;
  21160. /**
  21161. * The l1,0 coefficients of the spherical harmonics
  21162. */
  21163. l10: Vector3;
  21164. /**
  21165. * The l1,1 coefficients of the spherical harmonics
  21166. */
  21167. l11: Vector3;
  21168. /**
  21169. * The l2,-2 coefficients of the spherical harmonics
  21170. */
  21171. l2_2: Vector3;
  21172. /**
  21173. * The l2,-1 coefficients of the spherical harmonics
  21174. */
  21175. l2_1: Vector3;
  21176. /**
  21177. * The l2,0 coefficients of the spherical harmonics
  21178. */
  21179. l20: Vector3;
  21180. /**
  21181. * The l2,1 coefficients of the spherical harmonics
  21182. */
  21183. l21: Vector3;
  21184. /**
  21185. * The l2,2 coefficients of the spherical harmonics
  21186. */
  21187. l22: Vector3;
  21188. /**
  21189. * Adds a light to the spherical harmonics
  21190. * @param direction the direction of the light
  21191. * @param color the color of the light
  21192. * @param deltaSolidAngle the delta solid angle of the light
  21193. */
  21194. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  21195. /**
  21196. * Scales the spherical harmonics by the given amount
  21197. * @param scale the amount to scale
  21198. */
  21199. scaleInPlace(scale: number): void;
  21200. /**
  21201. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  21202. *
  21203. * ```
  21204. * E_lm = A_l * L_lm
  21205. * ```
  21206. *
  21207. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  21208. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  21209. * the scaling factors are given in equation 9.
  21210. */
  21211. convertIncidentRadianceToIrradiance(): void;
  21212. /**
  21213. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21214. *
  21215. * ```
  21216. * L = (1/pi) * E * rho
  21217. * ```
  21218. *
  21219. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21220. */
  21221. convertIrradianceToLambertianRadiance(): void;
  21222. /**
  21223. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21224. * required operations at run time.
  21225. *
  21226. * This is simply done by scaling back the SH with Ylm constants parameter.
  21227. * The trigonometric part being applied by the shader at run time.
  21228. */
  21229. preScaleForRendering(): void;
  21230. /**
  21231. * Constructs a spherical harmonics from an array.
  21232. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21233. * @returns the spherical harmonics
  21234. */
  21235. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21236. /**
  21237. * Gets the spherical harmonics from polynomial
  21238. * @param polynomial the spherical polynomial
  21239. * @returns the spherical harmonics
  21240. */
  21241. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21242. }
  21243. /**
  21244. * Class representing spherical polynomial coefficients to the 3rd degree
  21245. */
  21246. export class SphericalPolynomial {
  21247. private _harmonics;
  21248. /**
  21249. * The spherical harmonics used to create the polynomials.
  21250. */
  21251. get preScaledHarmonics(): SphericalHarmonics;
  21252. /**
  21253. * The x coefficients of the spherical polynomial
  21254. */
  21255. x: Vector3;
  21256. /**
  21257. * The y coefficients of the spherical polynomial
  21258. */
  21259. y: Vector3;
  21260. /**
  21261. * The z coefficients of the spherical polynomial
  21262. */
  21263. z: Vector3;
  21264. /**
  21265. * The xx coefficients of the spherical polynomial
  21266. */
  21267. xx: Vector3;
  21268. /**
  21269. * The yy coefficients of the spherical polynomial
  21270. */
  21271. yy: Vector3;
  21272. /**
  21273. * The zz coefficients of the spherical polynomial
  21274. */
  21275. zz: Vector3;
  21276. /**
  21277. * The xy coefficients of the spherical polynomial
  21278. */
  21279. xy: Vector3;
  21280. /**
  21281. * The yz coefficients of the spherical polynomial
  21282. */
  21283. yz: Vector3;
  21284. /**
  21285. * The zx coefficients of the spherical polynomial
  21286. */
  21287. zx: Vector3;
  21288. /**
  21289. * Adds an ambient color to the spherical polynomial
  21290. * @param color the color to add
  21291. */
  21292. addAmbient(color: Color3): void;
  21293. /**
  21294. * Scales the spherical polynomial by the given amount
  21295. * @param scale the amount to scale
  21296. */
  21297. scaleInPlace(scale: number): void;
  21298. /**
  21299. * Gets the spherical polynomial from harmonics
  21300. * @param harmonics the spherical harmonics
  21301. * @returns the spherical polynomial
  21302. */
  21303. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21304. /**
  21305. * Constructs a spherical polynomial from an array.
  21306. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21307. * @returns the spherical polynomial
  21308. */
  21309. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21310. }
  21311. }
  21312. declare module BABYLON {
  21313. /**
  21314. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21315. */
  21316. export interface CubeMapInfo {
  21317. /**
  21318. * The pixel array for the front face.
  21319. * This is stored in format, left to right, up to down format.
  21320. */
  21321. front: Nullable<ArrayBufferView>;
  21322. /**
  21323. * The pixel array for the back face.
  21324. * This is stored in format, left to right, up to down format.
  21325. */
  21326. back: Nullable<ArrayBufferView>;
  21327. /**
  21328. * The pixel array for the left face.
  21329. * This is stored in format, left to right, up to down format.
  21330. */
  21331. left: Nullable<ArrayBufferView>;
  21332. /**
  21333. * The pixel array for the right face.
  21334. * This is stored in format, left to right, up to down format.
  21335. */
  21336. right: Nullable<ArrayBufferView>;
  21337. /**
  21338. * The pixel array for the up face.
  21339. * This is stored in format, left to right, up to down format.
  21340. */
  21341. up: Nullable<ArrayBufferView>;
  21342. /**
  21343. * The pixel array for the down face.
  21344. * This is stored in format, left to right, up to down format.
  21345. */
  21346. down: Nullable<ArrayBufferView>;
  21347. /**
  21348. * The size of the cubemap stored.
  21349. *
  21350. * Each faces will be size * size pixels.
  21351. */
  21352. size: number;
  21353. /**
  21354. * The format of the texture.
  21355. *
  21356. * RGBA, RGB.
  21357. */
  21358. format: number;
  21359. /**
  21360. * The type of the texture data.
  21361. *
  21362. * UNSIGNED_INT, FLOAT.
  21363. */
  21364. type: number;
  21365. /**
  21366. * Specifies whether the texture is in gamma space.
  21367. */
  21368. gammaSpace: boolean;
  21369. }
  21370. /**
  21371. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21372. */
  21373. export class PanoramaToCubeMapTools {
  21374. private static FACE_LEFT;
  21375. private static FACE_RIGHT;
  21376. private static FACE_FRONT;
  21377. private static FACE_BACK;
  21378. private static FACE_DOWN;
  21379. private static FACE_UP;
  21380. /**
  21381. * Converts a panorama stored in RGB right to left up to down format into a cubemap (6 faces).
  21382. *
  21383. * @param float32Array The source data.
  21384. * @param inputWidth The width of the input panorama.
  21385. * @param inputHeight The height of the input panorama.
  21386. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21387. * @return The cubemap data
  21388. */
  21389. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21390. private static CreateCubemapTexture;
  21391. private static CalcProjectionSpherical;
  21392. }
  21393. }
  21394. declare module BABYLON {
  21395. /**
  21396. * Helper class dealing with the extraction of spherical polynomial dataArray
  21397. * from a cube map.
  21398. */
  21399. export class CubeMapToSphericalPolynomialTools {
  21400. private static FileFaces;
  21401. /**
  21402. * Converts a texture to the according Spherical Polynomial data.
  21403. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21404. *
  21405. * @param texture The texture to extract the information from.
  21406. * @return The Spherical Polynomial data.
  21407. */
  21408. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21409. /**
  21410. * Converts a cubemap to the according Spherical Polynomial data.
  21411. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21412. *
  21413. * @param cubeInfo The Cube map to extract the information from.
  21414. * @return The Spherical Polynomial data.
  21415. */
  21416. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21417. }
  21418. }
  21419. declare module BABYLON {
  21420. interface BaseTexture {
  21421. /**
  21422. * Get the polynomial representation of the texture data.
  21423. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21424. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21425. */
  21426. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21427. }
  21428. }
  21429. declare module BABYLON {
  21430. /** @hidden */
  21431. export var pbrFragmentDeclaration: {
  21432. name: string;
  21433. shader: string;
  21434. };
  21435. }
  21436. declare module BABYLON {
  21437. /** @hidden */
  21438. export var pbrUboDeclaration: {
  21439. name: string;
  21440. shader: string;
  21441. };
  21442. }
  21443. declare module BABYLON {
  21444. /** @hidden */
  21445. export var pbrFragmentExtraDeclaration: {
  21446. name: string;
  21447. shader: string;
  21448. };
  21449. }
  21450. declare module BABYLON {
  21451. /** @hidden */
  21452. export var pbrFragmentSamplersDeclaration: {
  21453. name: string;
  21454. shader: string;
  21455. };
  21456. }
  21457. declare module BABYLON {
  21458. /** @hidden */
  21459. export var subSurfaceScatteringFunctions: {
  21460. name: string;
  21461. shader: string;
  21462. };
  21463. }
  21464. declare module BABYLON {
  21465. /** @hidden */
  21466. export var importanceSampling: {
  21467. name: string;
  21468. shader: string;
  21469. };
  21470. }
  21471. declare module BABYLON {
  21472. /** @hidden */
  21473. export var pbrHelperFunctions: {
  21474. name: string;
  21475. shader: string;
  21476. };
  21477. }
  21478. declare module BABYLON {
  21479. /** @hidden */
  21480. export var harmonicsFunctions: {
  21481. name: string;
  21482. shader: string;
  21483. };
  21484. }
  21485. declare module BABYLON {
  21486. /** @hidden */
  21487. export var pbrDirectLightingSetupFunctions: {
  21488. name: string;
  21489. shader: string;
  21490. };
  21491. }
  21492. declare module BABYLON {
  21493. /** @hidden */
  21494. export var pbrDirectLightingFalloffFunctions: {
  21495. name: string;
  21496. shader: string;
  21497. };
  21498. }
  21499. declare module BABYLON {
  21500. /** @hidden */
  21501. export var pbrBRDFFunctions: {
  21502. name: string;
  21503. shader: string;
  21504. };
  21505. }
  21506. declare module BABYLON {
  21507. /** @hidden */
  21508. export var hdrFilteringFunctions: {
  21509. name: string;
  21510. shader: string;
  21511. };
  21512. }
  21513. declare module BABYLON {
  21514. /** @hidden */
  21515. export var pbrDirectLightingFunctions: {
  21516. name: string;
  21517. shader: string;
  21518. };
  21519. }
  21520. declare module BABYLON {
  21521. /** @hidden */
  21522. export var pbrIBLFunctions: {
  21523. name: string;
  21524. shader: string;
  21525. };
  21526. }
  21527. declare module BABYLON {
  21528. /** @hidden */
  21529. export var pbrBlockAlbedoOpacity: {
  21530. name: string;
  21531. shader: string;
  21532. };
  21533. }
  21534. declare module BABYLON {
  21535. /** @hidden */
  21536. export var pbrBlockReflectivity: {
  21537. name: string;
  21538. shader: string;
  21539. };
  21540. }
  21541. declare module BABYLON {
  21542. /** @hidden */
  21543. export var pbrBlockAmbientOcclusion: {
  21544. name: string;
  21545. shader: string;
  21546. };
  21547. }
  21548. declare module BABYLON {
  21549. /** @hidden */
  21550. export var pbrBlockAlphaFresnel: {
  21551. name: string;
  21552. shader: string;
  21553. };
  21554. }
  21555. declare module BABYLON {
  21556. /** @hidden */
  21557. export var pbrBlockAnisotropic: {
  21558. name: string;
  21559. shader: string;
  21560. };
  21561. }
  21562. declare module BABYLON {
  21563. /** @hidden */
  21564. export var pbrBlockReflection: {
  21565. name: string;
  21566. shader: string;
  21567. };
  21568. }
  21569. declare module BABYLON {
  21570. /** @hidden */
  21571. export var pbrBlockSheen: {
  21572. name: string;
  21573. shader: string;
  21574. };
  21575. }
  21576. declare module BABYLON {
  21577. /** @hidden */
  21578. export var pbrBlockClearcoat: {
  21579. name: string;
  21580. shader: string;
  21581. };
  21582. }
  21583. declare module BABYLON {
  21584. /** @hidden */
  21585. export var pbrBlockSubSurface: {
  21586. name: string;
  21587. shader: string;
  21588. };
  21589. }
  21590. declare module BABYLON {
  21591. /** @hidden */
  21592. export var pbrBlockNormalGeometric: {
  21593. name: string;
  21594. shader: string;
  21595. };
  21596. }
  21597. declare module BABYLON {
  21598. /** @hidden */
  21599. export var pbrBlockNormalFinal: {
  21600. name: string;
  21601. shader: string;
  21602. };
  21603. }
  21604. declare module BABYLON {
  21605. /** @hidden */
  21606. export var pbrBlockLightmapInit: {
  21607. name: string;
  21608. shader: string;
  21609. };
  21610. }
  21611. declare module BABYLON {
  21612. /** @hidden */
  21613. export var pbrBlockGeometryInfo: {
  21614. name: string;
  21615. shader: string;
  21616. };
  21617. }
  21618. declare module BABYLON {
  21619. /** @hidden */
  21620. export var pbrBlockReflectance0: {
  21621. name: string;
  21622. shader: string;
  21623. };
  21624. }
  21625. declare module BABYLON {
  21626. /** @hidden */
  21627. export var pbrBlockReflectance: {
  21628. name: string;
  21629. shader: string;
  21630. };
  21631. }
  21632. declare module BABYLON {
  21633. /** @hidden */
  21634. export var pbrBlockDirectLighting: {
  21635. name: string;
  21636. shader: string;
  21637. };
  21638. }
  21639. declare module BABYLON {
  21640. /** @hidden */
  21641. export var pbrBlockFinalLitComponents: {
  21642. name: string;
  21643. shader: string;
  21644. };
  21645. }
  21646. declare module BABYLON {
  21647. /** @hidden */
  21648. export var pbrBlockFinalUnlitComponents: {
  21649. name: string;
  21650. shader: string;
  21651. };
  21652. }
  21653. declare module BABYLON {
  21654. /** @hidden */
  21655. export var pbrBlockFinalColorComposition: {
  21656. name: string;
  21657. shader: string;
  21658. };
  21659. }
  21660. declare module BABYLON {
  21661. /** @hidden */
  21662. export var pbrBlockImageProcessing: {
  21663. name: string;
  21664. shader: string;
  21665. };
  21666. }
  21667. declare module BABYLON {
  21668. /** @hidden */
  21669. export var pbrDebug: {
  21670. name: string;
  21671. shader: string;
  21672. };
  21673. }
  21674. declare module BABYLON {
  21675. /** @hidden */
  21676. export var pbrPixelShader: {
  21677. name: string;
  21678. shader: string;
  21679. };
  21680. }
  21681. declare module BABYLON {
  21682. /** @hidden */
  21683. export var pbrVertexDeclaration: {
  21684. name: string;
  21685. shader: string;
  21686. };
  21687. }
  21688. declare module BABYLON {
  21689. /** @hidden */
  21690. export var pbrVertexShader: {
  21691. name: string;
  21692. shader: string;
  21693. };
  21694. }
  21695. declare module BABYLON {
  21696. /**
  21697. * Manages the defines for the PBR Material.
  21698. * @hidden
  21699. */
  21700. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21701. PBR: boolean;
  21702. NUM_SAMPLES: string;
  21703. REALTIME_FILTERING: boolean;
  21704. MAINUV1: boolean;
  21705. MAINUV2: boolean;
  21706. UV1: boolean;
  21707. UV2: boolean;
  21708. ALBEDO: boolean;
  21709. GAMMAALBEDO: boolean;
  21710. ALBEDODIRECTUV: number;
  21711. VERTEXCOLOR: boolean;
  21712. DETAIL: boolean;
  21713. DETAILDIRECTUV: number;
  21714. DETAIL_NORMALBLENDMETHOD: number;
  21715. AMBIENT: boolean;
  21716. AMBIENTDIRECTUV: number;
  21717. AMBIENTINGRAYSCALE: boolean;
  21718. OPACITY: boolean;
  21719. VERTEXALPHA: boolean;
  21720. OPACITYDIRECTUV: number;
  21721. OPACITYRGB: boolean;
  21722. ALPHATEST: boolean;
  21723. DEPTHPREPASS: boolean;
  21724. ALPHABLEND: boolean;
  21725. ALPHAFROMALBEDO: boolean;
  21726. ALPHATESTVALUE: string;
  21727. SPECULAROVERALPHA: boolean;
  21728. RADIANCEOVERALPHA: boolean;
  21729. ALPHAFRESNEL: boolean;
  21730. LINEARALPHAFRESNEL: boolean;
  21731. PREMULTIPLYALPHA: boolean;
  21732. EMISSIVE: boolean;
  21733. EMISSIVEDIRECTUV: number;
  21734. REFLECTIVITY: boolean;
  21735. REFLECTIVITYDIRECTUV: number;
  21736. SPECULARTERM: boolean;
  21737. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21738. MICROSURFACEAUTOMATIC: boolean;
  21739. LODBASEDMICROSFURACE: boolean;
  21740. MICROSURFACEMAP: boolean;
  21741. MICROSURFACEMAPDIRECTUV: number;
  21742. METALLICWORKFLOW: boolean;
  21743. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21744. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21745. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21746. AOSTOREINMETALMAPRED: boolean;
  21747. METALLIC_REFLECTANCE: boolean;
  21748. METALLIC_REFLECTANCEDIRECTUV: number;
  21749. ENVIRONMENTBRDF: boolean;
  21750. ENVIRONMENTBRDF_RGBD: boolean;
  21751. NORMAL: boolean;
  21752. TANGENT: boolean;
  21753. BUMP: boolean;
  21754. BUMPDIRECTUV: number;
  21755. OBJECTSPACE_NORMALMAP: boolean;
  21756. PARALLAX: boolean;
  21757. PARALLAXOCCLUSION: boolean;
  21758. NORMALXYSCALE: boolean;
  21759. LIGHTMAP: boolean;
  21760. LIGHTMAPDIRECTUV: number;
  21761. USELIGHTMAPASSHADOWMAP: boolean;
  21762. GAMMALIGHTMAP: boolean;
  21763. RGBDLIGHTMAP: boolean;
  21764. REFLECTION: boolean;
  21765. REFLECTIONMAP_3D: boolean;
  21766. REFLECTIONMAP_SPHERICAL: boolean;
  21767. REFLECTIONMAP_PLANAR: boolean;
  21768. REFLECTIONMAP_CUBIC: boolean;
  21769. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21770. REFLECTIONMAP_PROJECTION: boolean;
  21771. REFLECTIONMAP_SKYBOX: boolean;
  21772. REFLECTIONMAP_EXPLICIT: boolean;
  21773. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21774. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21775. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21776. INVERTCUBICMAP: boolean;
  21777. USESPHERICALFROMREFLECTIONMAP: boolean;
  21778. USEIRRADIANCEMAP: boolean;
  21779. SPHERICAL_HARMONICS: boolean;
  21780. USESPHERICALINVERTEX: boolean;
  21781. REFLECTIONMAP_OPPOSITEZ: boolean;
  21782. LODINREFLECTIONALPHA: boolean;
  21783. GAMMAREFLECTION: boolean;
  21784. RGBDREFLECTION: boolean;
  21785. LINEARSPECULARREFLECTION: boolean;
  21786. RADIANCEOCCLUSION: boolean;
  21787. HORIZONOCCLUSION: boolean;
  21788. INSTANCES: boolean;
  21789. THIN_INSTANCES: boolean;
  21790. PREPASS: boolean;
  21791. PREPASS_IRRADIANCE: boolean;
  21792. PREPASS_IRRADIANCE_INDEX: number;
  21793. PREPASS_ALBEDO: boolean;
  21794. PREPASS_ALBEDO_INDEX: number;
  21795. PREPASS_DEPTH: boolean;
  21796. PREPASS_DEPTH_INDEX: number;
  21797. PREPASS_NORMAL: boolean;
  21798. PREPASS_NORMAL_INDEX: number;
  21799. PREPASS_POSITION: boolean;
  21800. PREPASS_POSITION_INDEX: number;
  21801. PREPASS_VELOCITY: boolean;
  21802. PREPASS_VELOCITY_INDEX: number;
  21803. PREPASS_REFLECTIVITY: boolean;
  21804. PREPASS_REFLECTIVITY_INDEX: number;
  21805. SCENE_MRT_COUNT: number;
  21806. NUM_BONE_INFLUENCERS: number;
  21807. BonesPerMesh: number;
  21808. BONETEXTURE: boolean;
  21809. BONES_VELOCITY_ENABLED: boolean;
  21810. NONUNIFORMSCALING: boolean;
  21811. MORPHTARGETS: boolean;
  21812. MORPHTARGETS_NORMAL: boolean;
  21813. MORPHTARGETS_TANGENT: boolean;
  21814. MORPHTARGETS_UV: boolean;
  21815. NUM_MORPH_INFLUENCERS: number;
  21816. MORPHTARGETS_TEXTURE: boolean;
  21817. IMAGEPROCESSING: boolean;
  21818. VIGNETTE: boolean;
  21819. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21820. VIGNETTEBLENDMODEOPAQUE: boolean;
  21821. TONEMAPPING: boolean;
  21822. TONEMAPPING_ACES: boolean;
  21823. CONTRAST: boolean;
  21824. COLORCURVES: boolean;
  21825. COLORGRADING: boolean;
  21826. COLORGRADING3D: boolean;
  21827. SAMPLER3DGREENDEPTH: boolean;
  21828. SAMPLER3DBGRMAP: boolean;
  21829. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21830. EXPOSURE: boolean;
  21831. MULTIVIEW: boolean;
  21832. USEPHYSICALLIGHTFALLOFF: boolean;
  21833. USEGLTFLIGHTFALLOFF: boolean;
  21834. TWOSIDEDLIGHTING: boolean;
  21835. SHADOWFLOAT: boolean;
  21836. CLIPPLANE: boolean;
  21837. CLIPPLANE2: boolean;
  21838. CLIPPLANE3: boolean;
  21839. CLIPPLANE4: boolean;
  21840. CLIPPLANE5: boolean;
  21841. CLIPPLANE6: boolean;
  21842. POINTSIZE: boolean;
  21843. FOG: boolean;
  21844. LOGARITHMICDEPTH: boolean;
  21845. FORCENORMALFORWARD: boolean;
  21846. SPECULARAA: boolean;
  21847. CLEARCOAT: boolean;
  21848. CLEARCOAT_DEFAULTIOR: boolean;
  21849. CLEARCOAT_TEXTURE: boolean;
  21850. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21851. CLEARCOAT_TEXTUREDIRECTUV: number;
  21852. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21853. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21854. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21855. CLEARCOAT_BUMP: boolean;
  21856. CLEARCOAT_BUMPDIRECTUV: number;
  21857. CLEARCOAT_REMAP_F0: boolean;
  21858. CLEARCOAT_TINT: boolean;
  21859. CLEARCOAT_TINT_TEXTURE: boolean;
  21860. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21861. ANISOTROPIC: boolean;
  21862. ANISOTROPIC_TEXTURE: boolean;
  21863. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21864. BRDF_V_HEIGHT_CORRELATED: boolean;
  21865. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21866. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21867. SHEEN: boolean;
  21868. SHEEN_TEXTURE: boolean;
  21869. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21870. SHEEN_TEXTUREDIRECTUV: number;
  21871. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21872. SHEEN_LINKWITHALBEDO: boolean;
  21873. SHEEN_ROUGHNESS: boolean;
  21874. SHEEN_ALBEDOSCALING: boolean;
  21875. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21876. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21877. SUBSURFACE: boolean;
  21878. SS_REFRACTION: boolean;
  21879. SS_TRANSLUCENCY: boolean;
  21880. SS_SCATTERING: boolean;
  21881. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21882. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21883. SS_REFRACTIONMAP_3D: boolean;
  21884. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21885. SS_LODINREFRACTIONALPHA: boolean;
  21886. SS_GAMMAREFRACTION: boolean;
  21887. SS_RGBDREFRACTION: boolean;
  21888. SS_LINEARSPECULARREFRACTION: boolean;
  21889. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21890. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21891. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21892. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21893. UNLIT: boolean;
  21894. DEBUGMODE: number;
  21895. /**
  21896. * Initializes the PBR Material defines.
  21897. */
  21898. constructor();
  21899. /**
  21900. * Resets the PBR Material defines.
  21901. */
  21902. reset(): void;
  21903. }
  21904. /**
  21905. * The Physically based material base class of BJS.
  21906. *
  21907. * This offers the main features of a standard PBR material.
  21908. * For more information, please refer to the documentation :
  21909. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21910. */
  21911. export abstract class PBRBaseMaterial extends PushMaterial {
  21912. /**
  21913. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21914. */
  21915. static readonly PBRMATERIAL_OPAQUE: number;
  21916. /**
  21917. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21918. */
  21919. static readonly PBRMATERIAL_ALPHATEST: number;
  21920. /**
  21921. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21922. */
  21923. static readonly PBRMATERIAL_ALPHABLEND: number;
  21924. /**
  21925. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21926. * They are also discarded below the alpha cutoff threshold to improve performances.
  21927. */
  21928. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21929. /**
  21930. * Defines the default value of how much AO map is occluding the analytical lights
  21931. * (point spot...).
  21932. */
  21933. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21934. /**
  21935. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21936. */
  21937. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21938. /**
  21939. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21940. * to enhance interoperability with other engines.
  21941. */
  21942. static readonly LIGHTFALLOFF_GLTF: number;
  21943. /**
  21944. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21945. * to enhance interoperability with other materials.
  21946. */
  21947. static readonly LIGHTFALLOFF_STANDARD: number;
  21948. /**
  21949. * Intensity of the direct lights e.g. the four lights available in your scene.
  21950. * This impacts both the direct diffuse and specular highlights.
  21951. */
  21952. protected _directIntensity: number;
  21953. /**
  21954. * Intensity of the emissive part of the material.
  21955. * This helps controlling the emissive effect without modifying the emissive color.
  21956. */
  21957. protected _emissiveIntensity: number;
  21958. /**
  21959. * Intensity of the environment e.g. how much the environment will light the object
  21960. * either through harmonics for rough material or through the reflection for shiny ones.
  21961. */
  21962. protected _environmentIntensity: number;
  21963. /**
  21964. * This is a special control allowing the reduction of the specular highlights coming from the
  21965. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21966. */
  21967. protected _specularIntensity: number;
  21968. /**
  21969. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21970. */
  21971. private _lightingInfos;
  21972. /**
  21973. * Debug Control allowing disabling the bump map on this material.
  21974. */
  21975. protected _disableBumpMap: boolean;
  21976. /**
  21977. * AKA Diffuse Texture in standard nomenclature.
  21978. */
  21979. protected _albedoTexture: Nullable<BaseTexture>;
  21980. /**
  21981. * AKA Occlusion Texture in other nomenclature.
  21982. */
  21983. protected _ambientTexture: Nullable<BaseTexture>;
  21984. /**
  21985. * AKA Occlusion Texture Intensity in other nomenclature.
  21986. */
  21987. protected _ambientTextureStrength: number;
  21988. /**
  21989. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21990. * 1 means it completely occludes it
  21991. * 0 mean it has no impact
  21992. */
  21993. protected _ambientTextureImpactOnAnalyticalLights: number;
  21994. /**
  21995. * Stores the alpha values in a texture.
  21996. */
  21997. protected _opacityTexture: Nullable<BaseTexture>;
  21998. /**
  21999. * Stores the reflection values in a texture.
  22000. */
  22001. protected _reflectionTexture: Nullable<BaseTexture>;
  22002. /**
  22003. * Stores the emissive values in a texture.
  22004. */
  22005. protected _emissiveTexture: Nullable<BaseTexture>;
  22006. /**
  22007. * AKA Specular texture in other nomenclature.
  22008. */
  22009. protected _reflectivityTexture: Nullable<BaseTexture>;
  22010. /**
  22011. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22012. */
  22013. protected _metallicTexture: Nullable<BaseTexture>;
  22014. /**
  22015. * Specifies the metallic scalar of the metallic/roughness workflow.
  22016. * Can also be used to scale the metalness values of the metallic texture.
  22017. */
  22018. protected _metallic: Nullable<number>;
  22019. /**
  22020. * Specifies the roughness scalar of the metallic/roughness workflow.
  22021. * Can also be used to scale the roughness values of the metallic texture.
  22022. */
  22023. protected _roughness: Nullable<number>;
  22024. /**
  22025. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22026. * By default the indexOfrefraction is used to compute F0;
  22027. *
  22028. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22029. *
  22030. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22031. * F90 = metallicReflectanceColor;
  22032. */
  22033. protected _metallicF0Factor: number;
  22034. /**
  22035. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22036. * By default the F90 is always 1;
  22037. *
  22038. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22039. *
  22040. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22041. * F90 = metallicReflectanceColor;
  22042. */
  22043. protected _metallicReflectanceColor: Color3;
  22044. /**
  22045. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22046. * This is multiply against the scalar values defined in the material.
  22047. */
  22048. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  22049. /**
  22050. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22051. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22052. */
  22053. protected _microSurfaceTexture: Nullable<BaseTexture>;
  22054. /**
  22055. * Stores surface normal data used to displace a mesh in a texture.
  22056. */
  22057. protected _bumpTexture: Nullable<BaseTexture>;
  22058. /**
  22059. * Stores the pre-calculated light information of a mesh in a texture.
  22060. */
  22061. protected _lightmapTexture: Nullable<BaseTexture>;
  22062. /**
  22063. * The color of a material in ambient lighting.
  22064. */
  22065. protected _ambientColor: Color3;
  22066. /**
  22067. * AKA Diffuse Color in other nomenclature.
  22068. */
  22069. protected _albedoColor: Color3;
  22070. /**
  22071. * AKA Specular Color in other nomenclature.
  22072. */
  22073. protected _reflectivityColor: Color3;
  22074. /**
  22075. * The color applied when light is reflected from a material.
  22076. */
  22077. protected _reflectionColor: Color3;
  22078. /**
  22079. * The color applied when light is emitted from a material.
  22080. */
  22081. protected _emissiveColor: Color3;
  22082. /**
  22083. * AKA Glossiness in other nomenclature.
  22084. */
  22085. protected _microSurface: number;
  22086. /**
  22087. * Specifies that the material will use the light map as a show map.
  22088. */
  22089. protected _useLightmapAsShadowmap: boolean;
  22090. /**
  22091. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22092. * makes the reflect vector face the model (under horizon).
  22093. */
  22094. protected _useHorizonOcclusion: boolean;
  22095. /**
  22096. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22097. * too much the area relying on ambient texture to define their ambient occlusion.
  22098. */
  22099. protected _useRadianceOcclusion: boolean;
  22100. /**
  22101. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22102. */
  22103. protected _useAlphaFromAlbedoTexture: boolean;
  22104. /**
  22105. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  22106. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22107. */
  22108. protected _useSpecularOverAlpha: boolean;
  22109. /**
  22110. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22111. */
  22112. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22113. /**
  22114. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22115. */
  22116. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22117. /**
  22118. * Specifies if the metallic texture contains the roughness information in its green channel.
  22119. */
  22120. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22121. /**
  22122. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22123. */
  22124. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22125. /**
  22126. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22127. */
  22128. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22129. /**
  22130. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22131. */
  22132. protected _useAmbientInGrayScale: boolean;
  22133. /**
  22134. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22135. * The material will try to infer what glossiness each pixel should be.
  22136. */
  22137. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22138. /**
  22139. * Defines the falloff type used in this material.
  22140. * It by default is Physical.
  22141. */
  22142. protected _lightFalloff: number;
  22143. /**
  22144. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22145. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22146. */
  22147. protected _useRadianceOverAlpha: boolean;
  22148. /**
  22149. * Allows using an object space normal map (instead of tangent space).
  22150. */
  22151. protected _useObjectSpaceNormalMap: boolean;
  22152. /**
  22153. * Allows using the bump map in parallax mode.
  22154. */
  22155. protected _useParallax: boolean;
  22156. /**
  22157. * Allows using the bump map in parallax occlusion mode.
  22158. */
  22159. protected _useParallaxOcclusion: boolean;
  22160. /**
  22161. * Controls the scale bias of the parallax mode.
  22162. */
  22163. protected _parallaxScaleBias: number;
  22164. /**
  22165. * If sets to true, disables all the lights affecting the material.
  22166. */
  22167. protected _disableLighting: boolean;
  22168. /**
  22169. * Number of Simultaneous lights allowed on the material.
  22170. */
  22171. protected _maxSimultaneousLights: number;
  22172. /**
  22173. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22174. */
  22175. protected _invertNormalMapX: boolean;
  22176. /**
  22177. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22178. */
  22179. protected _invertNormalMapY: boolean;
  22180. /**
  22181. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22182. */
  22183. protected _twoSidedLighting: boolean;
  22184. /**
  22185. * Defines the alpha limits in alpha test mode.
  22186. */
  22187. protected _alphaCutOff: number;
  22188. /**
  22189. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22190. */
  22191. protected _forceAlphaTest: boolean;
  22192. /**
  22193. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22194. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22195. */
  22196. protected _useAlphaFresnel: boolean;
  22197. /**
  22198. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22199. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22200. */
  22201. protected _useLinearAlphaFresnel: boolean;
  22202. /**
  22203. * Specifies the environment BRDF texture used to compute the scale and offset roughness values
  22204. * from cos theta and roughness:
  22205. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22206. */
  22207. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22208. /**
  22209. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22210. */
  22211. protected _forceIrradianceInFragment: boolean;
  22212. private _realTimeFiltering;
  22213. /**
  22214. * Enables realtime filtering on the texture.
  22215. */
  22216. get realTimeFiltering(): boolean;
  22217. set realTimeFiltering(b: boolean);
  22218. private _realTimeFilteringQuality;
  22219. /**
  22220. * Quality switch for realtime filtering
  22221. */
  22222. get realTimeFilteringQuality(): number;
  22223. set realTimeFilteringQuality(n: number);
  22224. /**
  22225. * Can this material render to several textures at once
  22226. */
  22227. get canRenderToMRT(): boolean;
  22228. /**
  22229. * Force normal to face away from face.
  22230. */
  22231. protected _forceNormalForward: boolean;
  22232. /**
  22233. * Enables specular anti aliasing in the PBR shader.
  22234. * It will both interacts on the Geometry for analytical and IBL lighting.
  22235. * It also prefilter the roughness map based on the bump values.
  22236. */
  22237. protected _enableSpecularAntiAliasing: boolean;
  22238. /**
  22239. * Default configuration related to image processing available in the PBR Material.
  22240. */
  22241. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22242. /**
  22243. * Keep track of the image processing observer to allow dispose and replace.
  22244. */
  22245. private _imageProcessingObserver;
  22246. /**
  22247. * Attaches a new image processing configuration to the PBR Material.
  22248. * @param configuration
  22249. */
  22250. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22251. /**
  22252. * Stores the available render targets.
  22253. */
  22254. private _renderTargets;
  22255. /**
  22256. * Sets the global ambient color for the material used in lighting calculations.
  22257. */
  22258. private _globalAmbientColor;
  22259. /**
  22260. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22261. */
  22262. private _useLogarithmicDepth;
  22263. /**
  22264. * If set to true, no lighting calculations will be applied.
  22265. */
  22266. private _unlit;
  22267. private _debugMode;
  22268. /**
  22269. * @hidden
  22270. * This is reserved for the inspector.
  22271. * Defines the material debug mode.
  22272. * It helps seeing only some components of the material while troubleshooting.
  22273. */
  22274. debugMode: number;
  22275. /**
  22276. * @hidden
  22277. * This is reserved for the inspector.
  22278. * Specify from where on screen the debug mode should start.
  22279. * The value goes from -1 (full screen) to 1 (not visible)
  22280. * It helps with side by side comparison against the final render
  22281. * This defaults to -1
  22282. */
  22283. private debugLimit;
  22284. /**
  22285. * @hidden
  22286. * This is reserved for the inspector.
  22287. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22288. * You can use the factor to better multiply the final value.
  22289. */
  22290. private debugFactor;
  22291. /**
  22292. * Defines the clear coat layer parameters for the material.
  22293. */
  22294. readonly clearCoat: PBRClearCoatConfiguration;
  22295. /**
  22296. * Defines the anisotropic parameters for the material.
  22297. */
  22298. readonly anisotropy: PBRAnisotropicConfiguration;
  22299. /**
  22300. * Defines the BRDF parameters for the material.
  22301. */
  22302. readonly brdf: PBRBRDFConfiguration;
  22303. /**
  22304. * Defines the Sheen parameters for the material.
  22305. */
  22306. readonly sheen: PBRSheenConfiguration;
  22307. /**
  22308. * Defines the SubSurface parameters for the material.
  22309. */
  22310. readonly subSurface: PBRSubSurfaceConfiguration;
  22311. /**
  22312. * Defines additional PrePass parameters for the material.
  22313. */
  22314. readonly prePassConfiguration: PrePassConfiguration;
  22315. /**
  22316. * Defines the detail map parameters for the material.
  22317. */
  22318. readonly detailMap: DetailMapConfiguration;
  22319. protected _rebuildInParallel: boolean;
  22320. /**
  22321. * Instantiates a new PBRMaterial instance.
  22322. *
  22323. * @param name The material name
  22324. * @param scene The scene the material will be use in.
  22325. */
  22326. constructor(name: string, scene: Scene);
  22327. /**
  22328. * Gets a boolean indicating that current material needs to register RTT
  22329. */
  22330. get hasRenderTargetTextures(): boolean;
  22331. /**
  22332. * Can this material render to prepass
  22333. */
  22334. get isPrePassCapable(): boolean;
  22335. /**
  22336. * Gets the name of the material class.
  22337. */
  22338. getClassName(): string;
  22339. /**
  22340. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22341. */
  22342. get useLogarithmicDepth(): boolean;
  22343. /**
  22344. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22345. */
  22346. set useLogarithmicDepth(value: boolean);
  22347. /**
  22348. * Returns true if alpha blending should be disabled.
  22349. */
  22350. protected get _disableAlphaBlending(): boolean;
  22351. /**
  22352. * Specifies whether or not this material should be rendered in alpha blend mode.
  22353. */
  22354. needAlphaBlending(): boolean;
  22355. /**
  22356. * Specifies whether or not this material should be rendered in alpha test mode.
  22357. */
  22358. needAlphaTesting(): boolean;
  22359. /**
  22360. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22361. */
  22362. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22363. /**
  22364. * Specifies whether or not there is a usable alpha channel for transparency.
  22365. */
  22366. protected _hasAlphaChannel(): boolean;
  22367. /**
  22368. * Gets the texture used for the alpha test.
  22369. */
  22370. getAlphaTestTexture(): Nullable<BaseTexture>;
  22371. /**
  22372. * Specifies that the submesh is ready to be used.
  22373. * @param mesh - BJS mesh.
  22374. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22375. * @param useInstances - Specifies that instances should be used.
  22376. * @returns - boolean indicating that the submesh is ready or not.
  22377. */
  22378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22379. /**
  22380. * Specifies if the material uses metallic roughness workflow.
  22381. * @returns boolean specifying if the material uses metallic roughness workflow.
  22382. */
  22383. isMetallicWorkflow(): boolean;
  22384. private _prepareEffect;
  22385. private _prepareDefines;
  22386. /**
  22387. * Force shader compilation
  22388. */
  22389. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22390. /**
  22391. * Initializes the uniform buffer layout for the shader.
  22392. */
  22393. buildUniformLayout(): void;
  22394. /**
  22395. * Unbinds the material from the mesh
  22396. */
  22397. unbind(): void;
  22398. /**
  22399. * Binds the submesh data.
  22400. * @param world - The world matrix.
  22401. * @param mesh - The BJS mesh.
  22402. * @param subMesh - A submesh of the BJS mesh.
  22403. */
  22404. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22405. /**
  22406. * Returns the animatable textures.
  22407. * @returns - Array of animatable textures.
  22408. */
  22409. getAnimatables(): IAnimatable[];
  22410. /**
  22411. * Returns the texture used for reflections.
  22412. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22413. */
  22414. private _getReflectionTexture;
  22415. /**
  22416. * Returns an array of the actively used textures.
  22417. * @returns - Array of BaseTextures
  22418. */
  22419. getActiveTextures(): BaseTexture[];
  22420. /**
  22421. * Checks to see if a texture is used in the material.
  22422. * @param texture - Base texture to use.
  22423. * @returns - Boolean specifying if a texture is used in the material.
  22424. */
  22425. hasTexture(texture: BaseTexture): boolean;
  22426. /**
  22427. * Sets the required values to the prepass renderer.
  22428. * @param prePassRenderer defines the prepass renderer to setup
  22429. */
  22430. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22431. /**
  22432. * Disposes the resources of the material.
  22433. * @param forceDisposeEffect - Forces the disposal of effects.
  22434. * @param forceDisposeTextures - Forces the disposal of all textures.
  22435. */
  22436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22437. }
  22438. }
  22439. declare module BABYLON {
  22440. /**
  22441. * The Physically based material of BJS.
  22442. *
  22443. * This offers the main features of a standard PBR material.
  22444. * For more information, please refer to the documentation :
  22445. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22446. */
  22447. export class PBRMaterial extends PBRBaseMaterial {
  22448. /**
  22449. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22450. */
  22451. static readonly PBRMATERIAL_OPAQUE: number;
  22452. /**
  22453. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22454. */
  22455. static readonly PBRMATERIAL_ALPHATEST: number;
  22456. /**
  22457. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22458. */
  22459. static readonly PBRMATERIAL_ALPHABLEND: number;
  22460. /**
  22461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22462. * They are also discarded below the alpha cutoff threshold to improve performances.
  22463. */
  22464. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22465. /**
  22466. * Defines the default value of how much AO map is occluding the analytical lights
  22467. * (point spot...).
  22468. */
  22469. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22470. /**
  22471. * Intensity of the direct lights e.g. the four lights available in your scene.
  22472. * This impacts both the direct diffuse and specular highlights.
  22473. */
  22474. directIntensity: number;
  22475. /**
  22476. * Intensity of the emissive part of the material.
  22477. * This helps controlling the emissive effect without modifying the emissive color.
  22478. */
  22479. emissiveIntensity: number;
  22480. /**
  22481. * Intensity of the environment e.g. how much the environment will light the object
  22482. * either through harmonics for rough material or through the reflection for shiny ones.
  22483. */
  22484. environmentIntensity: number;
  22485. /**
  22486. * This is a special control allowing the reduction of the specular highlights coming from the
  22487. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22488. */
  22489. specularIntensity: number;
  22490. /**
  22491. * Debug Control allowing disabling the bump map on this material.
  22492. */
  22493. disableBumpMap: boolean;
  22494. /**
  22495. * AKA Diffuse Texture in standard nomenclature.
  22496. */
  22497. albedoTexture: BaseTexture;
  22498. /**
  22499. * AKA Occlusion Texture in other nomenclature.
  22500. */
  22501. ambientTexture: BaseTexture;
  22502. /**
  22503. * AKA Occlusion Texture Intensity in other nomenclature.
  22504. */
  22505. ambientTextureStrength: number;
  22506. /**
  22507. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22508. * 1 means it completely occludes it
  22509. * 0 mean it has no impact
  22510. */
  22511. ambientTextureImpactOnAnalyticalLights: number;
  22512. /**
  22513. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22514. */
  22515. opacityTexture: BaseTexture;
  22516. /**
  22517. * Stores the reflection values in a texture.
  22518. */
  22519. reflectionTexture: Nullable<BaseTexture>;
  22520. /**
  22521. * Stores the emissive values in a texture.
  22522. */
  22523. emissiveTexture: BaseTexture;
  22524. /**
  22525. * AKA Specular texture in other nomenclature.
  22526. */
  22527. reflectivityTexture: BaseTexture;
  22528. /**
  22529. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22530. */
  22531. metallicTexture: BaseTexture;
  22532. /**
  22533. * Specifies the metallic scalar of the metallic/roughness workflow.
  22534. * Can also be used to scale the metalness values of the metallic texture.
  22535. */
  22536. metallic: Nullable<number>;
  22537. /**
  22538. * Specifies the roughness scalar of the metallic/roughness workflow.
  22539. * Can also be used to scale the roughness values of the metallic texture.
  22540. */
  22541. roughness: Nullable<number>;
  22542. /**
  22543. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22544. * By default the indexOfrefraction is used to compute F0;
  22545. *
  22546. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22547. *
  22548. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22549. * F90 = metallicReflectanceColor;
  22550. */
  22551. metallicF0Factor: number;
  22552. /**
  22553. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22554. * By default the F90 is always 1;
  22555. *
  22556. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22557. *
  22558. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22559. * F90 = metallicReflectanceColor;
  22560. */
  22561. metallicReflectanceColor: Color3;
  22562. /**
  22563. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22564. * This is multiply against the scalar values defined in the material.
  22565. */
  22566. metallicReflectanceTexture: Nullable<BaseTexture>;
  22567. /**
  22568. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22569. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22570. */
  22571. microSurfaceTexture: BaseTexture;
  22572. /**
  22573. * Stores surface normal data used to displace a mesh in a texture.
  22574. */
  22575. bumpTexture: BaseTexture;
  22576. /**
  22577. * Stores the pre-calculated light information of a mesh in a texture.
  22578. */
  22579. lightmapTexture: BaseTexture;
  22580. /**
  22581. * Stores the refracted light information in a texture.
  22582. */
  22583. get refractionTexture(): Nullable<BaseTexture>;
  22584. set refractionTexture(value: Nullable<BaseTexture>);
  22585. /**
  22586. * The color of a material in ambient lighting.
  22587. */
  22588. ambientColor: Color3;
  22589. /**
  22590. * AKA Diffuse Color in other nomenclature.
  22591. */
  22592. albedoColor: Color3;
  22593. /**
  22594. * AKA Specular Color in other nomenclature.
  22595. */
  22596. reflectivityColor: Color3;
  22597. /**
  22598. * The color reflected from the material.
  22599. */
  22600. reflectionColor: Color3;
  22601. /**
  22602. * The color emitted from the material.
  22603. */
  22604. emissiveColor: Color3;
  22605. /**
  22606. * AKA Glossiness in other nomenclature.
  22607. */
  22608. microSurface: number;
  22609. /**
  22610. * Index of refraction of the material base layer.
  22611. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22612. *
  22613. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22614. *
  22615. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22616. */
  22617. get indexOfRefraction(): number;
  22618. set indexOfRefraction(value: number);
  22619. /**
  22620. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22621. */
  22622. get invertRefractionY(): boolean;
  22623. set invertRefractionY(value: boolean);
  22624. /**
  22625. * This parameters will make the material used its opacity to control how much it is refracting against not.
  22626. * Materials half opaque for instance using refraction could benefit from this control.
  22627. */
  22628. get linkRefractionWithTransparency(): boolean;
  22629. set linkRefractionWithTransparency(value: boolean);
  22630. /**
  22631. * If true, the light map contains occlusion information instead of lighting info.
  22632. */
  22633. useLightmapAsShadowmap: boolean;
  22634. /**
  22635. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22636. */
  22637. useAlphaFromAlbedoTexture: boolean;
  22638. /**
  22639. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22640. */
  22641. forceAlphaTest: boolean;
  22642. /**
  22643. * Defines the alpha limits in alpha test mode.
  22644. */
  22645. alphaCutOff: number;
  22646. /**
  22647. * Specifies that the material will keep the specular highlights over a transparent surface (only the most luminous ones).
  22648. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  22649. */
  22650. useSpecularOverAlpha: boolean;
  22651. /**
  22652. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22653. */
  22654. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22655. /**
  22656. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22657. */
  22658. useRoughnessFromMetallicTextureAlpha: boolean;
  22659. /**
  22660. * Specifies if the metallic texture contains the roughness information in its green channel.
  22661. */
  22662. useRoughnessFromMetallicTextureGreen: boolean;
  22663. /**
  22664. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22665. */
  22666. useMetallnessFromMetallicTextureBlue: boolean;
  22667. /**
  22668. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22669. */
  22670. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22671. /**
  22672. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22673. */
  22674. useAmbientInGrayScale: boolean;
  22675. /**
  22676. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22677. * The material will try to infer what glossiness each pixel should be.
  22678. */
  22679. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22680. /**
  22681. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22682. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22683. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22684. */
  22685. get usePhysicalLightFalloff(): boolean;
  22686. /**
  22687. * BJS is using an hardcoded light falloff based on a manually sets up range.
  22688. * In PBR, one way to represents the falloff is to use the inverse squared root algorithm.
  22689. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22690. */
  22691. set usePhysicalLightFalloff(value: boolean);
  22692. /**
  22693. * In order to support the falloff compatibility with gltf, a special mode has been added
  22694. * to reproduce the gltf light falloff.
  22695. */
  22696. get useGLTFLightFalloff(): boolean;
  22697. /**
  22698. * In order to support the falloff compatibility with gltf, a special mode has been added
  22699. * to reproduce the gltf light falloff.
  22700. */
  22701. set useGLTFLightFalloff(value: boolean);
  22702. /**
  22703. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  22704. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  22705. */
  22706. useRadianceOverAlpha: boolean;
  22707. /**
  22708. * Allows using an object space normal map (instead of tangent space).
  22709. */
  22710. useObjectSpaceNormalMap: boolean;
  22711. /**
  22712. * Allows using the bump map in parallax mode.
  22713. */
  22714. useParallax: boolean;
  22715. /**
  22716. * Allows using the bump map in parallax occlusion mode.
  22717. */
  22718. useParallaxOcclusion: boolean;
  22719. /**
  22720. * Controls the scale bias of the parallax mode.
  22721. */
  22722. parallaxScaleBias: number;
  22723. /**
  22724. * If sets to true, disables all the lights affecting the material.
  22725. */
  22726. disableLighting: boolean;
  22727. /**
  22728. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22729. */
  22730. forceIrradianceInFragment: boolean;
  22731. /**
  22732. * Number of Simultaneous lights allowed on the material.
  22733. */
  22734. maxSimultaneousLights: number;
  22735. /**
  22736. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22737. */
  22738. invertNormalMapX: boolean;
  22739. /**
  22740. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22741. */
  22742. invertNormalMapY: boolean;
  22743. /**
  22744. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22745. */
  22746. twoSidedLighting: boolean;
  22747. /**
  22748. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22749. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22750. */
  22751. useAlphaFresnel: boolean;
  22752. /**
  22753. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22754. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22755. */
  22756. useLinearAlphaFresnel: boolean;
  22757. /**
  22758. * Let user defines the brdf lookup texture used for IBL.
  22759. * A default 8bit version is embedded but you could point at :
  22760. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22761. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22762. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22763. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22764. */
  22765. environmentBRDFTexture: Nullable<BaseTexture>;
  22766. /**
  22767. * Force normal to face away from face.
  22768. */
  22769. forceNormalForward: boolean;
  22770. /**
  22771. * Enables specular anti aliasing in the PBR shader.
  22772. * It will both interacts on the Geometry for analytical and IBL lighting.
  22773. * It also prefilter the roughness map based on the bump values.
  22774. */
  22775. enableSpecularAntiAliasing: boolean;
  22776. /**
  22777. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22778. * makes the reflect vector face the model (under horizon).
  22779. */
  22780. useHorizonOcclusion: boolean;
  22781. /**
  22782. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22783. * too much the area relying on ambient texture to define their ambient occlusion.
  22784. */
  22785. useRadianceOcclusion: boolean;
  22786. /**
  22787. * If set to true, no lighting calculations will be applied.
  22788. */
  22789. unlit: boolean;
  22790. /**
  22791. * Gets the image processing configuration used either in this material.
  22792. */
  22793. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22794. /**
  22795. * Sets the Default image processing configuration used either in the this material.
  22796. *
  22797. * If sets to null, the scene one is in use.
  22798. */
  22799. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22800. /**
  22801. * Gets whether the color curves effect is enabled.
  22802. */
  22803. get cameraColorCurvesEnabled(): boolean;
  22804. /**
  22805. * Sets whether the color curves effect is enabled.
  22806. */
  22807. set cameraColorCurvesEnabled(value: boolean);
  22808. /**
  22809. * Gets whether the color grading effect is enabled.
  22810. */
  22811. get cameraColorGradingEnabled(): boolean;
  22812. /**
  22813. * Gets whether the color grading effect is enabled.
  22814. */
  22815. set cameraColorGradingEnabled(value: boolean);
  22816. /**
  22817. * Gets whether tonemapping is enabled or not.
  22818. */
  22819. get cameraToneMappingEnabled(): boolean;
  22820. /**
  22821. * Sets whether tonemapping is enabled or not
  22822. */
  22823. set cameraToneMappingEnabled(value: boolean);
  22824. /**
  22825. * The camera exposure used on this material.
  22826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22827. * This corresponds to a photographic exposure.
  22828. */
  22829. get cameraExposure(): number;
  22830. /**
  22831. * The camera exposure used on this material.
  22832. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22833. * This corresponds to a photographic exposure.
  22834. */
  22835. set cameraExposure(value: number);
  22836. /**
  22837. * Gets The camera contrast used on this material.
  22838. */
  22839. get cameraContrast(): number;
  22840. /**
  22841. * Sets The camera contrast used on this material.
  22842. */
  22843. set cameraContrast(value: number);
  22844. /**
  22845. * Gets the Color Grading 2D Lookup Texture.
  22846. */
  22847. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22848. /**
  22849. * Sets the Color Grading 2D Lookup Texture.
  22850. */
  22851. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22852. /**
  22853. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22854. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22855. * 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;
  22856. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22857. */
  22858. get cameraColorCurves(): Nullable<ColorCurves>;
  22859. /**
  22860. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  22861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22862. * 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;
  22863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22864. */
  22865. set cameraColorCurves(value: Nullable<ColorCurves>);
  22866. /**
  22867. * Instantiates a new PBRMaterial instance.
  22868. *
  22869. * @param name The material name
  22870. * @param scene The scene the material will be use in.
  22871. */
  22872. constructor(name: string, scene: Scene);
  22873. /**
  22874. * Returns the name of this material class.
  22875. */
  22876. getClassName(): string;
  22877. /**
  22878. * Makes a duplicate of the current material.
  22879. * @param name - name to use for the new material.
  22880. */
  22881. clone(name: string): PBRMaterial;
  22882. /**
  22883. * Serializes this PBR Material.
  22884. * @returns - An object with the serialized material.
  22885. */
  22886. serialize(): any;
  22887. /**
  22888. * Parses a PBR Material from a serialized object.
  22889. * @param source - Serialized object.
  22890. * @param scene - BJS scene instance.
  22891. * @param rootUrl - url for the scene object
  22892. * @returns - PBRMaterial
  22893. */
  22894. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /** @hidden */
  22899. export var mrtFragmentDeclaration: {
  22900. name: string;
  22901. shader: string;
  22902. };
  22903. }
  22904. declare module BABYLON {
  22905. /** @hidden */
  22906. export var geometryPixelShader: {
  22907. name: string;
  22908. shader: string;
  22909. };
  22910. }
  22911. declare module BABYLON {
  22912. /** @hidden */
  22913. export var instancesDeclaration: {
  22914. name: string;
  22915. shader: string;
  22916. };
  22917. }
  22918. declare module BABYLON {
  22919. /** @hidden */
  22920. export var geometryVertexDeclaration: {
  22921. name: string;
  22922. shader: string;
  22923. };
  22924. }
  22925. declare module BABYLON {
  22926. /** @hidden */
  22927. export var geometryUboDeclaration: {
  22928. name: string;
  22929. shader: string;
  22930. };
  22931. }
  22932. declare module BABYLON {
  22933. /** @hidden */
  22934. export var geometryVertexShader: {
  22935. name: string;
  22936. shader: string;
  22937. };
  22938. }
  22939. declare module BABYLON {
  22940. /** @hidden */
  22941. interface ISavedTransformationMatrix {
  22942. world: Matrix;
  22943. viewProjection: Matrix;
  22944. }
  22945. /**
  22946. * This renderer is helpful to fill one of the render target with a geometry buffer.
  22947. */
  22948. export class GeometryBufferRenderer {
  22949. /**
  22950. * Constant used to retrieve the depth texture index in the G-Buffer textures array
  22951. * using getIndex(GeometryBufferRenderer.DEPTH_TEXTURE_INDEX)
  22952. */
  22953. static readonly DEPTH_TEXTURE_TYPE: number;
  22954. /**
  22955. * Constant used to retrieve the normal texture index in the G-Buffer textures array
  22956. * using getIndex(GeometryBufferRenderer.NORMAL_TEXTURE_INDEX)
  22957. */
  22958. static readonly NORMAL_TEXTURE_TYPE: number;
  22959. /**
  22960. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22961. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22962. */
  22963. static readonly POSITION_TEXTURE_TYPE: number;
  22964. /**
  22965. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22966. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22967. */
  22968. static readonly VELOCITY_TEXTURE_TYPE: number;
  22969. /**
  22970. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22971. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22972. */
  22973. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22974. /**
  22975. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22976. * in order to compute objects velocities when enableVelocity is set to "true"
  22977. * @hidden
  22978. */
  22979. _previousTransformationMatrices: {
  22980. [index: number]: ISavedTransformationMatrix;
  22981. };
  22982. /**
  22983. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22984. * in order to compute objects velocities when enableVelocity is set to "true"
  22985. * @hidden
  22986. */
  22987. _previousBonesTransformationMatrices: {
  22988. [index: number]: Float32Array;
  22989. };
  22990. /**
  22991. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22992. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22993. */
  22994. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22995. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22996. renderTransparentMeshes: boolean;
  22997. private _scene;
  22998. private _resizeObserver;
  22999. private _multiRenderTarget;
  23000. private _ratio;
  23001. private _enablePosition;
  23002. private _enableVelocity;
  23003. private _enableReflectivity;
  23004. private _positionIndex;
  23005. private _velocityIndex;
  23006. private _reflectivityIndex;
  23007. private _depthIndex;
  23008. private _normalIndex;
  23009. private _linkedWithPrePass;
  23010. private _prePassRenderer;
  23011. private _attachments;
  23012. private _useUbo;
  23013. protected _effect: Effect;
  23014. protected _cachedDefines: string;
  23015. /**
  23016. * @hidden
  23017. * Sets up internal structures to share outputs with PrePassRenderer
  23018. * This method should only be called by the PrePassRenderer itself
  23019. */
  23020. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  23021. /**
  23022. * @hidden
  23023. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  23024. * This method should only be called by the PrePassRenderer itself
  23025. */
  23026. _unlinkPrePassRenderer(): void;
  23027. /**
  23028. * @hidden
  23029. * Resets the geometry buffer layout
  23030. */
  23031. _resetLayout(): void;
  23032. /**
  23033. * @hidden
  23034. * Replaces a texture in the geometry buffer renderer
  23035. * Useful when linking textures of the prepass renderer
  23036. */
  23037. _forceTextureType(geometryBufferType: number, index: number): void;
  23038. /**
  23039. * @hidden
  23040. * Sets texture attachments
  23041. * Useful when linking textures of the prepass renderer
  23042. */
  23043. _setAttachments(attachments: number[]): void;
  23044. /**
  23045. * @hidden
  23046. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  23047. * Useful when linking textures of the prepass renderer
  23048. */
  23049. _linkInternalTexture(internalTexture: InternalTexture): void;
  23050. /**
  23051. * Gets the render list (meshes to be rendered) used in the G buffer.
  23052. */
  23053. get renderList(): Nullable<AbstractMesh[]>;
  23054. /**
  23055. * Set the render list (meshes to be rendered) used in the G buffer.
  23056. */
  23057. set renderList(meshes: Nullable<AbstractMesh[]>);
  23058. /**
  23059. * Gets whether or not G buffer are supported by the running hardware.
  23060. * This requires draw buffer supports
  23061. */
  23062. get isSupported(): boolean;
  23063. /**
  23064. * Returns the index of the given texture type in the G-Buffer textures array
  23065. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  23066. * @returns the index of the given texture type in the G-Buffer textures array
  23067. */
  23068. getTextureIndex(textureType: number): number;
  23069. /**
  23070. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  23071. */
  23072. get enablePosition(): boolean;
  23073. /**
  23074. * Sets whether or not objects positions are enabled for the G buffer.
  23075. */
  23076. set enablePosition(enable: boolean);
  23077. /**
  23078. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  23079. */
  23080. get enableVelocity(): boolean;
  23081. /**
  23082. * Sets whether or not objects velocities are enabled for the G buffer.
  23083. */
  23084. set enableVelocity(enable: boolean);
  23085. /**
  23086. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  23087. */
  23088. get enableReflectivity(): boolean;
  23089. /**
  23090. * Sets whether or not objects roughness are enabled for the G buffer.
  23091. */
  23092. set enableReflectivity(enable: boolean);
  23093. /**
  23094. * Gets the scene associated with the buffer.
  23095. */
  23096. get scene(): Scene;
  23097. /**
  23098. * Gets the ratio used by the buffer during its creation.
  23099. * How big is the buffer related to the main canvas.
  23100. */
  23101. get ratio(): number;
  23102. /** @hidden */
  23103. static _SceneComponentInitialization: (scene: Scene) => void;
  23104. /**
  23105. * Creates a new G Buffer for the scene
  23106. * @param scene The scene the buffer belongs to
  23107. * @param ratio How big is the buffer related to the main canvas.
  23108. */
  23109. constructor(scene: Scene, ratio?: number);
  23110. /**
  23111. * Checks whether everything is ready to render a submesh to the G buffer.
  23112. * @param subMesh the submesh to check readiness for
  23113. * @param useInstances is the mesh drawn using instance or not
  23114. * @returns true if ready otherwise false
  23115. */
  23116. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23117. /**
  23118. * Gets the current underlying G Buffer.
  23119. * @returns the buffer
  23120. */
  23121. getGBuffer(): MultiRenderTarget;
  23122. /**
  23123. * Gets the number of samples used to render the buffer (anti aliasing).
  23124. */
  23125. get samples(): number;
  23126. /**
  23127. * Sets the number of samples used to render the buffer (anti aliasing).
  23128. */
  23129. set samples(value: number);
  23130. /**
  23131. * Disposes the renderer and frees up associated resources.
  23132. */
  23133. dispose(): void;
  23134. private _assignRenderTargetIndices;
  23135. protected _createRenderTargets(): void;
  23136. private _copyBonesTransformationMatrices;
  23137. }
  23138. }
  23139. declare module BABYLON {
  23140. /**
  23141. * Renders a pre pass of the scene
  23142. * This means every mesh in the scene will be rendered to a render target texture
  23143. * And then this texture will be composited to the rendering canvas with post processes
  23144. * It is necessary for effects like subsurface scattering or deferred shading
  23145. */
  23146. export class PrePassRenderer {
  23147. /** @hidden */
  23148. static _SceneComponentInitialization: (scene: Scene) => void;
  23149. /**
  23150. * To save performance, we can excluded skinned meshes from the prepass
  23151. */
  23152. excludedSkinnedMesh: AbstractMesh[];
  23153. /**
  23154. * Force material to be excluded from the prepass
  23155. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23156. * and you don't want a material to show in the effect.
  23157. */
  23158. excludedMaterials: Material[];
  23159. private _scene;
  23160. private _engine;
  23161. /**
  23162. * Number of textures in the multi render target texture where the scene is directly rendered
  23163. */
  23164. mrtCount: number;
  23165. private _mrtFormats;
  23166. private _mrtLayout;
  23167. private _textureIndices;
  23168. private _multiRenderAttachments;
  23169. private _defaultAttachments;
  23170. private _clearAttachments;
  23171. /**
  23172. * Returns the index of a texture in the multi render target texture array.
  23173. * @param type Texture type
  23174. * @return The index
  23175. */
  23176. getIndex(type: number): number;
  23177. /**
  23178. * How many samples are used for MSAA of the scene render target
  23179. */
  23180. get samples(): number;
  23181. set samples(n: number);
  23182. private static _textureFormats;
  23183. private _isDirty;
  23184. /**
  23185. * The render target where the scene is directly rendered
  23186. */
  23187. defaultRT: PrePassRenderTarget;
  23188. /**
  23189. * Configuration for prepass effects
  23190. */
  23191. private _effectConfigurations;
  23192. /**
  23193. * @return the prepass render target for the rendering pass.
  23194. * If we are currently rendering a render target, it returns the PrePassRenderTarget
  23195. * associated with that render target. Otherwise, it returns the scene default PrePassRenderTarget
  23196. */
  23197. getRenderTarget(): PrePassRenderTarget;
  23198. /**
  23199. * @hidden
  23200. * Managed by the scene component
  23201. * @param prePassRenderTarget
  23202. */
  23203. _setRenderTarget(prePassRenderTarget: Nullable<PrePassRenderTarget>): void;
  23204. /**
  23205. * Returns true if the currently rendered prePassRenderTarget is the one
  23206. * associated with the scene.
  23207. */
  23208. get currentRTisSceneRT(): boolean;
  23209. private _geometryBuffer;
  23210. /**
  23211. * Prevents the PrePassRenderer from using the GeometryBufferRenderer as a fallback
  23212. */
  23213. doNotUseGeometryRendererFallback: boolean;
  23214. private _refreshGeometryBufferRendererLink;
  23215. private _currentTarget;
  23216. /**
  23217. * All the render targets generated by prepass
  23218. */
  23219. renderTargets: PrePassRenderTarget[];
  23220. private readonly _clearColor;
  23221. private _enabled;
  23222. private _needsCompositionForThisPass;
  23223. private _postProcessesSourceForThisPass;
  23224. /**
  23225. * Indicates if the prepass is enabled
  23226. */
  23227. get enabled(): boolean;
  23228. /**
  23229. * Set to true to disable gamma transform in PrePass.
  23230. * Can be useful in case you already proceed to gamma transform on a material level
  23231. * and your post processes don't need to be in linear color space.
  23232. */
  23233. disableGammaTransform: boolean;
  23234. /**
  23235. * Instanciates a prepass renderer
  23236. * @param scene The scene
  23237. */
  23238. constructor(scene: Scene);
  23239. /**
  23240. * Creates a new PrePassRenderTarget
  23241. * This should be the only way to instanciate a `PrePassRenderTarget`
  23242. * @param name Name of the `PrePassRenderTarget`
  23243. * @param renderTargetTexture RenderTarget the `PrePassRenderTarget` will be attached to.
  23244. * Can be `null` if the created `PrePassRenderTarget` is attached to the scene (default framebuffer).
  23245. * @hidden
  23246. */
  23247. _createRenderTarget(name: string, renderTargetTexture: Nullable<RenderTargetTexture>): PrePassRenderTarget;
  23248. /**
  23249. * Indicates if rendering a prepass is supported
  23250. */
  23251. get isSupported(): boolean;
  23252. /**
  23253. * Sets the proper output textures to draw in the engine.
  23254. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23255. * @param subMesh Submesh on which the effect is applied
  23256. */
  23257. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23258. private _reinitializeAttachments;
  23259. private _resetLayout;
  23260. private _updateGeometryBufferLayout;
  23261. /**
  23262. * Restores attachments for single texture draw.
  23263. */
  23264. restoreAttachments(): void;
  23265. /**
  23266. * @hidden
  23267. */
  23268. _beforeDraw(camera?: Camera, faceIndex?: number, layer?: number): void;
  23269. private _prepareFrame;
  23270. private _renderPostProcesses;
  23271. /**
  23272. * @hidden
  23273. */
  23274. _afterDraw(faceIndex?: number, layer?: number): void;
  23275. /**
  23276. * Clears the current prepass render target (in the sense of settings pixels to the scene clear color value)
  23277. * @hidden
  23278. */
  23279. _clear(): void;
  23280. private _bindFrameBuffer;
  23281. private _setEnabled;
  23282. private _setRenderTargetEnabled;
  23283. /**
  23284. * Adds an effect configuration to the prepass render target.
  23285. * If an effect has already been added, it won't add it twice and will return the configuration
  23286. * already present.
  23287. * @param cfg the effect configuration
  23288. * @return the effect configuration now used by the prepass
  23289. */
  23290. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23291. private _enable;
  23292. private _disable;
  23293. private _getPostProcessesSource;
  23294. private _setupOutputForThisPass;
  23295. private _linkInternalTexture;
  23296. private _needsImageProcessing;
  23297. private _hasImageProcessing;
  23298. /**
  23299. * Internal, gets the first post proces.
  23300. * @returns the first post process to be run on this camera.
  23301. */
  23302. private _getFirstPostProcess;
  23303. /**
  23304. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23305. */
  23306. markAsDirty(): void;
  23307. /**
  23308. * Enables a texture on the MultiRenderTarget for prepass
  23309. */
  23310. private _enableTextures;
  23311. private _update;
  23312. private _markAllMaterialsAsPrePassDirty;
  23313. /**
  23314. * Disposes the prepass renderer.
  23315. */
  23316. dispose(): void;
  23317. }
  23318. }
  23319. declare module BABYLON {
  23320. /**
  23321. * Size options for a post process
  23322. */
  23323. export type PostProcessOptions = {
  23324. width: number;
  23325. height: number;
  23326. };
  23327. /**
  23328. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23329. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23330. */
  23331. export class PostProcess {
  23332. /**
  23333. * Gets or sets the unique id of the post process
  23334. */
  23335. uniqueId: number;
  23336. /** Name of the PostProcess. */
  23337. name: string;
  23338. /**
  23339. * Width of the texture to apply the post process on
  23340. */
  23341. width: number;
  23342. /**
  23343. * Height of the texture to apply the post process on
  23344. */
  23345. height: number;
  23346. /**
  23347. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23348. */
  23349. nodeMaterialSource: Nullable<NodeMaterial>;
  23350. /**
  23351. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23352. * @hidden
  23353. */
  23354. _outputTexture: Nullable<InternalTexture>;
  23355. /**
  23356. * Sampling mode used by the shader
  23357. * See https://doc.babylonjs.com/classes/3.1/texture
  23358. */
  23359. renderTargetSamplingMode: number;
  23360. /**
  23361. * Clear color to use when screen clearing
  23362. */
  23363. clearColor: Color4;
  23364. /**
  23365. * If the buffer needs to be cleared before applying the post process. (default: true)
  23366. * Should be set to false if shader will overwrite all previous pixels.
  23367. */
  23368. autoClear: boolean;
  23369. /**
  23370. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23371. */
  23372. alphaMode: number;
  23373. /**
  23374. * Sets the setAlphaBlendConstants of the babylon engine
  23375. */
  23376. alphaConstants: Color4;
  23377. /**
  23378. * Animations to be used for the post processing
  23379. */
  23380. animations: Animation[];
  23381. /**
  23382. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23383. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23384. */
  23385. enablePixelPerfectMode: boolean;
  23386. /**
  23387. * Force the postprocess to be applied without taking in account viewport
  23388. */
  23389. forceFullscreenViewport: boolean;
  23390. /**
  23391. * List of inspectable custom properties (used by the Inspector)
  23392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23393. */
  23394. inspectableCustomProperties: IInspectable[];
  23395. /**
  23396. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23397. *
  23398. * | Value | Type | Description |
  23399. * | ----- | ----------------------------------- | ----------- |
  23400. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23401. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23402. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23403. *
  23404. */
  23405. scaleMode: number;
  23406. /**
  23407. * Force textures to be a power of two (default: false)
  23408. */
  23409. alwaysForcePOT: boolean;
  23410. private _samples;
  23411. /**
  23412. * Number of sample textures (default: 1)
  23413. */
  23414. get samples(): number;
  23415. set samples(n: number);
  23416. /**
  23417. * Modify the scale of the post process to be the same as the viewport (default: false)
  23418. */
  23419. adaptScaleToCurrentViewport: boolean;
  23420. private _camera;
  23421. protected _scene: Scene;
  23422. private _engine;
  23423. private _options;
  23424. private _reusable;
  23425. private _renderId;
  23426. private _textureType;
  23427. private _textureFormat;
  23428. /**
  23429. * Smart array of input and output textures for the post process.
  23430. * @hidden
  23431. */
  23432. _textures: SmartArray<InternalTexture>;
  23433. /**
  23434. * Smart array of input and output textures for the post process.
  23435. * @hidden
  23436. */
  23437. private _textureCache;
  23438. /**
  23439. * The index in _textures that corresponds to the output texture.
  23440. * @hidden
  23441. */
  23442. _currentRenderTextureInd: number;
  23443. private _effect;
  23444. private _samplers;
  23445. private _fragmentUrl;
  23446. private _vertexUrl;
  23447. private _parameters;
  23448. protected _postProcessDefines: Nullable<string>;
  23449. private _scaleRatio;
  23450. protected _indexParameters: any;
  23451. private _shareOutputWithPostProcess;
  23452. private _texelSize;
  23453. /** @hidden */
  23454. _forcedOutputTexture: Nullable<InternalTexture>;
  23455. /**
  23456. * Prepass configuration in case this post process needs a texture from prepass
  23457. * @hidden
  23458. */
  23459. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23460. /**
  23461. * Returns the fragment url or shader name used in the post process.
  23462. * @returns the fragment url or name in the shader store.
  23463. */
  23464. getEffectName(): string;
  23465. /**
  23466. * An event triggered when the postprocess is activated.
  23467. */
  23468. onActivateObservable: Observable<Camera>;
  23469. private _onActivateObserver;
  23470. /**
  23471. * A function that is added to the onActivateObservable
  23472. */
  23473. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23474. /**
  23475. * An event triggered when the postprocess changes its size.
  23476. */
  23477. onSizeChangedObservable: Observable<PostProcess>;
  23478. private _onSizeChangedObserver;
  23479. /**
  23480. * A function that is added to the onSizeChangedObservable
  23481. */
  23482. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23483. /**
  23484. * An event triggered when the postprocess applies its effect.
  23485. */
  23486. onApplyObservable: Observable<Effect>;
  23487. private _onApplyObserver;
  23488. /**
  23489. * A function that is added to the onApplyObservable
  23490. */
  23491. set onApply(callback: (effect: Effect) => void);
  23492. /**
  23493. * An event triggered before rendering the postprocess
  23494. */
  23495. onBeforeRenderObservable: Observable<Effect>;
  23496. private _onBeforeRenderObserver;
  23497. /**
  23498. * A function that is added to the onBeforeRenderObservable
  23499. */
  23500. set onBeforeRender(callback: (effect: Effect) => void);
  23501. /**
  23502. * An event triggered after rendering the postprocess
  23503. */
  23504. onAfterRenderObservable: Observable<Effect>;
  23505. private _onAfterRenderObserver;
  23506. /**
  23507. * A function that is added to the onAfterRenderObservable
  23508. */
  23509. set onAfterRender(callback: (efect: Effect) => void);
  23510. /**
  23511. * 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
  23512. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23513. */
  23514. get inputTexture(): InternalTexture;
  23515. set inputTexture(value: InternalTexture);
  23516. /**
  23517. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23518. * the only way to unset it is to use this function to restore its internal state
  23519. */
  23520. restoreDefaultInputTexture(): void;
  23521. /**
  23522. * Gets the camera which post process is applied to.
  23523. * @returns The camera the post process is applied to.
  23524. */
  23525. getCamera(): Camera;
  23526. /**
  23527. * Gets the texel size of the postprocess.
  23528. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23529. */
  23530. get texelSize(): Vector2;
  23531. /**
  23532. * Creates a new instance PostProcess
  23533. * @param name The name of the PostProcess.
  23534. * @param fragmentUrl The url of the fragment shader to be used.
  23535. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23536. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23537. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23538. * @param camera The camera to apply the render pass to.
  23539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23540. * @param engine The engine which the post process will be applied. (default: current engine)
  23541. * @param reusable If the post process can be reused on the same frame. (default: false)
  23542. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23543. * @param textureType Type of textures used when performing the post process. (default: 0)
  23544. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23545. * @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
  23546. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23547. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23548. */
  23549. 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);
  23550. /**
  23551. * Gets a string identifying the name of the class
  23552. * @returns "PostProcess" string
  23553. */
  23554. getClassName(): string;
  23555. /**
  23556. * Gets the engine which this post process belongs to.
  23557. * @returns The engine the post process was enabled with.
  23558. */
  23559. getEngine(): Engine;
  23560. /**
  23561. * The effect that is created when initializing the post process.
  23562. * @returns The created effect corresponding the the postprocess.
  23563. */
  23564. getEffect(): Effect;
  23565. /**
  23566. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23567. * @param postProcess The post process to share the output with.
  23568. * @returns This post process.
  23569. */
  23570. shareOutputWith(postProcess: PostProcess): PostProcess;
  23571. /**
  23572. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23573. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23574. */
  23575. useOwnOutput(): void;
  23576. /**
  23577. * Updates the effect with the current post process compile time values and recompiles the shader.
  23578. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23579. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23580. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23581. * @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
  23582. * @param onCompiled Called when the shader has been compiled.
  23583. * @param onError Called if there is an error when compiling a shader.
  23584. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23585. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23586. */
  23587. 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;
  23588. /**
  23589. * The post process is reusable if it can be used multiple times within one frame.
  23590. * @returns If the post process is reusable
  23591. */
  23592. isReusable(): boolean;
  23593. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23594. markTextureDirty(): void;
  23595. private _createRenderTargetTexture;
  23596. private _flushTextureCache;
  23597. private _resize;
  23598. /**
  23599. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23600. * 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.
  23601. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23602. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23603. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23604. * @returns The target texture that was bound to be written to.
  23605. */
  23606. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23607. /**
  23608. * If the post process is supported.
  23609. */
  23610. get isSupported(): boolean;
  23611. /**
  23612. * The aspect ratio of the output texture.
  23613. */
  23614. get aspectRatio(): number;
  23615. /**
  23616. * Get a value indicating if the post-process is ready to be used
  23617. * @returns true if the post-process is ready (shader is compiled)
  23618. */
  23619. isReady(): boolean;
  23620. /**
  23621. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23622. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23623. */
  23624. apply(): Nullable<Effect>;
  23625. private _disposeTextures;
  23626. private _disposeTextureCache;
  23627. /**
  23628. * Sets the required values to the prepass renderer.
  23629. * @param prePassRenderer defines the prepass renderer to setup.
  23630. * @returns true if the pre pass is needed.
  23631. */
  23632. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23633. /**
  23634. * Disposes the post process.
  23635. * @param camera The camera to dispose the post process on.
  23636. */
  23637. dispose(camera?: Camera): void;
  23638. /**
  23639. * Serializes the particle system to a JSON object
  23640. * @returns the JSON object
  23641. */
  23642. serialize(): any;
  23643. /**
  23644. * Clones this post process
  23645. * @returns a new post process similar to this one
  23646. */
  23647. clone(): Nullable<PostProcess>;
  23648. /**
  23649. * Creates a material from parsed material data
  23650. * @param parsedPostProcess defines parsed post process data
  23651. * @param scene defines the hosting scene
  23652. * @param rootUrl defines the root URL to use to load textures
  23653. * @returns a new post process
  23654. */
  23655. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23656. /** @hidden */
  23657. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23658. }
  23659. }
  23660. declare module BABYLON {
  23661. /** @hidden */
  23662. export var kernelBlurVaryingDeclaration: {
  23663. name: string;
  23664. shader: string;
  23665. };
  23666. }
  23667. declare module BABYLON {
  23668. /** @hidden */
  23669. export var packingFunctions: {
  23670. name: string;
  23671. shader: string;
  23672. };
  23673. }
  23674. declare module BABYLON {
  23675. /** @hidden */
  23676. export var kernelBlurFragment: {
  23677. name: string;
  23678. shader: string;
  23679. };
  23680. }
  23681. declare module BABYLON {
  23682. /** @hidden */
  23683. export var kernelBlurFragment2: {
  23684. name: string;
  23685. shader: string;
  23686. };
  23687. }
  23688. declare module BABYLON {
  23689. /** @hidden */
  23690. export var kernelBlurPixelShader: {
  23691. name: string;
  23692. shader: string;
  23693. };
  23694. }
  23695. declare module BABYLON {
  23696. /** @hidden */
  23697. export var kernelBlurVertex: {
  23698. name: string;
  23699. shader: string;
  23700. };
  23701. }
  23702. declare module BABYLON {
  23703. /** @hidden */
  23704. export var kernelBlurVertexShader: {
  23705. name: string;
  23706. shader: string;
  23707. };
  23708. }
  23709. declare module BABYLON {
  23710. /**
  23711. * The Blur Post Process which blurs an image based on a kernel and direction.
  23712. * Can be used twice in x and y directions to perform a gaussian blur in two passes.
  23713. */
  23714. export class BlurPostProcess extends PostProcess {
  23715. private blockCompilation;
  23716. protected _kernel: number;
  23717. protected _idealKernel: number;
  23718. protected _packedFloat: boolean;
  23719. private _staticDefines;
  23720. /** The direction in which to blur the image. */
  23721. direction: Vector2;
  23722. /**
  23723. * Sets the length in pixels of the blur sample region
  23724. */
  23725. set kernel(v: number);
  23726. /**
  23727. * Gets the length in pixels of the blur sample region
  23728. */
  23729. get kernel(): number;
  23730. /**
  23731. * Sets whether or not the blur needs to unpack/repack floats
  23732. */
  23733. set packedFloat(v: boolean);
  23734. /**
  23735. * Gets whether or not the blur is unpacking/repacking floats
  23736. */
  23737. get packedFloat(): boolean;
  23738. /**
  23739. * Gets a string identifying the name of the class
  23740. * @returns "BlurPostProcess" string
  23741. */
  23742. getClassName(): string;
  23743. /**
  23744. * Creates a new instance BlurPostProcess
  23745. * @param name The name of the effect.
  23746. * @param direction The direction in which to blur the image.
  23747. * @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.
  23748. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23749. * @param camera The camera to apply the render pass to.
  23750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23751. * @param engine The engine which the post process will be applied. (default: current engine)
  23752. * @param reusable If the post process can be reused on the same frame. (default: false)
  23753. * @param textureType Type of textures used when performing the post process. (default: 0)
  23754. * @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)
  23755. */
  23756. 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);
  23757. /**
  23758. * Updates the effect with the current post process compile time values and recompiles the shader.
  23759. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23760. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23761. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23762. * @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
  23763. * @param onCompiled Called when the shader has been compiled.
  23764. * @param onError Called if there is an error when compiling a shader.
  23765. */
  23766. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23767. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23768. /**
  23769. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23770. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23771. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23772. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23773. * The gaps between physical kernels are compensated for in the weighting of the samples
  23774. * @param idealKernel Ideal blur kernel.
  23775. * @return Nearest best kernel.
  23776. */
  23777. protected _nearestBestKernel(idealKernel: number): number;
  23778. /**
  23779. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23780. * @param x The point on the Gaussian distribution to sample.
  23781. * @return the value of the Gaussian function at x.
  23782. */
  23783. protected _gaussianWeight(x: number): number;
  23784. /**
  23785. * Generates a string that can be used as a floating point number in GLSL.
  23786. * @param x Value to print.
  23787. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23788. * @return GLSL float string.
  23789. */
  23790. protected _glslFloat(x: number, decimalFigures?: number): string;
  23791. /** @hidden */
  23792. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23793. }
  23794. }
  23795. declare module BABYLON {
  23796. /**
  23797. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23798. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23799. * You can then easily use it as a reflectionTexture on a flat surface.
  23800. * In case the surface is not a plane, please consider relying on reflection probes.
  23801. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23802. */
  23803. export class MirrorTexture extends RenderTargetTexture {
  23804. private scene;
  23805. /**
  23806. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23807. * 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.
  23808. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23809. */
  23810. mirrorPlane: Plane;
  23811. /**
  23812. * Define the blur ratio used to blur the reflection if needed.
  23813. */
  23814. set blurRatio(value: number);
  23815. get blurRatio(): number;
  23816. /**
  23817. * Define the adaptive blur kernel used to blur the reflection if needed.
  23818. * This will autocompute the closest best match for the `blurKernel`
  23819. */
  23820. set adaptiveBlurKernel(value: number);
  23821. /**
  23822. * Define the blur kernel used to blur the reflection if needed.
  23823. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23824. */
  23825. set blurKernel(value: number);
  23826. /**
  23827. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23828. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23829. */
  23830. set blurKernelX(value: number);
  23831. get blurKernelX(): number;
  23832. /**
  23833. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23834. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23835. */
  23836. set blurKernelY(value: number);
  23837. get blurKernelY(): number;
  23838. private _autoComputeBlurKernel;
  23839. protected _onRatioRescale(): void;
  23840. private _updateGammaSpace;
  23841. private _imageProcessingConfigChangeObserver;
  23842. private _transformMatrix;
  23843. private _mirrorMatrix;
  23844. private _blurX;
  23845. private _blurY;
  23846. private _adaptiveBlurKernel;
  23847. private _blurKernelX;
  23848. private _blurKernelY;
  23849. private _blurRatio;
  23850. /**
  23851. * Instantiates a Mirror Texture.
  23852. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23853. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23854. * You can then easily use it as a reflectionTexture on a flat surface.
  23855. * In case the surface is not a plane, please consider relying on reflection probes.
  23856. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23857. * @param name
  23858. * @param size
  23859. * @param scene
  23860. * @param generateMipMaps
  23861. * @param type
  23862. * @param samplingMode
  23863. * @param generateDepthBuffer
  23864. */
  23865. constructor(name: string, size: number | {
  23866. width: number;
  23867. height: number;
  23868. } | {
  23869. ratio: number;
  23870. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23871. private _preparePostProcesses;
  23872. /**
  23873. * Clone the mirror texture.
  23874. * @returns the cloned texture
  23875. */
  23876. clone(): MirrorTexture;
  23877. /**
  23878. * Serialize the texture to a JSON representation you could use in Parse later on
  23879. * @returns the serialized JSON representation
  23880. */
  23881. serialize(): any;
  23882. /**
  23883. * Dispose the texture and release its associated resources.
  23884. */
  23885. dispose(): void;
  23886. }
  23887. }
  23888. declare module BABYLON {
  23889. /**
  23890. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23891. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23892. */
  23893. export class Texture extends BaseTexture {
  23894. /**
  23895. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23896. */
  23897. static SerializeBuffers: boolean;
  23898. /**
  23899. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23900. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23901. */
  23902. static ForceSerializeBuffers: boolean;
  23903. /** @hidden */
  23904. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23905. /** @hidden */
  23906. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23907. /** @hidden */
  23908. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23909. /** nearest is mag = nearest and min = nearest and mip = linear */
  23910. static readonly NEAREST_SAMPLINGMODE: number;
  23911. /** nearest is mag = nearest and min = nearest and mip = linear */
  23912. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23913. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23914. static readonly BILINEAR_SAMPLINGMODE: number;
  23915. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23916. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23917. /** Trilinear is mag = linear and min = linear and mip = linear */
  23918. static readonly TRILINEAR_SAMPLINGMODE: number;
  23919. /** Trilinear is mag = linear and min = linear and mip = linear */
  23920. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23921. /** mag = nearest and min = nearest and mip = nearest */
  23922. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23923. /** mag = nearest and min = linear and mip = nearest */
  23924. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23925. /** mag = nearest and min = linear and mip = linear */
  23926. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23927. /** mag = nearest and min = linear and mip = none */
  23928. static readonly NEAREST_LINEAR: number;
  23929. /** mag = nearest and min = nearest and mip = none */
  23930. static readonly NEAREST_NEAREST: number;
  23931. /** mag = linear and min = nearest and mip = nearest */
  23932. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23933. /** mag = linear and min = nearest and mip = linear */
  23934. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23935. /** mag = linear and min = linear and mip = none */
  23936. static readonly LINEAR_LINEAR: number;
  23937. /** mag = linear and min = nearest and mip = none */
  23938. static readonly LINEAR_NEAREST: number;
  23939. /** Explicit coordinates mode */
  23940. static readonly EXPLICIT_MODE: number;
  23941. /** Spherical coordinates mode */
  23942. static readonly SPHERICAL_MODE: number;
  23943. /** Planar coordinates mode */
  23944. static readonly PLANAR_MODE: number;
  23945. /** Cubic coordinates mode */
  23946. static readonly CUBIC_MODE: number;
  23947. /** Projection coordinates mode */
  23948. static readonly PROJECTION_MODE: number;
  23949. /** Inverse Cubic coordinates mode */
  23950. static readonly SKYBOX_MODE: number;
  23951. /** Inverse Cubic coordinates mode */
  23952. static readonly INVCUBIC_MODE: number;
  23953. /** Equirectangular coordinates mode */
  23954. static readonly EQUIRECTANGULAR_MODE: number;
  23955. /** Equirectangular Fixed coordinates mode */
  23956. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23957. /** Equirectangular Fixed Mirrored coordinates mode */
  23958. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23959. /** Texture is not repeating outside of 0..1 UVs */
  23960. static readonly CLAMP_ADDRESSMODE: number;
  23961. /** Texture is repeating outside of 0..1 UVs */
  23962. static readonly WRAP_ADDRESSMODE: number;
  23963. /** Texture is repeating and mirrored */
  23964. static readonly MIRROR_ADDRESSMODE: number;
  23965. /**
  23966. * 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
  23967. */
  23968. static UseSerializedUrlIfAny: boolean;
  23969. /**
  23970. * Define the url of the texture.
  23971. */
  23972. url: Nullable<string>;
  23973. /**
  23974. * Define an offset on the texture to offset the u coordinates of the UVs
  23975. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23976. */
  23977. uOffset: number;
  23978. /**
  23979. * Define an offset on the texture to offset the v coordinates of the UVs
  23980. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23981. */
  23982. vOffset: number;
  23983. /**
  23984. * Define an offset on the texture to scale the u coordinates of the UVs
  23985. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23986. */
  23987. uScale: number;
  23988. /**
  23989. * Define an offset on the texture to scale the v coordinates of the UVs
  23990. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23991. */
  23992. vScale: number;
  23993. /**
  23994. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23995. * @see https://doc.babylonjs.com/how_to/more_materials
  23996. */
  23997. uAng: number;
  23998. /**
  23999. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24000. * @see https://doc.babylonjs.com/how_to/more_materials
  24001. */
  24002. vAng: number;
  24003. /**
  24004. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24005. * @see https://doc.babylonjs.com/how_to/more_materials
  24006. */
  24007. wAng: number;
  24008. /**
  24009. * Defines the center of rotation (U)
  24010. */
  24011. uRotationCenter: number;
  24012. /**
  24013. * Defines the center of rotation (V)
  24014. */
  24015. vRotationCenter: number;
  24016. /**
  24017. * Defines the center of rotation (W)
  24018. */
  24019. wRotationCenter: number;
  24020. /**
  24021. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  24022. */
  24023. homogeneousRotationInUVTransform: boolean;
  24024. /**
  24025. * Are mip maps generated for this texture or not.
  24026. */
  24027. get noMipmap(): boolean;
  24028. /**
  24029. * List of inspectable custom properties (used by the Inspector)
  24030. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24031. */
  24032. inspectableCustomProperties: Nullable<IInspectable[]>;
  24033. private _noMipmap;
  24034. /** @hidden */
  24035. _invertY: boolean;
  24036. private _rowGenerationMatrix;
  24037. private _cachedTextureMatrix;
  24038. private _projectionModeMatrix;
  24039. private _t0;
  24040. private _t1;
  24041. private _t2;
  24042. private _cachedUOffset;
  24043. private _cachedVOffset;
  24044. private _cachedUScale;
  24045. private _cachedVScale;
  24046. private _cachedUAng;
  24047. private _cachedVAng;
  24048. private _cachedWAng;
  24049. private _cachedProjectionMatrixId;
  24050. private _cachedURotationCenter;
  24051. private _cachedVRotationCenter;
  24052. private _cachedWRotationCenter;
  24053. private _cachedHomogeneousRotationInUVTransform;
  24054. private _cachedCoordinatesMode;
  24055. /** @hidden */
  24056. protected _initialSamplingMode: number;
  24057. /** @hidden */
  24058. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24059. private _deleteBuffer;
  24060. protected _format: Nullable<number>;
  24061. private _delayedOnLoad;
  24062. private _delayedOnError;
  24063. private _mimeType?;
  24064. private _loaderOptions?;
  24065. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24066. get mimeType(): string | undefined;
  24067. /**
  24068. * Observable triggered once the texture has been loaded.
  24069. */
  24070. onLoadObservable: Observable<Texture>;
  24071. protected _isBlocking: boolean;
  24072. /**
  24073. * Is the texture preventing material to render while loading.
  24074. * If false, a default texture will be used instead of the loading one during the preparation step.
  24075. */
  24076. set isBlocking(value: boolean);
  24077. get isBlocking(): boolean;
  24078. /**
  24079. * Get the current sampling mode associated with the texture.
  24080. */
  24081. get samplingMode(): number;
  24082. /**
  24083. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24084. */
  24085. get invertY(): boolean;
  24086. /**
  24087. * Instantiates a new texture.
  24088. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24089. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24090. * @param url defines the url of the picture to load as a texture
  24091. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24092. * @param noMipmap defines if the texture will require mip maps or not
  24093. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24094. * @param samplingMode defines the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24095. * @param onLoad defines a callback triggered when the texture has been loaded
  24096. * @param onError defines a callback triggered when an error occurred during the loading session
  24097. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24098. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24099. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24100. * @param mimeType defines an optional mime type information
  24101. * @param loaderOptions options to be passed to the loader
  24102. */
  24103. 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);
  24104. /**
  24105. * Update the url (and optional buffer) of this texture if url was null during construction.
  24106. * @param url the url of the texture
  24107. * @param buffer the buffer of the texture (defaults to null)
  24108. * @param onLoad callback called when the texture is loaded (defaults to null)
  24109. */
  24110. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24111. /**
  24112. * Finish the loading sequence of a texture flagged as delayed load.
  24113. * @hidden
  24114. */
  24115. delayLoad(): void;
  24116. private _prepareRowForTextureGeneration;
  24117. /**
  24118. * Checks if the texture has the same transform matrix than another texture
  24119. * @param texture texture to check against
  24120. * @returns true if the transforms are the same, else false
  24121. */
  24122. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24123. /**
  24124. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24125. * @returns the transform matrix of the texture.
  24126. */
  24127. getTextureMatrix(uBase?: number): Matrix;
  24128. /**
  24129. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24130. * @returns The reflection texture transform
  24131. */
  24132. getReflectionTextureMatrix(): Matrix;
  24133. /**
  24134. * Clones the texture.
  24135. * @returns the cloned texture
  24136. */
  24137. clone(): Texture;
  24138. /**
  24139. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  24140. * @returns The JSON representation of the texture
  24141. */
  24142. serialize(): any;
  24143. /**
  24144. * Get the current class name of the texture useful for serialization or dynamic coding.
  24145. * @returns "Texture"
  24146. */
  24147. getClassName(): string;
  24148. /**
  24149. * Dispose the texture and release its associated resources.
  24150. */
  24151. dispose(): void;
  24152. /**
  24153. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24154. * @param parsedTexture Define the JSON representation of the texture
  24155. * @param scene Define the scene the parsed texture should be instantiated in
  24156. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24157. * @returns The parsed texture if successful
  24158. */
  24159. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24160. /**
  24161. * Creates a texture from its base 64 representation.
  24162. * @param data Define the base64 payload without the data: prefix
  24163. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24164. * @param scene Define the scene the texture should belong to
  24165. * @param noMipmap Forces the texture to not create mip map information if true
  24166. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24167. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24168. * @param onLoad define a callback triggered when the texture has been loaded
  24169. * @param onError define a callback triggered when an error occurred during the loading session
  24170. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24171. * @returns the created texture
  24172. */
  24173. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24174. /**
  24175. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24176. * @param data Define the base64 payload without the data: prefix
  24177. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24178. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24179. * @param scene Define the scene the texture should belong to
  24180. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24181. * @param noMipmap Forces the texture to not create mip map information if true
  24182. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24183. * @param samplingMode define the sampling mode we want for the texture while fetching from it (Texture.NEAREST_SAMPLINGMODE...)
  24184. * @param onLoad define a callback triggered when the texture has been loaded
  24185. * @param onError define a callback triggered when an error occurred during the loading session
  24186. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24187. * @returns the created texture
  24188. */
  24189. 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;
  24190. }
  24191. }
  24192. declare module BABYLON {
  24193. /**
  24194. * ThinSprite Class used to represent a thin sprite
  24195. * This is the base class for sprites but can also directly be used with ThinEngine
  24196. * @see https://doc.babylonjs.com/babylon101/sprites
  24197. */
  24198. export class ThinSprite {
  24199. /** Gets or sets the cell index in the sprite sheet */
  24200. cellIndex: number;
  24201. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24202. cellRef: string;
  24203. /** Gets or sets the current world position */
  24204. position: IVector3Like;
  24205. /** Gets or sets the main color */
  24206. color: IColor4Like;
  24207. /** Gets or sets the width */
  24208. width: number;
  24209. /** Gets or sets the height */
  24210. height: number;
  24211. /** Gets or sets rotation angle */
  24212. angle: number;
  24213. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24214. invertU: boolean;
  24215. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24216. invertV: boolean;
  24217. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24218. isVisible: boolean;
  24219. /**
  24220. * Returns a boolean indicating if the animation is started
  24221. */
  24222. get animationStarted(): boolean;
  24223. /** Gets the initial key for the animation (setting it will restart the animation) */
  24224. get fromIndex(): number;
  24225. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24226. get toIndex(): number;
  24227. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24228. get loopAnimation(): boolean;
  24229. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24230. get delay(): number;
  24231. /** @hidden */
  24232. _xOffset: number;
  24233. /** @hidden */
  24234. _yOffset: number;
  24235. /** @hidden */
  24236. _xSize: number;
  24237. /** @hidden */
  24238. _ySize: number;
  24239. private _animationStarted;
  24240. protected _loopAnimation: boolean;
  24241. protected _fromIndex: number;
  24242. protected _toIndex: number;
  24243. protected _delay: number;
  24244. private _direction;
  24245. private _time;
  24246. private _onBaseAnimationEnd;
  24247. /**
  24248. * Creates a new Thin Sprite
  24249. */
  24250. constructor();
  24251. /**
  24252. * Starts an animation
  24253. * @param from defines the initial key
  24254. * @param to defines the end key
  24255. * @param loop defines if the animation must loop
  24256. * @param delay defines the start delay (in ms)
  24257. * @param onAnimationEnd defines a callback for when the animation ends
  24258. */
  24259. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24260. /** Stops current animation (if any) */
  24261. stopAnimation(): void;
  24262. /** @hidden */
  24263. _animate(deltaTime: number): void;
  24264. }
  24265. }
  24266. declare module BABYLON {
  24267. /** @hidden */
  24268. export var imageProcessingCompatibility: {
  24269. name: string;
  24270. shader: string;
  24271. };
  24272. }
  24273. declare module BABYLON {
  24274. /** @hidden */
  24275. export var spritesPixelShader: {
  24276. name: string;
  24277. shader: string;
  24278. };
  24279. }
  24280. declare module BABYLON {
  24281. /** @hidden */
  24282. export var spritesVertexShader: {
  24283. name: string;
  24284. shader: string;
  24285. };
  24286. }
  24287. declare module BABYLON {
  24288. /**
  24289. * Class used to render sprites.
  24290. *
  24291. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24292. */
  24293. export class SpriteRenderer {
  24294. /**
  24295. * Defines the texture of the spritesheet
  24296. */
  24297. texture: Nullable<ThinTexture>;
  24298. /**
  24299. * Defines the default width of a cell in the spritesheet
  24300. */
  24301. cellWidth: number;
  24302. /**
  24303. * Defines the default height of a cell in the spritesheet
  24304. */
  24305. cellHeight: number;
  24306. /**
  24307. * Blend mode use to render the particle, it can be any of
  24308. * the static Constants.ALPHA_x properties provided in this class.
  24309. * Default value is Constants.ALPHA_COMBINE
  24310. */
  24311. blendMode: number;
  24312. /**
  24313. * Gets or sets a boolean indicating if alpha mode is automatically
  24314. * reset.
  24315. */
  24316. autoResetAlpha: boolean;
  24317. /**
  24318. * Disables writing to the depth buffer when rendering the sprites.
  24319. * It can be handy to disable depth writing when using textures without alpha channel
  24320. * and setting some specific blend modes.
  24321. */
  24322. disableDepthWrite: boolean;
  24323. /**
  24324. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24325. */
  24326. fogEnabled: boolean;
  24327. /**
  24328. * Gets the capacity of the manager
  24329. */
  24330. get capacity(): number;
  24331. private readonly _engine;
  24332. private readonly _useVAO;
  24333. private readonly _useInstancing;
  24334. private readonly _scene;
  24335. private readonly _capacity;
  24336. private readonly _epsilon;
  24337. private _vertexBufferSize;
  24338. private _vertexData;
  24339. private _buffer;
  24340. private _vertexBuffers;
  24341. private _spriteBuffer;
  24342. private _indexBuffer;
  24343. private _effectBase;
  24344. private _effectFog;
  24345. private _vertexArrayObject;
  24346. /**
  24347. * Creates a new sprite Renderer
  24348. * @param engine defines the engine the renderer works with
  24349. * @param capacity defines the maximum allowed number of sprites
  24350. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24351. * @param scene defines the hosting scene
  24352. */
  24353. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24354. /**
  24355. * Render all child sprites
  24356. * @param sprites defines the list of sprites to render
  24357. * @param deltaTime defines the time since last frame
  24358. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24359. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24360. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24361. */
  24362. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24363. private _appendSpriteVertex;
  24364. /**
  24365. * Release associated resources
  24366. */
  24367. dispose(): void;
  24368. }
  24369. }
  24370. declare module BABYLON {
  24371. /**
  24372. * Defines the minimum interface to fulfill in order to be a sprite manager.
  24373. */
  24374. export interface ISpriteManager extends IDisposable {
  24375. /**
  24376. * Gets manager's name
  24377. */
  24378. name: string;
  24379. /**
  24380. * Restricts the camera to viewing objects with the same layerMask.
  24381. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24382. */
  24383. layerMask: number;
  24384. /**
  24385. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24386. */
  24387. isPickable: boolean;
  24388. /**
  24389. * Gets the hosting scene
  24390. */
  24391. scene: Scene;
  24392. /**
  24393. * Specifies the rendering group id for this mesh (0 by default)
  24394. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24395. */
  24396. renderingGroupId: number;
  24397. /**
  24398. * Defines the list of sprites managed by the manager.
  24399. */
  24400. sprites: Array<Sprite>;
  24401. /**
  24402. * Gets or sets the spritesheet texture
  24403. */
  24404. texture: Texture;
  24405. /** Defines the default width of a cell in the spritesheet */
  24406. cellWidth: number;
  24407. /** Defines the default height of a cell in the spritesheet */
  24408. cellHeight: number;
  24409. /**
  24410. * Tests the intersection of a sprite with a specific ray.
  24411. * @param ray The ray we are sending to test the collision
  24412. * @param camera The camera space we are sending rays in
  24413. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24415. * @returns picking info or null.
  24416. */
  24417. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24418. /**
  24419. * Intersects the sprites with a ray
  24420. * @param ray defines the ray to intersect with
  24421. * @param camera defines the current active camera
  24422. * @param predicate defines a predicate used to select candidate sprites
  24423. * @returns null if no hit or a PickingInfo array
  24424. */
  24425. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24426. /**
  24427. * Renders the list of sprites on screen.
  24428. */
  24429. render(): void;
  24430. }
  24431. /**
  24432. * Class used to manage multiple sprites on the same spritesheet
  24433. * @see https://doc.babylonjs.com/babylon101/sprites
  24434. */
  24435. export class SpriteManager implements ISpriteManager {
  24436. /** defines the manager's name */
  24437. name: string;
  24438. /** Define the Url to load snippets */
  24439. static SnippetUrl: string;
  24440. /** Snippet ID if the manager was created from the snippet server */
  24441. snippetId: string;
  24442. /** Gets the list of sprites */
  24443. sprites: Sprite[];
  24444. /** Gets or sets the rendering group id (0 by default) */
  24445. renderingGroupId: number;
  24446. /** Gets or sets camera layer mask */
  24447. layerMask: number;
  24448. /** Gets or sets a boolean indicating if the sprites are pickable */
  24449. isPickable: boolean;
  24450. /**
  24451. * An event triggered when the manager is disposed.
  24452. */
  24453. onDisposeObservable: Observable<SpriteManager>;
  24454. /**
  24455. * Callback called when the manager is disposed
  24456. */
  24457. set onDispose(callback: () => void);
  24458. /**
  24459. * Gets or sets the unique id of the sprite
  24460. */
  24461. uniqueId: number;
  24462. /**
  24463. * Gets the array of sprites
  24464. */
  24465. get children(): Sprite[];
  24466. /**
  24467. * Gets the hosting scene
  24468. */
  24469. get scene(): Scene;
  24470. /**
  24471. * Gets the capacity of the manager
  24472. */
  24473. get capacity(): number;
  24474. /**
  24475. * Gets or sets the spritesheet texture
  24476. */
  24477. get texture(): Texture;
  24478. set texture(value: Texture);
  24479. /** Defines the default width of a cell in the spritesheet */
  24480. get cellWidth(): number;
  24481. set cellWidth(value: number);
  24482. /** Defines the default height of a cell in the spritesheet */
  24483. get cellHeight(): number;
  24484. set cellHeight(value: number);
  24485. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24486. get fogEnabled(): boolean;
  24487. set fogEnabled(value: boolean);
  24488. /**
  24489. * Blend mode use to render the particle, it can be any of
  24490. * the static Constants.ALPHA_x properties provided in this class.
  24491. * Default value is Constants.ALPHA_COMBINE
  24492. */
  24493. get blendMode(): number;
  24494. set blendMode(blendMode: number);
  24495. /** Disables writing to the depth buffer when rendering the sprites.
  24496. * It can be handy to disable depth writing when using textures without alpha channel
  24497. * and setting some specific blend modes.
  24498. */
  24499. disableDepthWrite: boolean;
  24500. private _spriteRenderer;
  24501. /** Associative array from JSON sprite data file */
  24502. private _cellData;
  24503. /** Array of sprite names from JSON sprite data file */
  24504. private _spriteMap;
  24505. /** True when packed cell data from JSON file is ready*/
  24506. private _packedAndReady;
  24507. private _textureContent;
  24508. private _onDisposeObserver;
  24509. private _fromPacked;
  24510. private _scene;
  24511. /**
  24512. * Creates a new sprite manager
  24513. * @param name defines the manager's name
  24514. * @param imgUrl defines the sprite sheet url
  24515. * @param capacity defines the maximum allowed number of sprites
  24516. * @param cellSize defines the size of a sprite cell
  24517. * @param scene defines the hosting scene
  24518. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24519. * @param samplingMode defines the sampling mode to use with spritesheet
  24520. * @param fromPacked set to false; do not alter
  24521. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24522. */
  24523. constructor(
  24524. /** defines the manager's name */
  24525. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24526. /**
  24527. * Returns the string "SpriteManager"
  24528. * @returns "SpriteManager"
  24529. */
  24530. getClassName(): string;
  24531. private _makePacked;
  24532. private _checkTextureAlpha;
  24533. /**
  24534. * Intersects the sprites with a ray
  24535. * @param ray defines the ray to intersect with
  24536. * @param camera defines the current active camera
  24537. * @param predicate defines a predicate used to select candidate sprites
  24538. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24539. * @returns null if no hit or a PickingInfo
  24540. */
  24541. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24542. /**
  24543. * Intersects the sprites with a ray
  24544. * @param ray defines the ray to intersect with
  24545. * @param camera defines the current active camera
  24546. * @param predicate defines a predicate used to select candidate sprites
  24547. * @returns null if no hit or a PickingInfo array
  24548. */
  24549. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24550. /**
  24551. * Render all child sprites
  24552. */
  24553. render(): void;
  24554. private _customUpdate;
  24555. /**
  24556. * Release associated resources
  24557. */
  24558. dispose(): void;
  24559. /**
  24560. * Serializes the sprite manager to a JSON object
  24561. * @param serializeTexture defines if the texture must be serialized as well
  24562. * @returns the JSON object
  24563. */
  24564. serialize(serializeTexture?: boolean): any;
  24565. /**
  24566. * Parses a JSON object to create a new sprite manager.
  24567. * @param parsedManager The JSON object to parse
  24568. * @param scene The scene to create the sprite manager
  24569. * @param rootUrl The root url to use to load external dependencies like texture
  24570. * @returns the new sprite manager
  24571. */
  24572. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24573. /**
  24574. * Creates a sprite manager from a snippet saved in a remote file
  24575. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24576. * @param url defines the url to load from
  24577. * @param scene defines the hosting scene
  24578. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24579. * @returns a promise that will resolve to the new sprite manager
  24580. */
  24581. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24582. /**
  24583. * Creates a sprite manager from a snippet saved by the sprite editor
  24584. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24585. * @param scene defines the hosting scene
  24586. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24587. * @returns a promise that will resolve to the new sprite manager
  24588. */
  24589. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24590. }
  24591. }
  24592. declare module BABYLON {
  24593. /**
  24594. * Class used to represent a sprite
  24595. * @see https://doc.babylonjs.com/babylon101/sprites
  24596. */
  24597. export class Sprite extends ThinSprite implements IAnimatable {
  24598. /** defines the name */
  24599. name: string;
  24600. /** Gets or sets the current world position */
  24601. position: Vector3;
  24602. /** Gets or sets the main color */
  24603. color: Color4;
  24604. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24605. disposeWhenFinishedAnimating: boolean;
  24606. /** Gets the list of attached animations */
  24607. animations: Nullable<Array<Animation>>;
  24608. /** Gets or sets a boolean indicating if the sprite can be picked */
  24609. isPickable: boolean;
  24610. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24611. useAlphaForPicking: boolean;
  24612. /**
  24613. * Gets or sets the associated action manager
  24614. */
  24615. actionManager: Nullable<ActionManager>;
  24616. /**
  24617. * An event triggered when the control has been disposed
  24618. */
  24619. onDisposeObservable: Observable<Sprite>;
  24620. private _manager;
  24621. private _onAnimationEnd;
  24622. /**
  24623. * Gets or sets the sprite size
  24624. */
  24625. get size(): number;
  24626. set size(value: number);
  24627. /**
  24628. * Gets or sets the unique id of the sprite
  24629. */
  24630. uniqueId: number;
  24631. /**
  24632. * Gets the manager of this sprite
  24633. */
  24634. get manager(): ISpriteManager;
  24635. /**
  24636. * Creates a new Sprite
  24637. * @param name defines the name
  24638. * @param manager defines the manager
  24639. */
  24640. constructor(
  24641. /** defines the name */
  24642. name: string, manager: ISpriteManager);
  24643. /**
  24644. * Returns the string "Sprite"
  24645. * @returns "Sprite"
  24646. */
  24647. getClassName(): string;
  24648. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24649. get fromIndex(): number;
  24650. set fromIndex(value: number);
  24651. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24652. get toIndex(): number;
  24653. set toIndex(value: number);
  24654. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24655. get loopAnimation(): boolean;
  24656. set loopAnimation(value: boolean);
  24657. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24658. get delay(): number;
  24659. set delay(value: number);
  24660. /**
  24661. * Starts an animation
  24662. * @param from defines the initial key
  24663. * @param to defines the end key
  24664. * @param loop defines if the animation must loop
  24665. * @param delay defines the start delay (in ms)
  24666. * @param onAnimationEnd defines a callback to call when animation ends
  24667. */
  24668. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24669. private _endAnimation;
  24670. /** Release associated resources */
  24671. dispose(): void;
  24672. /**
  24673. * Serializes the sprite to a JSON object
  24674. * @returns the JSON object
  24675. */
  24676. serialize(): any;
  24677. /**
  24678. * Parses a JSON object to create a new sprite
  24679. * @param parsedSprite The JSON object to parse
  24680. * @param manager defines the hosting manager
  24681. * @returns the new sprite
  24682. */
  24683. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24684. }
  24685. }
  24686. declare module BABYLON {
  24687. /**
  24688. * Information about the result of picking within a scene
  24689. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24690. */
  24691. export class PickingInfo {
  24692. /** @hidden */
  24693. _pickingUnavailable: boolean;
  24694. /**
  24695. * If the pick collided with an object
  24696. */
  24697. hit: boolean;
  24698. /**
  24699. * Distance away where the pick collided
  24700. */
  24701. distance: number;
  24702. /**
  24703. * The location of pick collision
  24704. */
  24705. pickedPoint: Nullable<Vector3>;
  24706. /**
  24707. * The mesh corresponding the the pick collision
  24708. */
  24709. pickedMesh: Nullable<AbstractMesh>;
  24710. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24711. bu: number;
  24712. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24713. bv: number;
  24714. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24715. faceId: number;
  24716. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24717. subMeshFaceId: number;
  24718. /** Id of the the submesh that was picked */
  24719. subMeshId: number;
  24720. /** If a sprite was picked, this will be the sprite the pick collided with */
  24721. pickedSprite: Nullable<Sprite>;
  24722. /** If we are picking a mesh with thin instance, this will give you the picked thin instance */
  24723. thinInstanceIndex: number;
  24724. /**
  24725. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24726. */
  24727. originMesh: Nullable<AbstractMesh>;
  24728. /**
  24729. * The ray that was used to perform the picking.
  24730. */
  24731. ray: Nullable<Ray>;
  24732. /**
  24733. * Gets the normal corresponding to the face the pick collided with
  24734. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24735. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24736. * @returns The normal corresponding to the face the pick collided with
  24737. */
  24738. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24739. /**
  24740. * Gets the texture coordinates of where the pick occurred
  24741. * @returns the vector containing the coordinates of the texture
  24742. */
  24743. getTextureCoordinates(): Nullable<Vector2>;
  24744. }
  24745. }
  24746. declare module BABYLON {
  24747. /**
  24748. * Gather the list of pointer event types as constants.
  24749. */
  24750. export class PointerEventTypes {
  24751. /**
  24752. * 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.
  24753. */
  24754. static readonly POINTERDOWN: number;
  24755. /**
  24756. * The pointerup event is fired when a pointer is no longer active.
  24757. */
  24758. static readonly POINTERUP: number;
  24759. /**
  24760. * The pointermove event is fired when a pointer changes coordinates.
  24761. */
  24762. static readonly POINTERMOVE: number;
  24763. /**
  24764. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24765. */
  24766. static readonly POINTERWHEEL: number;
  24767. /**
  24768. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24769. */
  24770. static readonly POINTERPICK: number;
  24771. /**
  24772. * The pointertap event is fired when a the object has been touched and released without drag.
  24773. */
  24774. static readonly POINTERTAP: number;
  24775. /**
  24776. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24777. */
  24778. static readonly POINTERDOUBLETAP: number;
  24779. }
  24780. /**
  24781. * Base class of pointer info types.
  24782. */
  24783. export class PointerInfoBase {
  24784. /**
  24785. * Defines the type of event (PointerEventTypes)
  24786. */
  24787. type: number;
  24788. /**
  24789. * Defines the related dom event
  24790. */
  24791. event: PointerEvent | MouseWheelEvent;
  24792. /**
  24793. * Instantiates the base class of pointers info.
  24794. * @param type Defines the type of event (PointerEventTypes)
  24795. * @param event Defines the related dom event
  24796. */
  24797. constructor(
  24798. /**
  24799. * Defines the type of event (PointerEventTypes)
  24800. */
  24801. type: number,
  24802. /**
  24803. * Defines the related dom event
  24804. */
  24805. event: PointerEvent | MouseWheelEvent);
  24806. }
  24807. /**
  24808. * This class is used to store pointer related info for the onPrePointerObservable event.
  24809. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24810. */
  24811. export class PointerInfoPre extends PointerInfoBase {
  24812. /**
  24813. * Ray from a pointer if availible (eg. 6dof controller)
  24814. */
  24815. ray: Nullable<Ray>;
  24816. /**
  24817. * Defines the local position of the pointer on the canvas.
  24818. */
  24819. localPosition: Vector2;
  24820. /**
  24821. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24822. */
  24823. skipOnPointerObservable: boolean;
  24824. /**
  24825. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24826. * @param type Defines the type of event (PointerEventTypes)
  24827. * @param event Defines the related dom event
  24828. * @param localX Defines the local x coordinates of the pointer when the event occured
  24829. * @param localY Defines the local y coordinates of the pointer when the event occured
  24830. */
  24831. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24832. }
  24833. /**
  24834. * This type contains all the data related to a pointer event in Babylon.js.
  24835. * 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.
  24836. */
  24837. export class PointerInfo extends PointerInfoBase {
  24838. /**
  24839. * Defines the picking info associated to the info (if any)\
  24840. */
  24841. pickInfo: Nullable<PickingInfo>;
  24842. /**
  24843. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24844. * @param type Defines the type of event (PointerEventTypes)
  24845. * @param event Defines the related dom event
  24846. * @param pickInfo Defines the picking info associated to the info (if any)\
  24847. */
  24848. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24849. /**
  24850. * Defines the picking info associated to the info (if any)\
  24851. */
  24852. pickInfo: Nullable<PickingInfo>);
  24853. }
  24854. /**
  24855. * Data relating to a touch event on the screen.
  24856. */
  24857. export interface PointerTouch {
  24858. /**
  24859. * X coordinate of touch.
  24860. */
  24861. x: number;
  24862. /**
  24863. * Y coordinate of touch.
  24864. */
  24865. y: number;
  24866. /**
  24867. * Id of touch. Unique for each finger.
  24868. */
  24869. pointerId: number;
  24870. /**
  24871. * Event type passed from DOM.
  24872. */
  24873. type: any;
  24874. }
  24875. }
  24876. declare module BABYLON {
  24877. /**
  24878. * Manage the mouse inputs to control the movement of a free camera.
  24879. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24880. */
  24881. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24882. /**
  24883. * Define if touch is enabled in the mouse input
  24884. */
  24885. touchEnabled: boolean;
  24886. /**
  24887. * Defines the camera the input is attached to.
  24888. */
  24889. camera: FreeCamera;
  24890. /**
  24891. * Defines the buttons associated with the input to handle camera move.
  24892. */
  24893. buttons: number[];
  24894. /**
  24895. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24896. */
  24897. angularSensibility: number;
  24898. private _pointerInput;
  24899. private _onMouseMove;
  24900. private _observer;
  24901. private previousPosition;
  24902. /**
  24903. * Observable for when a pointer move event occurs containing the move offset
  24904. */
  24905. onPointerMovedObservable: Observable<{
  24906. offsetX: number;
  24907. offsetY: number;
  24908. }>;
  24909. /**
  24910. * @hidden
  24911. * If the camera should be rotated automatically based on pointer movement
  24912. */
  24913. _allowCameraRotation: boolean;
  24914. /**
  24915. * Manage the mouse inputs to control the movement of a free camera.
  24916. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24917. * @param touchEnabled Defines if touch is enabled or not
  24918. */
  24919. constructor(
  24920. /**
  24921. * Define if touch is enabled in the mouse input
  24922. */
  24923. touchEnabled?: boolean);
  24924. /**
  24925. * Attach the input controls to a specific dom element to get the input from.
  24926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24927. */
  24928. attachControl(noPreventDefault?: boolean): void;
  24929. /**
  24930. * Called on JS contextmenu event.
  24931. * Override this method to provide functionality.
  24932. */
  24933. protected onContextMenu(evt: PointerEvent): void;
  24934. /**
  24935. * Detach the current controls from the specified dom element.
  24936. */
  24937. detachControl(): void;
  24938. /**
  24939. * Gets the class name of the current input.
  24940. * @returns the class name
  24941. */
  24942. getClassName(): string;
  24943. /**
  24944. * Get the friendly name associated with the input class.
  24945. * @returns the input friendly name
  24946. */
  24947. getSimpleName(): string;
  24948. }
  24949. }
  24950. declare module BABYLON {
  24951. /**
  24952. * Base class for mouse wheel input..
  24953. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24954. * for example usage.
  24955. */
  24956. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24957. /**
  24958. * Defines the camera the input is attached to.
  24959. */
  24960. abstract camera: Camera;
  24961. /**
  24962. * How fast is the camera moves in relation to X axis mouseWheel events.
  24963. * Use negative value to reverse direction.
  24964. */
  24965. wheelPrecisionX: number;
  24966. /**
  24967. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24968. * Use negative value to reverse direction.
  24969. */
  24970. wheelPrecisionY: number;
  24971. /**
  24972. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24973. * Use negative value to reverse direction.
  24974. */
  24975. wheelPrecisionZ: number;
  24976. /**
  24977. * Observable for when a mouse wheel move event occurs.
  24978. */
  24979. onChangedObservable: Observable<{
  24980. wheelDeltaX: number;
  24981. wheelDeltaY: number;
  24982. wheelDeltaZ: number;
  24983. }>;
  24984. private _wheel;
  24985. private _observer;
  24986. /**
  24987. * Attach the input controls to a specific dom element to get the input from.
  24988. * @param noPreventDefault Defines whether event caught by the controls
  24989. * should call preventdefault().
  24990. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24991. */
  24992. attachControl(noPreventDefault?: boolean): void;
  24993. /**
  24994. * Detach the current controls from the specified dom element.
  24995. */
  24996. detachControl(): void;
  24997. /**
  24998. * Called for each rendered frame.
  24999. */
  25000. checkInputs(): void;
  25001. /**
  25002. * Gets the class name of the current input.
  25003. * @returns the class name
  25004. */
  25005. getClassName(): string;
  25006. /**
  25007. * Get the friendly name associated with the input class.
  25008. * @returns the input friendly name
  25009. */
  25010. getSimpleName(): string;
  25011. /**
  25012. * Incremental value of multiple mouse wheel movements of the X axis.
  25013. * Should be zero-ed when read.
  25014. */
  25015. protected _wheelDeltaX: number;
  25016. /**
  25017. * Incremental value of multiple mouse wheel movements of the Y axis.
  25018. * Should be zero-ed when read.
  25019. */
  25020. protected _wheelDeltaY: number;
  25021. /**
  25022. * Incremental value of multiple mouse wheel movements of the Z axis.
  25023. * Should be zero-ed when read.
  25024. */
  25025. protected _wheelDeltaZ: number;
  25026. /**
  25027. * Firefox uses a different scheme to report scroll distances to other
  25028. * browsers. Rather than use complicated methods to calculate the exact
  25029. * multiple we need to apply, let's just cheat and use a constant.
  25030. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  25031. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  25032. */
  25033. private readonly _ffMultiplier;
  25034. /**
  25035. * Different event attributes for wheel data fall into a few set ranges.
  25036. * Some relevant but dated date here:
  25037. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  25038. */
  25039. private readonly _normalize;
  25040. }
  25041. }
  25042. declare module BABYLON {
  25043. /**
  25044. * Manage the mouse wheel inputs to control a free camera.
  25045. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25046. */
  25047. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  25048. /**
  25049. * Defines the camera the input is attached to.
  25050. */
  25051. camera: FreeCamera;
  25052. /**
  25053. * Gets the class name of the current input.
  25054. * @returns the class name
  25055. */
  25056. getClassName(): string;
  25057. /**
  25058. * Set which movement axis (relative to camera's orientation) the mouse
  25059. * wheel's X axis controls.
  25060. * @param axis The axis to be moved. Set null to clear.
  25061. */
  25062. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  25063. /**
  25064. * Get the configured movement axis (relative to camera's orientation) the
  25065. * mouse wheel's X axis controls.
  25066. * @returns The configured axis or null if none.
  25067. */
  25068. get wheelXMoveRelative(): Nullable<Coordinate>;
  25069. /**
  25070. * Set which movement axis (relative to camera's orientation) the mouse
  25071. * wheel's Y axis controls.
  25072. * @param axis The axis to be moved. Set null to clear.
  25073. */
  25074. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25075. /**
  25076. * Get the configured movement axis (relative to camera's orientation) the
  25077. * mouse wheel's Y axis controls.
  25078. * @returns The configured axis or null if none.
  25079. */
  25080. get wheelYMoveRelative(): Nullable<Coordinate>;
  25081. /**
  25082. * Set which movement axis (relative to camera's orientation) the mouse
  25083. * wheel's Z axis controls.
  25084. * @param axis The axis to be moved. Set null to clear.
  25085. */
  25086. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25087. /**
  25088. * Get the configured movement axis (relative to camera's orientation) the
  25089. * mouse wheel's Z axis controls.
  25090. * @returns The configured axis or null if none.
  25091. */
  25092. get wheelZMoveRelative(): Nullable<Coordinate>;
  25093. /**
  25094. * Set which rotation axis (relative to camera's orientation) the mouse
  25095. * wheel's X axis controls.
  25096. * @param axis The axis to be moved. Set null to clear.
  25097. */
  25098. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25099. /**
  25100. * Get the configured rotation axis (relative to camera's orientation) the
  25101. * mouse wheel's X axis controls.
  25102. * @returns The configured axis or null if none.
  25103. */
  25104. get wheelXRotateRelative(): Nullable<Coordinate>;
  25105. /**
  25106. * Set which rotation axis (relative to camera's orientation) the mouse
  25107. * wheel's Y axis controls.
  25108. * @param axis The axis to be moved. Set null to clear.
  25109. */
  25110. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25111. /**
  25112. * Get the configured rotation axis (relative to camera's orientation) the
  25113. * mouse wheel's Y axis controls.
  25114. * @returns The configured axis or null if none.
  25115. */
  25116. get wheelYRotateRelative(): Nullable<Coordinate>;
  25117. /**
  25118. * Set which rotation axis (relative to camera's orientation) the mouse
  25119. * wheel's Z axis controls.
  25120. * @param axis The axis to be moved. Set null to clear.
  25121. */
  25122. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25123. /**
  25124. * Get the configured rotation axis (relative to camera's orientation) the
  25125. * mouse wheel's Z axis controls.
  25126. * @returns The configured axis or null if none.
  25127. */
  25128. get wheelZRotateRelative(): Nullable<Coordinate>;
  25129. /**
  25130. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25131. * controls.
  25132. * @param axis The axis to be moved. Set null to clear.
  25133. */
  25134. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25135. /**
  25136. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25137. * X axis controls.
  25138. * @returns The configured axis or null if none.
  25139. */
  25140. get wheelXMoveScene(): Nullable<Coordinate>;
  25141. /**
  25142. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25143. * controls.
  25144. * @param axis The axis to be moved. Set null to clear.
  25145. */
  25146. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25147. /**
  25148. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25149. * Y axis controls.
  25150. * @returns The configured axis or null if none.
  25151. */
  25152. get wheelYMoveScene(): Nullable<Coordinate>;
  25153. /**
  25154. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25155. * controls.
  25156. * @param axis The axis to be moved. Set null to clear.
  25157. */
  25158. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25159. /**
  25160. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25161. * Z axis controls.
  25162. * @returns The configured axis or null if none.
  25163. */
  25164. get wheelZMoveScene(): Nullable<Coordinate>;
  25165. /**
  25166. * Called for each rendered frame.
  25167. */
  25168. checkInputs(): void;
  25169. private _moveRelative;
  25170. private _rotateRelative;
  25171. private _moveScene;
  25172. /**
  25173. * These are set to the desired default behaviour.
  25174. */
  25175. private _wheelXAction;
  25176. private _wheelXActionCoordinate;
  25177. private _wheelYAction;
  25178. private _wheelYActionCoordinate;
  25179. private _wheelZAction;
  25180. private _wheelZActionCoordinate;
  25181. /**
  25182. * Update the camera according to any configured properties for the 3
  25183. * mouse-wheel axis.
  25184. */
  25185. private _updateCamera;
  25186. /**
  25187. * Update one property of the camera.
  25188. */
  25189. private _updateCameraProperty;
  25190. }
  25191. }
  25192. declare module BABYLON {
  25193. /**
  25194. * Manage the touch inputs to control the movement of a free camera.
  25195. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25196. */
  25197. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25198. /**
  25199. * Define if mouse events can be treated as touch events
  25200. */
  25201. allowMouse: boolean;
  25202. /**
  25203. * Defines the camera the input is attached to.
  25204. */
  25205. camera: FreeCamera;
  25206. /**
  25207. * Defines the touch sensibility for rotation.
  25208. * The higher the faster.
  25209. */
  25210. touchAngularSensibility: number;
  25211. /**
  25212. * Defines the touch sensibility for move.
  25213. * The higher the faster.
  25214. */
  25215. touchMoveSensibility: number;
  25216. private _offsetX;
  25217. private _offsetY;
  25218. private _pointerPressed;
  25219. private _pointerInput?;
  25220. private _observer;
  25221. private _onLostFocus;
  25222. /**
  25223. * Manage the touch inputs to control the movement of a free camera.
  25224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25225. * @param allowMouse Defines if mouse events can be treated as touch events
  25226. */
  25227. constructor(
  25228. /**
  25229. * Define if mouse events can be treated as touch events
  25230. */
  25231. allowMouse?: boolean);
  25232. /**
  25233. * Attach the input controls to a specific dom element to get the input from.
  25234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25235. */
  25236. attachControl(noPreventDefault?: boolean): void;
  25237. /**
  25238. * Detach the current controls from the specified dom element.
  25239. */
  25240. detachControl(): void;
  25241. /**
  25242. * Update the current camera state depending on the inputs that have been used this frame.
  25243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25244. */
  25245. checkInputs(): void;
  25246. /**
  25247. * Gets the class name of the current input.
  25248. * @returns the class name
  25249. */
  25250. getClassName(): string;
  25251. /**
  25252. * Get the friendly name associated with the input class.
  25253. * @returns the input friendly name
  25254. */
  25255. getSimpleName(): string;
  25256. }
  25257. }
  25258. declare module BABYLON {
  25259. /**
  25260. * Default Inputs manager for the FreeCamera.
  25261. * It groups all the default supported inputs for ease of use.
  25262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25263. */
  25264. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25265. /**
  25266. * @hidden
  25267. */
  25268. _mouseInput: Nullable<FreeCameraMouseInput>;
  25269. /**
  25270. * @hidden
  25271. */
  25272. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25273. /**
  25274. * Instantiates a new FreeCameraInputsManager.
  25275. * @param camera Defines the camera the inputs belong to
  25276. */
  25277. constructor(camera: FreeCamera);
  25278. /**
  25279. * Add keyboard input support to the input manager.
  25280. * @returns the current input manager
  25281. */
  25282. addKeyboard(): FreeCameraInputsManager;
  25283. /**
  25284. * Add mouse input support to the input manager.
  25285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25286. * @returns the current input manager
  25287. */
  25288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25289. /**
  25290. * Removes the mouse input support from the manager
  25291. * @returns the current input manager
  25292. */
  25293. removeMouse(): FreeCameraInputsManager;
  25294. /**
  25295. * Add mouse wheel input support to the input manager.
  25296. * @returns the current input manager
  25297. */
  25298. addMouseWheel(): FreeCameraInputsManager;
  25299. /**
  25300. * Removes the mouse wheel input support from the manager
  25301. * @returns the current input manager
  25302. */
  25303. removeMouseWheel(): FreeCameraInputsManager;
  25304. /**
  25305. * Add touch input support to the input manager.
  25306. * @returns the current input manager
  25307. */
  25308. addTouch(): FreeCameraInputsManager;
  25309. /**
  25310. * Remove all attached input methods from a camera
  25311. */
  25312. clear(): void;
  25313. }
  25314. }
  25315. declare module BABYLON {
  25316. /**
  25317. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25318. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25319. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25320. */
  25321. export class FreeCamera extends TargetCamera {
  25322. /**
  25323. * Define the collision ellipsoid of the camera.
  25324. * This is helpful to simulate a camera body like the player body around the camera
  25325. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25326. */
  25327. ellipsoid: Vector3;
  25328. /**
  25329. * Define an offset for the position of the ellipsoid around the camera.
  25330. * This can be helpful to determine the center of the body near the gravity center of the body
  25331. * instead of its head.
  25332. */
  25333. ellipsoidOffset: Vector3;
  25334. /**
  25335. * Enable or disable collisions of the camera with the rest of the scene objects.
  25336. */
  25337. checkCollisions: boolean;
  25338. /**
  25339. * Enable or disable gravity on the camera.
  25340. */
  25341. applyGravity: boolean;
  25342. /**
  25343. * Define the input manager associated to the camera.
  25344. */
  25345. inputs: FreeCameraInputsManager;
  25346. /**
  25347. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25348. * Higher values reduce sensitivity.
  25349. */
  25350. get angularSensibility(): number;
  25351. /**
  25352. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25353. * Higher values reduce sensitivity.
  25354. */
  25355. set angularSensibility(value: number);
  25356. /**
  25357. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25358. */
  25359. get keysUp(): number[];
  25360. set keysUp(value: number[]);
  25361. /**
  25362. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25363. */
  25364. get keysUpward(): number[];
  25365. set keysUpward(value: number[]);
  25366. /**
  25367. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25368. */
  25369. get keysDown(): number[];
  25370. set keysDown(value: number[]);
  25371. /**
  25372. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25373. */
  25374. get keysDownward(): number[];
  25375. set keysDownward(value: number[]);
  25376. /**
  25377. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25378. */
  25379. get keysLeft(): number[];
  25380. set keysLeft(value: number[]);
  25381. /**
  25382. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25383. */
  25384. get keysRight(): number[];
  25385. set keysRight(value: number[]);
  25386. /**
  25387. * Event raised when the camera collide with a mesh in the scene.
  25388. */
  25389. onCollide: (collidedMesh: AbstractMesh) => void;
  25390. private _collider;
  25391. private _needMoveForGravity;
  25392. private _oldPosition;
  25393. private _diffPosition;
  25394. private _newPosition;
  25395. /** @hidden */
  25396. _localDirection: Vector3;
  25397. /** @hidden */
  25398. _transformedDirection: Vector3;
  25399. /**
  25400. * Instantiates a Free Camera.
  25401. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25402. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25403. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25404. * @param name Define the name of the camera in the scene
  25405. * @param position Define the start position of the camera in the scene
  25406. * @param scene Define the scene the camera belongs to
  25407. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  25408. */
  25409. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25410. /**
  25411. * Attach the input controls to a specific dom element to get the input from.
  25412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25413. */
  25414. attachControl(noPreventDefault?: boolean): void;
  25415. /**
  25416. * Attach the input controls to a specific dom element to get the input from.
  25417. * @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
  25418. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25419. * BACK COMPAT SIGNATURE ONLY.
  25420. */
  25421. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25422. /**
  25423. * Detach the current controls from the specified dom element.
  25424. */
  25425. detachControl(): void;
  25426. /**
  25427. * Detach the current controls from the specified dom element.
  25428. * @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
  25429. */
  25430. detachControl(ignored: any): void;
  25431. private _collisionMask;
  25432. /**
  25433. * Define a collision mask to limit the list of object the camera can collide with
  25434. */
  25435. get collisionMask(): number;
  25436. set collisionMask(mask: number);
  25437. /** @hidden */
  25438. _collideWithWorld(displacement: Vector3): void;
  25439. private _onCollisionPositionChange;
  25440. /** @hidden */
  25441. _checkInputs(): void;
  25442. /** @hidden */
  25443. _decideIfNeedsToMove(): boolean;
  25444. /** @hidden */
  25445. _updatePosition(): void;
  25446. /**
  25447. * Destroy the camera and release the current resources hold by it.
  25448. */
  25449. dispose(): void;
  25450. /**
  25451. * Gets the current object class name.
  25452. * @return the class name
  25453. */
  25454. getClassName(): string;
  25455. }
  25456. }
  25457. declare module BABYLON {
  25458. /**
  25459. * Represents a gamepad control stick position
  25460. */
  25461. export class StickValues {
  25462. /**
  25463. * The x component of the control stick
  25464. */
  25465. x: number;
  25466. /**
  25467. * The y component of the control stick
  25468. */
  25469. y: number;
  25470. /**
  25471. * Initializes the gamepad x and y control stick values
  25472. * @param x The x component of the gamepad control stick value
  25473. * @param y The y component of the gamepad control stick value
  25474. */
  25475. constructor(
  25476. /**
  25477. * The x component of the control stick
  25478. */
  25479. x: number,
  25480. /**
  25481. * The y component of the control stick
  25482. */
  25483. y: number);
  25484. }
  25485. /**
  25486. * An interface which manages callbacks for gamepad button changes
  25487. */
  25488. export interface GamepadButtonChanges {
  25489. /**
  25490. * Called when a gamepad has been changed
  25491. */
  25492. changed: boolean;
  25493. /**
  25494. * Called when a gamepad press event has been triggered
  25495. */
  25496. pressChanged: boolean;
  25497. /**
  25498. * Called when a touch event has been triggered
  25499. */
  25500. touchChanged: boolean;
  25501. /**
  25502. * Called when a value has changed
  25503. */
  25504. valueChanged: boolean;
  25505. }
  25506. /**
  25507. * Represents a gamepad
  25508. */
  25509. export class Gamepad {
  25510. /**
  25511. * The id of the gamepad
  25512. */
  25513. id: string;
  25514. /**
  25515. * The index of the gamepad
  25516. */
  25517. index: number;
  25518. /**
  25519. * The browser gamepad
  25520. */
  25521. browserGamepad: any;
  25522. /**
  25523. * Specifies what type of gamepad this represents
  25524. */
  25525. type: number;
  25526. private _leftStick;
  25527. private _rightStick;
  25528. /** @hidden */
  25529. _isConnected: boolean;
  25530. private _leftStickAxisX;
  25531. private _leftStickAxisY;
  25532. private _rightStickAxisX;
  25533. private _rightStickAxisY;
  25534. /**
  25535. * Triggered when the left control stick has been changed
  25536. */
  25537. private _onleftstickchanged;
  25538. /**
  25539. * Triggered when the right control stick has been changed
  25540. */
  25541. private _onrightstickchanged;
  25542. /**
  25543. * Represents a gamepad controller
  25544. */
  25545. static GAMEPAD: number;
  25546. /**
  25547. * Represents a generic controller
  25548. */
  25549. static GENERIC: number;
  25550. /**
  25551. * Represents an XBox controller
  25552. */
  25553. static XBOX: number;
  25554. /**
  25555. * Represents a pose-enabled controller
  25556. */
  25557. static POSE_ENABLED: number;
  25558. /**
  25559. * Represents an Dual Shock controller
  25560. */
  25561. static DUALSHOCK: number;
  25562. /**
  25563. * Specifies whether the left control stick should be Y-inverted
  25564. */
  25565. protected _invertLeftStickY: boolean;
  25566. /**
  25567. * Specifies if the gamepad has been connected
  25568. */
  25569. get isConnected(): boolean;
  25570. /**
  25571. * Initializes the gamepad
  25572. * @param id The id of the gamepad
  25573. * @param index The index of the gamepad
  25574. * @param browserGamepad The browser gamepad
  25575. * @param leftStickX The x component of the left joystick
  25576. * @param leftStickY The y component of the left joystick
  25577. * @param rightStickX The x component of the right joystick
  25578. * @param rightStickY The y component of the right joystick
  25579. */
  25580. constructor(
  25581. /**
  25582. * The id of the gamepad
  25583. */
  25584. id: string,
  25585. /**
  25586. * The index of the gamepad
  25587. */
  25588. index: number,
  25589. /**
  25590. * The browser gamepad
  25591. */
  25592. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25593. /**
  25594. * Callback triggered when the left joystick has changed
  25595. * @param callback
  25596. */
  25597. onleftstickchanged(callback: (values: StickValues) => void): void;
  25598. /**
  25599. * Callback triggered when the right joystick has changed
  25600. * @param callback
  25601. */
  25602. onrightstickchanged(callback: (values: StickValues) => void): void;
  25603. /**
  25604. * Gets the left joystick
  25605. */
  25606. get leftStick(): StickValues;
  25607. /**
  25608. * Sets the left joystick values
  25609. */
  25610. set leftStick(newValues: StickValues);
  25611. /**
  25612. * Gets the right joystick
  25613. */
  25614. get rightStick(): StickValues;
  25615. /**
  25616. * Sets the right joystick value
  25617. */
  25618. set rightStick(newValues: StickValues);
  25619. /**
  25620. * Updates the gamepad joystick positions
  25621. */
  25622. update(): void;
  25623. /**
  25624. * Disposes the gamepad
  25625. */
  25626. dispose(): void;
  25627. }
  25628. /**
  25629. * Represents a generic gamepad
  25630. */
  25631. export class GenericPad extends Gamepad {
  25632. private _buttons;
  25633. private _onbuttondown;
  25634. private _onbuttonup;
  25635. /**
  25636. * Observable triggered when a button has been pressed
  25637. */
  25638. onButtonDownObservable: Observable<number>;
  25639. /**
  25640. * Observable triggered when a button has been released
  25641. */
  25642. onButtonUpObservable: Observable<number>;
  25643. /**
  25644. * Callback triggered when a button has been pressed
  25645. * @param callback Called when a button has been pressed
  25646. */
  25647. onbuttondown(callback: (buttonPressed: number) => void): void;
  25648. /**
  25649. * Callback triggered when a button has been released
  25650. * @param callback Called when a button has been released
  25651. */
  25652. onbuttonup(callback: (buttonReleased: number) => void): void;
  25653. /**
  25654. * Initializes the generic gamepad
  25655. * @param id The id of the generic gamepad
  25656. * @param index The index of the generic gamepad
  25657. * @param browserGamepad The browser gamepad
  25658. */
  25659. constructor(id: string, index: number, browserGamepad: any);
  25660. private _setButtonValue;
  25661. /**
  25662. * Updates the generic gamepad
  25663. */
  25664. update(): void;
  25665. /**
  25666. * Disposes the generic gamepad
  25667. */
  25668. dispose(): void;
  25669. }
  25670. }
  25671. declare module BABYLON {
  25672. /**
  25673. * Defines a runtime animation
  25674. */
  25675. export class RuntimeAnimation {
  25676. private _events;
  25677. /**
  25678. * The current frame of the runtime animation
  25679. */
  25680. private _currentFrame;
  25681. /**
  25682. * The animation used by the runtime animation
  25683. */
  25684. private _animation;
  25685. /**
  25686. * The target of the runtime animation
  25687. */
  25688. private _target;
  25689. /**
  25690. * The initiating animatable
  25691. */
  25692. private _host;
  25693. /**
  25694. * The original value of the runtime animation
  25695. */
  25696. private _originalValue;
  25697. /**
  25698. * The original blend value of the runtime animation
  25699. */
  25700. private _originalBlendValue;
  25701. /**
  25702. * The offsets cache of the runtime animation
  25703. */
  25704. private _offsetsCache;
  25705. /**
  25706. * The high limits cache of the runtime animation
  25707. */
  25708. private _highLimitsCache;
  25709. /**
  25710. * Specifies if the runtime animation has been stopped
  25711. */
  25712. private _stopped;
  25713. /**
  25714. * The blending factor of the runtime animation
  25715. */
  25716. private _blendingFactor;
  25717. /**
  25718. * The BabylonJS scene
  25719. */
  25720. private _scene;
  25721. /**
  25722. * The current value of the runtime animation
  25723. */
  25724. private _currentValue;
  25725. /** @hidden */
  25726. _animationState: _IAnimationState;
  25727. /**
  25728. * The active target of the runtime animation
  25729. */
  25730. private _activeTargets;
  25731. private _currentActiveTarget;
  25732. private _directTarget;
  25733. /**
  25734. * The target path of the runtime animation
  25735. */
  25736. private _targetPath;
  25737. /**
  25738. * The weight of the runtime animation
  25739. */
  25740. private _weight;
  25741. /**
  25742. * The ratio offset of the runtime animation
  25743. */
  25744. private _ratioOffset;
  25745. /**
  25746. * The previous delay of the runtime animation
  25747. */
  25748. private _previousDelay;
  25749. /**
  25750. * The previous ratio of the runtime animation
  25751. */
  25752. private _previousRatio;
  25753. private _enableBlending;
  25754. private _keys;
  25755. private _minFrame;
  25756. private _maxFrame;
  25757. private _minValue;
  25758. private _maxValue;
  25759. private _targetIsArray;
  25760. /**
  25761. * Gets the current frame of the runtime animation
  25762. */
  25763. get currentFrame(): number;
  25764. /**
  25765. * Gets the weight of the runtime animation
  25766. */
  25767. get weight(): number;
  25768. /**
  25769. * Gets the current value of the runtime animation
  25770. */
  25771. get currentValue(): any;
  25772. /**
  25773. * Gets the target path of the runtime animation
  25774. */
  25775. get targetPath(): string;
  25776. /**
  25777. * Gets the actual target of the runtime animation
  25778. */
  25779. get target(): any;
  25780. /**
  25781. * Gets the additive state of the runtime animation
  25782. */
  25783. get isAdditive(): boolean;
  25784. /** @hidden */
  25785. _onLoop: () => void;
  25786. /**
  25787. * Create a new RuntimeAnimation object
  25788. * @param target defines the target of the animation
  25789. * @param animation defines the source animation object
  25790. * @param scene defines the hosting scene
  25791. * @param host defines the initiating Animatable
  25792. */
  25793. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25794. private _preparePath;
  25795. /**
  25796. * Gets the animation from the runtime animation
  25797. */
  25798. get animation(): Animation;
  25799. /**
  25800. * Resets the runtime animation to the beginning
  25801. * @param restoreOriginal defines whether to restore the target property to the original value
  25802. */
  25803. reset(restoreOriginal?: boolean): void;
  25804. /**
  25805. * Specifies if the runtime animation is stopped
  25806. * @returns Boolean specifying if the runtime animation is stopped
  25807. */
  25808. isStopped(): boolean;
  25809. /**
  25810. * Disposes of the runtime animation
  25811. */
  25812. dispose(): void;
  25813. /**
  25814. * Apply the interpolated value to the target
  25815. * @param currentValue defines the value computed by the animation
  25816. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25817. */
  25818. setValue(currentValue: any, weight: number): void;
  25819. private _getOriginalValues;
  25820. private _setValue;
  25821. /**
  25822. * Gets the loop pmode of the runtime animation
  25823. * @returns Loop Mode
  25824. */
  25825. private _getCorrectLoopMode;
  25826. /**
  25827. * Move the current animation to a given frame
  25828. * @param frame defines the frame to move to
  25829. */
  25830. goToFrame(frame: number): void;
  25831. /**
  25832. * @hidden Internal use only
  25833. */
  25834. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25835. /**
  25836. * Execute the current animation
  25837. * @param delay defines the delay to add to the current frame
  25838. * @param from defines the lower bound of the animation range
  25839. * @param to defines the upper bound of the animation range
  25840. * @param loop defines if the current animation must loop
  25841. * @param speedRatio defines the current speed ratio
  25842. * @param weight defines the weight of the animation (default is -1 so no weight)
  25843. * @param onLoop optional callback called when animation loops
  25844. * @returns a boolean indicating if the animation is running
  25845. */
  25846. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25847. }
  25848. }
  25849. declare module BABYLON {
  25850. /**
  25851. * Class used to store an actual running animation
  25852. */
  25853. export class Animatable {
  25854. /** defines the target object */
  25855. target: any;
  25856. /** defines the starting frame number (default is 0) */
  25857. fromFrame: number;
  25858. /** defines the ending frame number (default is 100) */
  25859. toFrame: number;
  25860. /** defines if the animation must loop (default is false) */
  25861. loopAnimation: boolean;
  25862. /** defines a callback to call when animation ends if it is not looping */
  25863. onAnimationEnd?: (() => void) | null | undefined;
  25864. /** defines a callback to call when animation loops */
  25865. onAnimationLoop?: (() => void) | null | undefined;
  25866. /** defines whether the animation should be evaluated additively */
  25867. isAdditive: boolean;
  25868. private _localDelayOffset;
  25869. private _pausedDelay;
  25870. private _runtimeAnimations;
  25871. private _paused;
  25872. private _scene;
  25873. private _speedRatio;
  25874. private _weight;
  25875. private _syncRoot;
  25876. /**
  25877. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25878. * This will only apply for non looping animation (default is true)
  25879. */
  25880. disposeOnEnd: boolean;
  25881. /**
  25882. * Gets a boolean indicating if the animation has started
  25883. */
  25884. animationStarted: boolean;
  25885. /**
  25886. * Observer raised when the animation ends
  25887. */
  25888. onAnimationEndObservable: Observable<Animatable>;
  25889. /**
  25890. * Observer raised when the animation loops
  25891. */
  25892. onAnimationLoopObservable: Observable<Animatable>;
  25893. /**
  25894. * Gets the root Animatable used to synchronize and normalize animations
  25895. */
  25896. get syncRoot(): Nullable<Animatable>;
  25897. /**
  25898. * Gets the current frame of the first RuntimeAnimation
  25899. * Used to synchronize Animatables
  25900. */
  25901. get masterFrame(): number;
  25902. /**
  25903. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25904. */
  25905. get weight(): number;
  25906. set weight(value: number);
  25907. /**
  25908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25909. */
  25910. get speedRatio(): number;
  25911. set speedRatio(value: number);
  25912. /**
  25913. * Creates a new Animatable
  25914. * @param scene defines the hosting scene
  25915. * @param target defines the target object
  25916. * @param fromFrame defines the starting frame number (default is 0)
  25917. * @param toFrame defines the ending frame number (default is 100)
  25918. * @param loopAnimation defines if the animation must loop (default is false)
  25919. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25920. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25921. * @param animations defines a group of animation to add to the new Animatable
  25922. * @param onAnimationLoop defines a callback to call when animation loops
  25923. * @param isAdditive defines whether the animation should be evaluated additively
  25924. */
  25925. constructor(scene: Scene,
  25926. /** defines the target object */
  25927. target: any,
  25928. /** defines the starting frame number (default is 0) */
  25929. fromFrame?: number,
  25930. /** defines the ending frame number (default is 100) */
  25931. toFrame?: number,
  25932. /** defines if the animation must loop (default is false) */
  25933. loopAnimation?: boolean, speedRatio?: number,
  25934. /** defines a callback to call when animation ends if it is not looping */
  25935. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25936. /** defines a callback to call when animation loops */
  25937. onAnimationLoop?: (() => void) | null | undefined,
  25938. /** defines whether the animation should be evaluated additively */
  25939. isAdditive?: boolean);
  25940. /**
  25941. * Synchronize and normalize current Animatable with a source Animatable
  25942. * This is useful when using animation weights and when animations are not of the same length
  25943. * @param root defines the root Animatable to synchronize with
  25944. * @returns the current Animatable
  25945. */
  25946. syncWith(root: Animatable): Animatable;
  25947. /**
  25948. * Gets the list of runtime animations
  25949. * @returns an array of RuntimeAnimation
  25950. */
  25951. getAnimations(): RuntimeAnimation[];
  25952. /**
  25953. * Adds more animations to the current animatable
  25954. * @param target defines the target of the animations
  25955. * @param animations defines the new animations to add
  25956. */
  25957. appendAnimations(target: any, animations: Animation[]): void;
  25958. /**
  25959. * Gets the source animation for a specific property
  25960. * @param property defines the property to look for
  25961. * @returns null or the source animation for the given property
  25962. */
  25963. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25964. /**
  25965. * Gets the runtime animation for a specific property
  25966. * @param property defines the property to look for
  25967. * @returns null or the runtime animation for the given property
  25968. */
  25969. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25970. /**
  25971. * Resets the animatable to its original state
  25972. */
  25973. reset(): void;
  25974. /**
  25975. * Allows the animatable to blend with current running animations
  25976. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25977. * @param blendingSpeed defines the blending speed to use
  25978. */
  25979. enableBlending(blendingSpeed: number): void;
  25980. /**
  25981. * Disable animation blending
  25982. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25983. */
  25984. disableBlending(): void;
  25985. /**
  25986. * Jump directly to a given frame
  25987. * @param frame defines the frame to jump to
  25988. */
  25989. goToFrame(frame: number): void;
  25990. /**
  25991. * Pause the animation
  25992. */
  25993. pause(): void;
  25994. /**
  25995. * Restart the animation
  25996. */
  25997. restart(): void;
  25998. private _raiseOnAnimationEnd;
  25999. /**
  26000. * Stop and delete the current animation
  26001. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  26002. * @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)
  26003. */
  26004. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  26005. /**
  26006. * Wait asynchronously for the animation to end
  26007. * @returns a promise which will be fulfilled when the animation ends
  26008. */
  26009. waitAsync(): Promise<Animatable>;
  26010. /** @hidden */
  26011. _animate(delay: number): boolean;
  26012. }
  26013. interface Scene {
  26014. /** @hidden */
  26015. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  26016. /** @hidden */
  26017. _processLateAnimationBindingsForMatrices(holder: {
  26018. totalWeight: number;
  26019. totalAdditiveWeight: number;
  26020. animations: RuntimeAnimation[];
  26021. additiveAnimations: RuntimeAnimation[];
  26022. originalValue: Matrix;
  26023. }): any;
  26024. /** @hidden */
  26025. _processLateAnimationBindingsForQuaternions(holder: {
  26026. totalWeight: number;
  26027. totalAdditiveWeight: number;
  26028. animations: RuntimeAnimation[];
  26029. additiveAnimations: RuntimeAnimation[];
  26030. originalValue: Quaternion;
  26031. }, refQuaternion: Quaternion): Quaternion;
  26032. /** @hidden */
  26033. _processLateAnimationBindings(): void;
  26034. /**
  26035. * Will start the animation sequence of a given target
  26036. * @param target defines the target
  26037. * @param from defines from which frame should animation start
  26038. * @param to defines until which frame should animation run.
  26039. * @param weight defines the weight to apply to the animation (1.0 by default)
  26040. * @param loop defines if the animation loops
  26041. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26042. * @param onAnimationEnd defines the function to be executed when the animation ends
  26043. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26044. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26045. * @param onAnimationLoop defines the callback to call when an animation loops
  26046. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26047. * @returns the animatable object created for this animation
  26048. */
  26049. 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;
  26050. /**
  26051. * Will start the animation sequence of a given target
  26052. * @param target defines the target
  26053. * @param from defines from which frame should animation start
  26054. * @param to defines until which frame should animation run.
  26055. * @param loop defines if the animation loops
  26056. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26057. * @param onAnimationEnd defines the function to be executed when the animation ends
  26058. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26059. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26060. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  26061. * @param onAnimationLoop defines the callback to call when an animation loops
  26062. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26063. * @returns the animatable object created for this animation
  26064. */
  26065. 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;
  26066. /**
  26067. * Will start the animation sequence of a given target and its hierarchy
  26068. * @param target defines the target
  26069. * @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.
  26070. * @param from defines from which frame should animation start
  26071. * @param to defines until which frame should animation run.
  26072. * @param loop defines if the animation loops
  26073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26074. * @param onAnimationEnd defines the function to be executed when the animation ends
  26075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26077. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26078. * @param onAnimationLoop defines the callback to call when an animation loops
  26079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26080. * @returns the list of created animatables
  26081. */
  26082. 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[];
  26083. /**
  26084. * Begin a new animation on a given node
  26085. * @param target defines the target where the animation will take place
  26086. * @param animations defines the list of animations to start
  26087. * @param from defines the initial value
  26088. * @param to defines the final value
  26089. * @param loop defines if you want animation to loop (off by default)
  26090. * @param speedRatio defines the speed ratio to apply to all animations
  26091. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26092. * @param onAnimationLoop defines the callback to call when an animation loops
  26093. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26094. * @returns the list of created animatables
  26095. */
  26096. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26097. /**
  26098. * Begin a new animation on a given node and its hierarchy
  26099. * @param target defines the root node where the animation will take place
  26100. * @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.
  26101. * @param animations defines the list of animations to start
  26102. * @param from defines the initial value
  26103. * @param to defines the final value
  26104. * @param loop defines if you want animation to loop (off by default)
  26105. * @param speedRatio defines the speed ratio to apply to all animations
  26106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26107. * @param onAnimationLoop defines the callback to call when an animation loops
  26108. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26109. * @returns the list of animatables created for all nodes
  26110. */
  26111. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26112. /**
  26113. * Gets the animatable associated with a specific target
  26114. * @param target defines the target of the animatable
  26115. * @returns the required animatable if found
  26116. */
  26117. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26118. /**
  26119. * Gets all animatables associated with a given target
  26120. * @param target defines the target to look animatables for
  26121. * @returns an array of Animatables
  26122. */
  26123. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26124. /**
  26125. * Stops and removes all animations that have been applied to the scene
  26126. */
  26127. stopAllAnimations(): void;
  26128. /**
  26129. * Gets the current delta time used by animation engine
  26130. */
  26131. deltaTime: number;
  26132. }
  26133. interface Bone {
  26134. /**
  26135. * Copy an animation range from another bone
  26136. * @param source defines the source bone
  26137. * @param rangeName defines the range name to copy
  26138. * @param frameOffset defines the frame offset
  26139. * @param rescaleAsRequired defines if rescaling must be applied if required
  26140. * @param skelDimensionsRatio defines the scaling ratio
  26141. * @returns true if operation was successful
  26142. */
  26143. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26144. }
  26145. }
  26146. declare module BABYLON {
  26147. /**
  26148. * Class used to override all child animations of a given target
  26149. */
  26150. export class AnimationPropertiesOverride {
  26151. /**
  26152. * Gets or sets a value indicating if animation blending must be used
  26153. */
  26154. enableBlending: boolean;
  26155. /**
  26156. * Gets or sets the blending speed to use when enableBlending is true
  26157. */
  26158. blendingSpeed: number;
  26159. /**
  26160. * Gets or sets the default loop mode to use
  26161. */
  26162. loopMode: number;
  26163. }
  26164. }
  26165. declare module BABYLON {
  26166. /**
  26167. * Class used to handle skinning animations
  26168. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26169. */
  26170. export class Skeleton implements IAnimatable {
  26171. /** defines the skeleton name */
  26172. name: string;
  26173. /** defines the skeleton Id */
  26174. id: string;
  26175. /**
  26176. * Defines the list of child bones
  26177. */
  26178. bones: Bone[];
  26179. /**
  26180. * Defines an estimate of the dimension of the skeleton at rest
  26181. */
  26182. dimensionsAtRest: Vector3;
  26183. /**
  26184. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26185. */
  26186. needInitialSkinMatrix: boolean;
  26187. /**
  26188. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26189. */
  26190. overrideMesh: Nullable<AbstractMesh>;
  26191. /**
  26192. * Gets the list of animations attached to this skeleton
  26193. */
  26194. animations: Array<Animation>;
  26195. private _scene;
  26196. private _isDirty;
  26197. private _transformMatrices;
  26198. private _transformMatrixTexture;
  26199. private _meshesWithPoseMatrix;
  26200. private _animatables;
  26201. private _identity;
  26202. private _synchronizedWithMesh;
  26203. private _ranges;
  26204. private _lastAbsoluteTransformsUpdateId;
  26205. private _canUseTextureForBones;
  26206. private _uniqueId;
  26207. /** @hidden */
  26208. _numBonesWithLinkedTransformNode: number;
  26209. /** @hidden */
  26210. _hasWaitingData: Nullable<boolean>;
  26211. /** @hidden */
  26212. _waitingOverrideMeshId: Nullable<string>;
  26213. /**
  26214. * Specifies if the skeleton should be serialized
  26215. */
  26216. doNotSerialize: boolean;
  26217. private _useTextureToStoreBoneMatrices;
  26218. /**
  26219. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26220. * Please note that this option is not available if the hardware does not support it
  26221. */
  26222. get useTextureToStoreBoneMatrices(): boolean;
  26223. set useTextureToStoreBoneMatrices(value: boolean);
  26224. private _animationPropertiesOverride;
  26225. /**
  26226. * Gets or sets the animation properties override
  26227. */
  26228. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26229. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26230. /**
  26231. * List of inspectable custom properties (used by the Inspector)
  26232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26233. */
  26234. inspectableCustomProperties: IInspectable[];
  26235. /**
  26236. * An observable triggered before computing the skeleton's matrices
  26237. */
  26238. onBeforeComputeObservable: Observable<Skeleton>;
  26239. /**
  26240. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26241. */
  26242. get isUsingTextureForMatrices(): boolean;
  26243. /**
  26244. * Gets the unique ID of this skeleton
  26245. */
  26246. get uniqueId(): number;
  26247. /**
  26248. * Creates a new skeleton
  26249. * @param name defines the skeleton name
  26250. * @param id defines the skeleton Id
  26251. * @param scene defines the hosting scene
  26252. */
  26253. constructor(
  26254. /** defines the skeleton name */
  26255. name: string,
  26256. /** defines the skeleton Id */
  26257. id: string, scene: Scene);
  26258. /**
  26259. * Gets the current object class name.
  26260. * @return the class name
  26261. */
  26262. getClassName(): string;
  26263. /**
  26264. * Returns an array containing the root bones
  26265. * @returns an array containing the root bones
  26266. */
  26267. getChildren(): Array<Bone>;
  26268. /**
  26269. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26270. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26271. * @returns a Float32Array containing matrices data
  26272. */
  26273. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26274. /**
  26275. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26276. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26277. * @returns a raw texture containing the data
  26278. */
  26279. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26280. /**
  26281. * Gets the current hosting scene
  26282. * @returns a scene object
  26283. */
  26284. getScene(): Scene;
  26285. /**
  26286. * Gets a string representing the current skeleton data
  26287. * @param fullDetails defines a boolean indicating if we want a verbose version
  26288. * @returns a string representing the current skeleton data
  26289. */
  26290. toString(fullDetails?: boolean): string;
  26291. /**
  26292. * Get bone's index searching by name
  26293. * @param name defines bone's name to search for
  26294. * @return the indice of the bone. Returns -1 if not found
  26295. */
  26296. getBoneIndexByName(name: string): number;
  26297. /**
  26298. * Create a new animation range
  26299. * @param name defines the name of the range
  26300. * @param from defines the start key
  26301. * @param to defines the end key
  26302. */
  26303. createAnimationRange(name: string, from: number, to: number): void;
  26304. /**
  26305. * Delete a specific animation range
  26306. * @param name defines the name of the range
  26307. * @param deleteFrames defines if frames must be removed as well
  26308. */
  26309. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26310. /**
  26311. * Gets a specific animation range
  26312. * @param name defines the name of the range to look for
  26313. * @returns the requested animation range or null if not found
  26314. */
  26315. getAnimationRange(name: string): Nullable<AnimationRange>;
  26316. /**
  26317. * Gets the list of all animation ranges defined on this skeleton
  26318. * @returns an array
  26319. */
  26320. getAnimationRanges(): Nullable<AnimationRange>[];
  26321. /**
  26322. * Copy animation range from a source skeleton.
  26323. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26324. * @param source defines the source skeleton
  26325. * @param name defines the name of the range to copy
  26326. * @param rescaleAsRequired defines if rescaling must be applied if required
  26327. * @returns true if operation was successful
  26328. */
  26329. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26330. /**
  26331. * Forces the skeleton to go to rest pose
  26332. */
  26333. returnToRest(): void;
  26334. private _getHighestAnimationFrame;
  26335. /**
  26336. * Begin a specific animation range
  26337. * @param name defines the name of the range to start
  26338. * @param loop defines if looping must be turned on (false by default)
  26339. * @param speedRatio defines the speed ratio to apply (1 by default)
  26340. * @param onAnimationEnd defines a callback which will be called when animation will end
  26341. * @returns a new animatable
  26342. */
  26343. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26344. /**
  26345. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26346. * @param skeleton defines the Skeleton containing the animation range to convert
  26347. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26348. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26349. * @returns the original skeleton
  26350. */
  26351. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26352. /** @hidden */
  26353. _markAsDirty(): void;
  26354. /** @hidden */
  26355. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26356. /** @hidden */
  26357. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26358. private _computeTransformMatrices;
  26359. /**
  26360. * Build all resources required to render a skeleton
  26361. */
  26362. prepare(): void;
  26363. /**
  26364. * Gets the list of animatables currently running for this skeleton
  26365. * @returns an array of animatables
  26366. */
  26367. getAnimatables(): IAnimatable[];
  26368. /**
  26369. * Clone the current skeleton
  26370. * @param name defines the name of the new skeleton
  26371. * @param id defines the id of the new skeleton
  26372. * @returns the new skeleton
  26373. */
  26374. clone(name: string, id?: string): Skeleton;
  26375. /**
  26376. * Enable animation blending for this skeleton
  26377. * @param blendingSpeed defines the blending speed to apply
  26378. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26379. */
  26380. enableBlending(blendingSpeed?: number): void;
  26381. /**
  26382. * Releases all resources associated with the current skeleton
  26383. */
  26384. dispose(): void;
  26385. /**
  26386. * Serialize the skeleton in a JSON object
  26387. * @returns a JSON object
  26388. */
  26389. serialize(): any;
  26390. /**
  26391. * Creates a new skeleton from serialized data
  26392. * @param parsedSkeleton defines the serialized data
  26393. * @param scene defines the hosting scene
  26394. * @returns a new skeleton
  26395. */
  26396. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26397. /**
  26398. * Compute all node absolute transforms
  26399. * @param forceUpdate defines if computation must be done even if cache is up to date
  26400. */
  26401. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26402. /**
  26403. * Gets the root pose matrix
  26404. * @returns a matrix
  26405. */
  26406. getPoseMatrix(): Nullable<Matrix>;
  26407. /**
  26408. * Sorts bones per internal index
  26409. */
  26410. sortBones(): void;
  26411. private _sortBones;
  26412. /**
  26413. * Set the current local matrix as the restPose for all bones in the skeleton.
  26414. */
  26415. setCurrentPoseAsRest(): void;
  26416. }
  26417. }
  26418. declare module BABYLON {
  26419. /**
  26420. * Class used to store bone information
  26421. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26422. */
  26423. export class Bone extends Node {
  26424. /**
  26425. * defines the bone name
  26426. */
  26427. name: string;
  26428. private static _tmpVecs;
  26429. private static _tmpQuat;
  26430. private static _tmpMats;
  26431. /**
  26432. * Gets the list of child bones
  26433. */
  26434. children: Bone[];
  26435. /** Gets the animations associated with this bone */
  26436. animations: Animation[];
  26437. /**
  26438. * Gets or sets bone length
  26439. */
  26440. length: number;
  26441. /**
  26442. * @hidden Internal only
  26443. * Set this value to map this bone to a different index in the transform matrices
  26444. * Set this value to -1 to exclude the bone from the transform matrices
  26445. */
  26446. _index: Nullable<number>;
  26447. private _skeleton;
  26448. private _localMatrix;
  26449. private _restPose;
  26450. private _bindPose;
  26451. private _baseMatrix;
  26452. private _absoluteTransform;
  26453. private _invertedAbsoluteTransform;
  26454. private _parent;
  26455. private _scalingDeterminant;
  26456. private _worldTransform;
  26457. private _localScaling;
  26458. private _localRotation;
  26459. private _localPosition;
  26460. private _needToDecompose;
  26461. private _needToCompose;
  26462. /** @hidden */
  26463. _linkedTransformNode: Nullable<TransformNode>;
  26464. /** @hidden */
  26465. _waitingTransformNodeId: Nullable<string>;
  26466. /** @hidden */
  26467. get _matrix(): Matrix;
  26468. /** @hidden */
  26469. set _matrix(value: Matrix);
  26470. /**
  26471. * Create a new bone
  26472. * @param name defines the bone name
  26473. * @param skeleton defines the parent skeleton
  26474. * @param parentBone defines the parent (can be null if the bone is the root)
  26475. * @param localMatrix defines the local matrix
  26476. * @param restPose defines the rest pose matrix
  26477. * @param baseMatrix defines the base matrix
  26478. * @param index defines index of the bone in the hierarchy
  26479. */
  26480. constructor(
  26481. /**
  26482. * defines the bone name
  26483. */
  26484. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26485. /**
  26486. * Gets the current object class name.
  26487. * @return the class name
  26488. */
  26489. getClassName(): string;
  26490. /**
  26491. * Gets the parent skeleton
  26492. * @returns a skeleton
  26493. */
  26494. getSkeleton(): Skeleton;
  26495. /**
  26496. * Gets parent bone
  26497. * @returns a bone or null if the bone is the root of the bone hierarchy
  26498. */
  26499. getParent(): Nullable<Bone>;
  26500. /**
  26501. * Returns an array containing the root bones
  26502. * @returns an array containing the root bones
  26503. */
  26504. getChildren(): Array<Bone>;
  26505. /**
  26506. * Gets the node index in matrix array generated for rendering
  26507. * @returns the node index
  26508. */
  26509. getIndex(): number;
  26510. /**
  26511. * Sets the parent bone
  26512. * @param parent defines the parent (can be null if the bone is the root)
  26513. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26514. */
  26515. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26516. /**
  26517. * Gets the local matrix
  26518. * @returns a matrix
  26519. */
  26520. getLocalMatrix(): Matrix;
  26521. /**
  26522. * Gets the base matrix (initial matrix which remains unchanged)
  26523. * @returns a matrix
  26524. */
  26525. getBaseMatrix(): Matrix;
  26526. /**
  26527. * Gets the rest pose matrix
  26528. * @returns a matrix
  26529. */
  26530. getRestPose(): Matrix;
  26531. /**
  26532. * Sets the rest pose matrix
  26533. * @param matrix the local-space rest pose to set for this bone
  26534. */
  26535. setRestPose(matrix: Matrix): void;
  26536. /**
  26537. * Gets the bind pose matrix
  26538. * @returns the bind pose matrix
  26539. */
  26540. getBindPose(): Matrix;
  26541. /**
  26542. * Sets the bind pose matrix
  26543. * @param matrix the local-space bind pose to set for this bone
  26544. */
  26545. setBindPose(matrix: Matrix): void;
  26546. /**
  26547. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26548. */
  26549. getWorldMatrix(): Matrix;
  26550. /**
  26551. * Sets the local matrix to rest pose matrix
  26552. */
  26553. returnToRest(): void;
  26554. /**
  26555. * Gets the inverse of the absolute transform matrix.
  26556. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26557. * @returns a matrix
  26558. */
  26559. getInvertedAbsoluteTransform(): Matrix;
  26560. /**
  26561. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26562. * @returns a matrix
  26563. */
  26564. getAbsoluteTransform(): Matrix;
  26565. /**
  26566. * Links with the given transform node.
  26567. * The local matrix of this bone is copied from the transform node every frame.
  26568. * @param transformNode defines the transform node to link to
  26569. */
  26570. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26571. /**
  26572. * Gets the node used to drive the bone's transformation
  26573. * @returns a transform node or null
  26574. */
  26575. getTransformNode(): Nullable<TransformNode>;
  26576. /** Gets or sets current position (in local space) */
  26577. get position(): Vector3;
  26578. set position(newPosition: Vector3);
  26579. /** Gets or sets current rotation (in local space) */
  26580. get rotation(): Vector3;
  26581. set rotation(newRotation: Vector3);
  26582. /** Gets or sets current rotation quaternion (in local space) */
  26583. get rotationQuaternion(): Quaternion;
  26584. set rotationQuaternion(newRotation: Quaternion);
  26585. /** Gets or sets current scaling (in local space) */
  26586. get scaling(): Vector3;
  26587. set scaling(newScaling: Vector3);
  26588. /**
  26589. * Gets the animation properties override
  26590. */
  26591. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26592. private _decompose;
  26593. private _compose;
  26594. /**
  26595. * Update the base and local matrices
  26596. * @param matrix defines the new base or local matrix
  26597. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26598. * @param updateLocalMatrix defines if the local matrix should be updated
  26599. */
  26600. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26601. /** @hidden */
  26602. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26603. /**
  26604. * Flag the bone as dirty (Forcing it to update everything)
  26605. */
  26606. markAsDirty(): void;
  26607. /** @hidden */
  26608. _markAsDirtyAndCompose(): void;
  26609. private _markAsDirtyAndDecompose;
  26610. /**
  26611. * Translate the bone in local or world space
  26612. * @param vec The amount to translate the bone
  26613. * @param space The space that the translation is in
  26614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26615. */
  26616. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26617. /**
  26618. * Set the position of the bone in local or world space
  26619. * @param position The position to set the bone
  26620. * @param space The space that the position is in
  26621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26622. */
  26623. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26624. /**
  26625. * Set the absolute position of the bone (world space)
  26626. * @param position The position to set the bone
  26627. * @param mesh The mesh that this bone is attached to
  26628. */
  26629. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26630. /**
  26631. * Scale the bone on the x, y and z axes (in local space)
  26632. * @param x The amount to scale the bone on the x axis
  26633. * @param y The amount to scale the bone on the y axis
  26634. * @param z The amount to scale the bone on the z axis
  26635. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26636. */
  26637. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26638. /**
  26639. * Set the bone scaling in local space
  26640. * @param scale defines the scaling vector
  26641. */
  26642. setScale(scale: Vector3): void;
  26643. /**
  26644. * Gets the current scaling in local space
  26645. * @returns the current scaling vector
  26646. */
  26647. getScale(): Vector3;
  26648. /**
  26649. * Gets the current scaling in local space and stores it in a target vector
  26650. * @param result defines the target vector
  26651. */
  26652. getScaleToRef(result: Vector3): void;
  26653. /**
  26654. * Set the yaw, pitch, and roll of the bone in local or world space
  26655. * @param yaw The rotation of the bone on the y axis
  26656. * @param pitch The rotation of the bone on the x axis
  26657. * @param roll The rotation of the bone on the z axis
  26658. * @param space The space that the axes of rotation are in
  26659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26660. */
  26661. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26662. /**
  26663. * Add a rotation to the bone on an axis in local or world space
  26664. * @param axis The axis to rotate the bone on
  26665. * @param amount The amount to rotate the bone
  26666. * @param space The space that the axis is in
  26667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26668. */
  26669. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26670. /**
  26671. * Set the rotation of the bone to a particular axis angle in local or world space
  26672. * @param axis The axis to rotate the bone on
  26673. * @param angle The angle that the bone should be rotated to
  26674. * @param space The space that the axis is in
  26675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26676. */
  26677. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26678. /**
  26679. * Set the euler rotation of the bone in local or world space
  26680. * @param rotation The euler rotation that the bone should be set to
  26681. * @param space The space that the rotation is in
  26682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26683. */
  26684. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26685. /**
  26686. * Set the quaternion rotation of the bone in local or world space
  26687. * @param quat The quaternion rotation that the bone should be set to
  26688. * @param space The space that the rotation is in
  26689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26690. */
  26691. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26692. /**
  26693. * Set the rotation matrix of the bone in local or world space
  26694. * @param rotMat The rotation matrix that the bone should be set to
  26695. * @param space The space that the rotation is in
  26696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26697. */
  26698. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26699. private _rotateWithMatrix;
  26700. private _getNegativeRotationToRef;
  26701. /**
  26702. * Get the position of the bone in local or world space
  26703. * @param space The space that the returned position is in
  26704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26705. * @returns The position of the bone
  26706. */
  26707. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26708. /**
  26709. * Copy the position of the bone to a vector3 in local or world space
  26710. * @param space The space that the returned position is in
  26711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26712. * @param result The vector3 to copy the position to
  26713. */
  26714. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26715. /**
  26716. * Get the absolute position of the bone (world space)
  26717. * @param mesh The mesh that this bone is attached to
  26718. * @returns The absolute position of the bone
  26719. */
  26720. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26721. /**
  26722. * Copy the absolute position of the bone (world space) to the result param
  26723. * @param mesh The mesh that this bone is attached to
  26724. * @param result The vector3 to copy the absolute position to
  26725. */
  26726. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26727. /**
  26728. * Compute the absolute transforms of this bone and its children
  26729. */
  26730. computeAbsoluteTransforms(): void;
  26731. /**
  26732. * Get the world direction from an axis that is in the local space of the bone
  26733. * @param localAxis The local direction that is used to compute the world direction
  26734. * @param mesh The mesh that this bone is attached to
  26735. * @returns The world direction
  26736. */
  26737. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26738. /**
  26739. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26740. * @param localAxis The local direction that is used to compute the world direction
  26741. * @param mesh The mesh that this bone is attached to
  26742. * @param result The vector3 that the world direction will be copied to
  26743. */
  26744. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26745. /**
  26746. * Get the euler rotation of the bone in local or world space
  26747. * @param space The space that the rotation should be in
  26748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26749. * @returns The euler rotation
  26750. */
  26751. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26752. /**
  26753. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26754. * @param space The space that the rotation should be in
  26755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26756. * @param result The vector3 that the rotation should be copied to
  26757. */
  26758. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26759. /**
  26760. * Get the quaternion rotation of the bone in either local or world space
  26761. * @param space The space that the rotation should be in
  26762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26763. * @returns The quaternion rotation
  26764. */
  26765. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26766. /**
  26767. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26768. * @param space The space that the rotation should be in
  26769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26770. * @param result The quaternion that the rotation should be copied to
  26771. */
  26772. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26773. /**
  26774. * Get the rotation matrix of the bone in local or world space
  26775. * @param space The space that the rotation should be in
  26776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26777. * @returns The rotation matrix
  26778. */
  26779. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26780. /**
  26781. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26782. * @param space The space that the rotation should be in
  26783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26784. * @param result The quaternion that the rotation should be copied to
  26785. */
  26786. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26787. /**
  26788. * Get the world position of a point that is in the local space of the bone
  26789. * @param position The local position
  26790. * @param mesh The mesh that this bone is attached to
  26791. * @returns The world position
  26792. */
  26793. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26794. /**
  26795. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26796. * @param position The local position
  26797. * @param mesh The mesh that this bone is attached to
  26798. * @param result The vector3 that the world position should be copied to
  26799. */
  26800. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26801. /**
  26802. * Get the local position of a point that is in world space
  26803. * @param position The world position
  26804. * @param mesh The mesh that this bone is attached to
  26805. * @returns The local position
  26806. */
  26807. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26808. /**
  26809. * Get the local position of a point that is in world space and copy it to the result param
  26810. * @param position The world position
  26811. * @param mesh The mesh that this bone is attached to
  26812. * @param result The vector3 that the local position should be copied to
  26813. */
  26814. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26815. /**
  26816. * Set the current local matrix as the restPose for this bone.
  26817. */
  26818. setCurrentPoseAsRest(): void;
  26819. }
  26820. }
  26821. declare module BABYLON {
  26822. /**
  26823. * 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.
  26824. * @see https://doc.babylonjs.com/how_to/transformnode
  26825. */
  26826. export class TransformNode extends Node {
  26827. /**
  26828. * Object will not rotate to face the camera
  26829. */
  26830. static BILLBOARDMODE_NONE: number;
  26831. /**
  26832. * Object will rotate to face the camera but only on the x axis
  26833. */
  26834. static BILLBOARDMODE_X: number;
  26835. /**
  26836. * Object will rotate to face the camera but only on the y axis
  26837. */
  26838. static BILLBOARDMODE_Y: number;
  26839. /**
  26840. * Object will rotate to face the camera but only on the z axis
  26841. */
  26842. static BILLBOARDMODE_Z: number;
  26843. /**
  26844. * Object will rotate to face the camera
  26845. */
  26846. static BILLBOARDMODE_ALL: number;
  26847. /**
  26848. * Object will rotate to face the camera's position instead of orientation
  26849. */
  26850. static BILLBOARDMODE_USE_POSITION: number;
  26851. private static _TmpRotation;
  26852. private static _TmpScaling;
  26853. private static _TmpTranslation;
  26854. private _forward;
  26855. private _forwardInverted;
  26856. private _up;
  26857. private _right;
  26858. private _rightInverted;
  26859. private _position;
  26860. private _rotation;
  26861. private _rotationQuaternion;
  26862. protected _scaling: Vector3;
  26863. protected _isDirty: boolean;
  26864. private _transformToBoneReferal;
  26865. private _isAbsoluteSynced;
  26866. private _billboardMode;
  26867. /**
  26868. * Gets or sets the billboard mode. Default is 0.
  26869. *
  26870. * | Value | Type | Description |
  26871. * | --- | --- | --- |
  26872. * | 0 | BILLBOARDMODE_NONE | |
  26873. * | 1 | BILLBOARDMODE_X | |
  26874. * | 2 | BILLBOARDMODE_Y | |
  26875. * | 4 | BILLBOARDMODE_Z | |
  26876. * | 7 | BILLBOARDMODE_ALL | |
  26877. *
  26878. */
  26879. get billboardMode(): number;
  26880. set billboardMode(value: number);
  26881. private _preserveParentRotationForBillboard;
  26882. /**
  26883. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26884. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26885. */
  26886. get preserveParentRotationForBillboard(): boolean;
  26887. set preserveParentRotationForBillboard(value: boolean);
  26888. /**
  26889. * 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
  26890. */
  26891. scalingDeterminant: number;
  26892. private _infiniteDistance;
  26893. /**
  26894. * Gets or sets the distance of the object to max, often used by skybox
  26895. */
  26896. get infiniteDistance(): boolean;
  26897. set infiniteDistance(value: boolean);
  26898. /**
  26899. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26900. * By default the system will update normals to compensate
  26901. */
  26902. ignoreNonUniformScaling: boolean;
  26903. /**
  26904. * 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
  26905. */
  26906. reIntegrateRotationIntoRotationQuaternion: boolean;
  26907. /** @hidden */
  26908. _poseMatrix: Nullable<Matrix>;
  26909. /** @hidden */
  26910. _localMatrix: Matrix;
  26911. private _usePivotMatrix;
  26912. private _absolutePosition;
  26913. private _absoluteScaling;
  26914. private _absoluteRotationQuaternion;
  26915. private _pivotMatrix;
  26916. private _pivotMatrixInverse;
  26917. /** @hidden */
  26918. _postMultiplyPivotMatrix: boolean;
  26919. protected _isWorldMatrixFrozen: boolean;
  26920. /** @hidden */
  26921. _indexInSceneTransformNodesArray: number;
  26922. /**
  26923. * An event triggered after the world matrix is updated
  26924. */
  26925. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26926. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26927. /**
  26928. * Gets a string identifying the name of the class
  26929. * @returns "TransformNode" string
  26930. */
  26931. getClassName(): string;
  26932. /**
  26933. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26934. */
  26935. get position(): Vector3;
  26936. set position(newPosition: Vector3);
  26937. /**
  26938. * 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)).
  26939. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26940. */
  26941. get rotation(): Vector3;
  26942. set rotation(newRotation: Vector3);
  26943. /**
  26944. * 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)).
  26945. */
  26946. get scaling(): Vector3;
  26947. set scaling(newScaling: Vector3);
  26948. /**
  26949. * 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).
  26950. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26951. */
  26952. get rotationQuaternion(): Nullable<Quaternion>;
  26953. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26954. /**
  26955. * The forward direction of that transform in world space.
  26956. */
  26957. get forward(): Vector3;
  26958. /**
  26959. * The up direction of that transform in world space.
  26960. */
  26961. get up(): Vector3;
  26962. /**
  26963. * The right direction of that transform in world space.
  26964. */
  26965. get right(): Vector3;
  26966. /**
  26967. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26968. * @param matrix the matrix to copy the pose from
  26969. * @returns this TransformNode.
  26970. */
  26971. updatePoseMatrix(matrix: Matrix): TransformNode;
  26972. /**
  26973. * Returns the mesh Pose matrix.
  26974. * @returns the pose matrix
  26975. */
  26976. getPoseMatrix(): Matrix;
  26977. /** @hidden */
  26978. _isSynchronized(): boolean;
  26979. /** @hidden */
  26980. _initCache(): void;
  26981. /**
  26982. * Flag the transform node as dirty (Forcing it to update everything)
  26983. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26984. * @returns this transform node
  26985. */
  26986. markAsDirty(property: string): TransformNode;
  26987. /**
  26988. * Returns the current mesh absolute position.
  26989. * Returns a Vector3.
  26990. */
  26991. get absolutePosition(): Vector3;
  26992. /**
  26993. * Returns the current mesh absolute scaling.
  26994. * Returns a Vector3.
  26995. */
  26996. get absoluteScaling(): Vector3;
  26997. /**
  26998. * Returns the current mesh absolute rotation.
  26999. * Returns a Quaternion.
  27000. */
  27001. get absoluteRotationQuaternion(): Quaternion;
  27002. /**
  27003. * Sets a new matrix to apply before all other transformation
  27004. * @param matrix defines the transform matrix
  27005. * @returns the current TransformNode
  27006. */
  27007. setPreTransformMatrix(matrix: Matrix): TransformNode;
  27008. /**
  27009. * Sets a new pivot matrix to the current node
  27010. * @param matrix defines the new pivot matrix to use
  27011. * @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
  27012. * @returns the current TransformNode
  27013. */
  27014. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27015. /**
  27016. * Returns the mesh pivot matrix.
  27017. * Default : Identity.
  27018. * @returns the matrix
  27019. */
  27020. getPivotMatrix(): Matrix;
  27021. /**
  27022. * Instantiate (when possible) or clone that node with its hierarchy
  27023. * @param newParent defines the new parent to use for the instance (or clone)
  27024. * @param options defines options to configure how copy is done
  27025. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27026. * @returns an instance (or a clone) of the current node with its hiearchy
  27027. */
  27028. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27029. doNotInstantiate: boolean;
  27030. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27031. /**
  27032. * Prevents the World matrix to be computed any longer
  27033. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27034. * @returns the TransformNode.
  27035. */
  27036. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27037. /**
  27038. * Allows back the World matrix computation.
  27039. * @returns the TransformNode.
  27040. */
  27041. unfreezeWorldMatrix(): this;
  27042. /**
  27043. * True if the World matrix has been frozen.
  27044. */
  27045. get isWorldMatrixFrozen(): boolean;
  27046. /**
  27047. * Returns the mesh absolute position in the World.
  27048. * @returns a Vector3.
  27049. */
  27050. getAbsolutePosition(): Vector3;
  27051. /**
  27052. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27053. * @param absolutePosition the absolute position to set
  27054. * @returns the TransformNode.
  27055. */
  27056. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27057. /**
  27058. * Sets the mesh position in its local space.
  27059. * @param vector3 the position to set in localspace
  27060. * @returns the TransformNode.
  27061. */
  27062. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27063. /**
  27064. * Returns the mesh position in the local space from the current World matrix values.
  27065. * @returns a new Vector3.
  27066. */
  27067. getPositionExpressedInLocalSpace(): Vector3;
  27068. /**
  27069. * Translates the mesh along the passed Vector3 in its local space.
  27070. * @param vector3 the distance to translate in localspace
  27071. * @returns the TransformNode.
  27072. */
  27073. locallyTranslate(vector3: Vector3): TransformNode;
  27074. private static _lookAtVectorCache;
  27075. /**
  27076. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27077. * @param targetPoint the position (must be in same space as current mesh) to look at
  27078. * @param yawCor optional yaw (y-axis) correction in radians
  27079. * @param pitchCor optional pitch (x-axis) correction in radians
  27080. * @param rollCor optional roll (z-axis) correction in radians
  27081. * @param space the chosen space of the target
  27082. * @returns the TransformNode.
  27083. */
  27084. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27085. /**
  27086. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27087. * This Vector3 is expressed in the World space.
  27088. * @param localAxis axis to rotate
  27089. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27090. */
  27091. getDirection(localAxis: Vector3): Vector3;
  27092. /**
  27093. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27094. * localAxis is expressed in the mesh local space.
  27095. * result is computed in the Wordl space from the mesh World matrix.
  27096. * @param localAxis axis to rotate
  27097. * @param result the resulting transformnode
  27098. * @returns this TransformNode.
  27099. */
  27100. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27101. /**
  27102. * Sets this transform node rotation to the given local axis.
  27103. * @param localAxis the axis in local space
  27104. * @param yawCor optional yaw (y-axis) correction in radians
  27105. * @param pitchCor optional pitch (x-axis) correction in radians
  27106. * @param rollCor optional roll (z-axis) correction in radians
  27107. * @returns this TransformNode
  27108. */
  27109. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27110. /**
  27111. * Sets a new pivot point to the current node
  27112. * @param point defines the new pivot point to use
  27113. * @param space defines if the point is in world or local space (local by default)
  27114. * @returns the current TransformNode
  27115. */
  27116. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27117. /**
  27118. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27119. * @returns the pivot point
  27120. */
  27121. getPivotPoint(): Vector3;
  27122. /**
  27123. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27124. * @param result the vector3 to store the result
  27125. * @returns this TransformNode.
  27126. */
  27127. getPivotPointToRef(result: Vector3): TransformNode;
  27128. /**
  27129. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27130. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27131. */
  27132. getAbsolutePivotPoint(): Vector3;
  27133. /**
  27134. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27135. * @param result vector3 to store the result
  27136. * @returns this TransformNode.
  27137. */
  27138. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27139. /**
  27140. * Defines the passed node as the parent of the current node.
  27141. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27142. * @see https://doc.babylonjs.com/how_to/parenting
  27143. * @param node the node ot set as the parent
  27144. * @returns this TransformNode.
  27145. */
  27146. setParent(node: Nullable<Node>): TransformNode;
  27147. private _nonUniformScaling;
  27148. /**
  27149. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27150. */
  27151. get nonUniformScaling(): boolean;
  27152. /** @hidden */
  27153. _updateNonUniformScalingState(value: boolean): boolean;
  27154. /**
  27155. * Attach the current TransformNode to another TransformNode associated with a bone
  27156. * @param bone Bone affecting the TransformNode
  27157. * @param affectedTransformNode TransformNode associated with the bone
  27158. * @returns this object
  27159. */
  27160. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27161. /**
  27162. * Detach the transform node if its associated with a bone
  27163. * @returns this object
  27164. */
  27165. detachFromBone(): TransformNode;
  27166. private static _rotationAxisCache;
  27167. /**
  27168. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27169. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27170. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27171. * The passed axis is also normalized.
  27172. * @param axis the axis to rotate around
  27173. * @param amount the amount to rotate in radians
  27174. * @param space Space to rotate in (Default: local)
  27175. * @returns the TransformNode.
  27176. */
  27177. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27178. /**
  27179. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27180. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27181. * The passed axis is also normalized. .
  27182. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27183. * @param point the point to rotate around
  27184. * @param axis the axis to rotate around
  27185. * @param amount the amount to rotate in radians
  27186. * @returns the TransformNode
  27187. */
  27188. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27189. /**
  27190. * Translates the mesh along the axis vector for the passed distance in the given space.
  27191. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27192. * @param axis the axis to translate in
  27193. * @param distance the distance to translate
  27194. * @param space Space to rotate in (Default: local)
  27195. * @returns the TransformNode.
  27196. */
  27197. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27198. /**
  27199. * Adds a rotation step to the mesh current rotation.
  27200. * x, y, z are Euler angles expressed in radians.
  27201. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27202. * This means this rotation is made in the mesh local space only.
  27203. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27204. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27205. * ```javascript
  27206. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27207. * ```
  27208. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27209. * 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.
  27210. * @param x Rotation to add
  27211. * @param y Rotation to add
  27212. * @param z Rotation to add
  27213. * @returns the TransformNode.
  27214. */
  27215. addRotation(x: number, y: number, z: number): TransformNode;
  27216. /**
  27217. * @hidden
  27218. */
  27219. protected _getEffectiveParent(): Nullable<Node>;
  27220. /**
  27221. * Computes the world matrix of the node
  27222. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27223. * @returns the world matrix
  27224. */
  27225. computeWorldMatrix(force?: boolean): Matrix;
  27226. /**
  27227. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27228. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27229. */
  27230. resetLocalMatrix(independentOfChildren?: boolean): void;
  27231. protected _afterComputeWorldMatrix(): void;
  27232. /**
  27233. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27234. * @param func callback function to add
  27235. *
  27236. * @returns the TransformNode.
  27237. */
  27238. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27239. /**
  27240. * Removes a registered callback function.
  27241. * @param func callback function to remove
  27242. * @returns the TransformNode.
  27243. */
  27244. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27245. /**
  27246. * Gets the position of the current mesh in camera space
  27247. * @param camera defines the camera to use
  27248. * @returns a position
  27249. */
  27250. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27251. /**
  27252. * Returns the distance from the mesh to the active camera
  27253. * @param camera defines the camera to use
  27254. * @returns the distance
  27255. */
  27256. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27257. /**
  27258. * Clone the current transform node
  27259. * @param name Name of the new clone
  27260. * @param newParent New parent for the clone
  27261. * @param doNotCloneChildren Do not clone children hierarchy
  27262. * @returns the new transform node
  27263. */
  27264. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27265. /**
  27266. * Serializes the objects information.
  27267. * @param currentSerializationObject defines the object to serialize in
  27268. * @returns the serialized object
  27269. */
  27270. serialize(currentSerializationObject?: any): any;
  27271. /**
  27272. * Returns a new TransformNode object parsed from the source provided.
  27273. * @param parsedTransformNode is the source.
  27274. * @param scene the scene the object belongs to
  27275. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27276. * @returns a new TransformNode object parsed from the source provided.
  27277. */
  27278. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27279. /**
  27280. * Get all child-transformNodes of this node
  27281. * @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
  27282. * @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
  27283. * @returns an array of TransformNode
  27284. */
  27285. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27286. /**
  27287. * Releases resources associated with this transform node.
  27288. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27289. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27290. */
  27291. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27292. /**
  27293. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27294. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27295. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27296. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27297. * @returns the current mesh
  27298. */
  27299. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27300. private _syncAbsoluteScalingAndRotation;
  27301. }
  27302. }
  27303. declare module BABYLON {
  27304. /**
  27305. * Defines the types of pose enabled controllers that are supported
  27306. */
  27307. export enum PoseEnabledControllerType {
  27308. /**
  27309. * HTC Vive
  27310. */
  27311. VIVE = 0,
  27312. /**
  27313. * Oculus Rift
  27314. */
  27315. OCULUS = 1,
  27316. /**
  27317. * Windows mixed reality
  27318. */
  27319. WINDOWS = 2,
  27320. /**
  27321. * Samsung gear VR
  27322. */
  27323. GEAR_VR = 3,
  27324. /**
  27325. * Google Daydream
  27326. */
  27327. DAYDREAM = 4,
  27328. /**
  27329. * Generic
  27330. */
  27331. GENERIC = 5
  27332. }
  27333. /**
  27334. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27335. */
  27336. export interface MutableGamepadButton {
  27337. /**
  27338. * Value of the button/trigger
  27339. */
  27340. value: number;
  27341. /**
  27342. * If the button/trigger is currently touched
  27343. */
  27344. touched: boolean;
  27345. /**
  27346. * If the button/trigger is currently pressed
  27347. */
  27348. pressed: boolean;
  27349. }
  27350. /**
  27351. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27352. * @hidden
  27353. */
  27354. export interface ExtendedGamepadButton extends GamepadButton {
  27355. /**
  27356. * If the button/trigger is currently pressed
  27357. */
  27358. readonly pressed: boolean;
  27359. /**
  27360. * If the button/trigger is currently touched
  27361. */
  27362. readonly touched: boolean;
  27363. /**
  27364. * Value of the button/trigger
  27365. */
  27366. readonly value: number;
  27367. }
  27368. /** @hidden */
  27369. export interface _GamePadFactory {
  27370. /**
  27371. * Returns whether or not the current gamepad can be created for this type of controller.
  27372. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27373. * @returns true if it can be created, otherwise false
  27374. */
  27375. canCreate(gamepadInfo: any): boolean;
  27376. /**
  27377. * Creates a new instance of the Gamepad.
  27378. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27379. * @returns the new gamepad instance
  27380. */
  27381. create(gamepadInfo: any): Gamepad;
  27382. }
  27383. /**
  27384. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27385. */
  27386. export class PoseEnabledControllerHelper {
  27387. /** @hidden */
  27388. static _ControllerFactories: _GamePadFactory[];
  27389. /** @hidden */
  27390. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27391. /**
  27392. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27393. * @param vrGamepad the gamepad to initialized
  27394. * @returns a vr controller of the type the gamepad identified as
  27395. */
  27396. static InitiateController(vrGamepad: any): Gamepad;
  27397. }
  27398. /**
  27399. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27400. */
  27401. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27402. /**
  27403. * If the controller is used in a webXR session
  27404. */
  27405. isXR: boolean;
  27406. private _deviceRoomPosition;
  27407. private _deviceRoomRotationQuaternion;
  27408. /**
  27409. * The device position in babylon space
  27410. */
  27411. devicePosition: Vector3;
  27412. /**
  27413. * The device rotation in babylon space
  27414. */
  27415. deviceRotationQuaternion: Quaternion;
  27416. /**
  27417. * The scale factor of the device in babylon space
  27418. */
  27419. deviceScaleFactor: number;
  27420. /**
  27421. * (Likely devicePosition should be used instead) The device position in its room space
  27422. */
  27423. position: Vector3;
  27424. /**
  27425. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27426. */
  27427. rotationQuaternion: Quaternion;
  27428. /**
  27429. * The type of controller (Eg. Windows mixed reality)
  27430. */
  27431. controllerType: PoseEnabledControllerType;
  27432. protected _calculatedPosition: Vector3;
  27433. private _calculatedRotation;
  27434. /**
  27435. * The raw pose from the device
  27436. */
  27437. rawPose: DevicePose;
  27438. private _trackPosition;
  27439. private _maxRotationDistFromHeadset;
  27440. private _draggedRoomRotation;
  27441. /**
  27442. * @hidden
  27443. */
  27444. _disableTrackPosition(fixedPosition: Vector3): void;
  27445. /**
  27446. * Internal, the mesh attached to the controller
  27447. * @hidden
  27448. */
  27449. _mesh: Nullable<AbstractMesh>;
  27450. private _poseControlledCamera;
  27451. private _leftHandSystemQuaternion;
  27452. /**
  27453. * Internal, matrix used to convert room space to babylon space
  27454. * @hidden
  27455. */
  27456. _deviceToWorld: Matrix;
  27457. /**
  27458. * Node to be used when casting a ray from the controller
  27459. * @hidden
  27460. */
  27461. _pointingPoseNode: Nullable<TransformNode>;
  27462. /**
  27463. * Name of the child mesh that can be used to cast a ray from the controller
  27464. */
  27465. static readonly POINTING_POSE: string;
  27466. /**
  27467. * Creates a new PoseEnabledController from a gamepad
  27468. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27469. */
  27470. constructor(browserGamepad: any);
  27471. private _workingMatrix;
  27472. /**
  27473. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27474. */
  27475. update(): void;
  27476. /**
  27477. * Updates only the pose device and mesh without doing any button event checking
  27478. */
  27479. protected _updatePoseAndMesh(): void;
  27480. /**
  27481. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27482. * @param poseData raw pose fromthe device
  27483. */
  27484. updateFromDevice(poseData: DevicePose): void;
  27485. /**
  27486. * @hidden
  27487. */
  27488. _meshAttachedObservable: Observable<AbstractMesh>;
  27489. /**
  27490. * Attaches a mesh to the controller
  27491. * @param mesh the mesh to be attached
  27492. */
  27493. attachToMesh(mesh: AbstractMesh): void;
  27494. /**
  27495. * Attaches the controllers mesh to a camera
  27496. * @param camera the camera the mesh should be attached to
  27497. */
  27498. attachToPoseControlledCamera(camera: TargetCamera): void;
  27499. /**
  27500. * Disposes of the controller
  27501. */
  27502. dispose(): void;
  27503. /**
  27504. * The mesh that is attached to the controller
  27505. */
  27506. get mesh(): Nullable<AbstractMesh>;
  27507. /**
  27508. * Gets the ray of the controller in the direction the controller is pointing
  27509. * @param length the length the resulting ray should be
  27510. * @returns a ray in the direction the controller is pointing
  27511. */
  27512. getForwardRay(length?: number): Ray;
  27513. }
  27514. }
  27515. declare module BABYLON {
  27516. /**
  27517. * Defines the WebVRController object that represents controllers tracked in 3D space
  27518. */
  27519. export abstract class WebVRController extends PoseEnabledController {
  27520. /**
  27521. * Internal, the default controller model for the controller
  27522. */
  27523. protected _defaultModel: Nullable<AbstractMesh>;
  27524. /**
  27525. * Fired when the trigger state has changed
  27526. */
  27527. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27528. /**
  27529. * Fired when the main button state has changed
  27530. */
  27531. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27532. /**
  27533. * Fired when the secondary button state has changed
  27534. */
  27535. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27536. /**
  27537. * Fired when the pad state has changed
  27538. */
  27539. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27540. /**
  27541. * Fired when controllers stick values have changed
  27542. */
  27543. onPadValuesChangedObservable: Observable<StickValues>;
  27544. /**
  27545. * Array of button availible on the controller
  27546. */
  27547. protected _buttons: Array<MutableGamepadButton>;
  27548. private _onButtonStateChange;
  27549. /**
  27550. * Fired when a controller button's state has changed
  27551. * @param callback the callback containing the button that was modified
  27552. */
  27553. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27554. /**
  27555. * X and Y axis corresponding to the controllers joystick
  27556. */
  27557. pad: StickValues;
  27558. /**
  27559. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27560. */
  27561. hand: string;
  27562. /**
  27563. * The default controller model for the controller
  27564. */
  27565. get defaultModel(): Nullable<AbstractMesh>;
  27566. /**
  27567. * Creates a new WebVRController from a gamepad
  27568. * @param vrGamepad the gamepad that the WebVRController should be created from
  27569. */
  27570. constructor(vrGamepad: any);
  27571. /**
  27572. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27573. */
  27574. update(): void;
  27575. /**
  27576. * Function to be called when a button is modified
  27577. */
  27578. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27579. /**
  27580. * Loads a mesh and attaches it to the controller
  27581. * @param scene the scene the mesh should be added to
  27582. * @param meshLoaded callback for when the mesh has been loaded
  27583. */
  27584. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27585. private _setButtonValue;
  27586. private _changes;
  27587. private _checkChanges;
  27588. /**
  27589. * Disposes of th webVRCOntroller
  27590. */
  27591. dispose(): void;
  27592. }
  27593. }
  27594. declare module BABYLON {
  27595. /**
  27596. * The HemisphericLight simulates the ambient environment light,
  27597. * so the passed direction is the light reflection direction, not the incoming direction.
  27598. */
  27599. export class HemisphericLight extends Light {
  27600. /**
  27601. * The groundColor is the light in the opposite direction to the one specified during creation.
  27602. * 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.
  27603. */
  27604. groundColor: Color3;
  27605. /**
  27606. * The light reflection direction, not the incoming direction.
  27607. */
  27608. direction: Vector3;
  27609. /**
  27610. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27611. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27612. * The HemisphericLight can't cast shadows.
  27613. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27614. * @param name The friendly name of the light
  27615. * @param direction The direction of the light reflection
  27616. * @param scene The scene the light belongs to
  27617. */
  27618. constructor(name: string, direction: Vector3, scene: Scene);
  27619. protected _buildUniformLayout(): void;
  27620. /**
  27621. * Returns the string "HemisphericLight".
  27622. * @return The class name
  27623. */
  27624. getClassName(): string;
  27625. /**
  27626. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27627. * Returns the updated direction.
  27628. * @param target The target the direction should point to
  27629. * @return The computed direction
  27630. */
  27631. setDirectionToTarget(target: Vector3): Vector3;
  27632. /**
  27633. * Returns the shadow generator associated to the light.
  27634. * @returns Always null for hemispheric lights because it does not support shadows.
  27635. */
  27636. getShadowGenerator(): Nullable<IShadowGenerator>;
  27637. /**
  27638. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27639. * @param effect The effect to update
  27640. * @param lightIndex The index of the light in the effect to update
  27641. * @returns The hemispheric light
  27642. */
  27643. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27644. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27645. /**
  27646. * Computes the world matrix of the node
  27647. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27648. * @param useWasUpdatedFlag defines a reserved property
  27649. * @returns the world matrix
  27650. */
  27651. computeWorldMatrix(): Matrix;
  27652. /**
  27653. * Returns the integer 3.
  27654. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27655. */
  27656. getTypeID(): number;
  27657. /**
  27658. * Prepares the list of defines specific to the light type.
  27659. * @param defines the list of defines
  27660. * @param lightIndex defines the index of the light for the effect
  27661. */
  27662. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27663. }
  27664. }
  27665. declare module BABYLON {
  27666. /** @hidden */
  27667. export var vrMultiviewToSingleviewPixelShader: {
  27668. name: string;
  27669. shader: string;
  27670. };
  27671. }
  27672. declare module BABYLON {
  27673. /**
  27674. * Renders to multiple views with a single draw call
  27675. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27676. */
  27677. export class MultiviewRenderTarget extends RenderTargetTexture {
  27678. /**
  27679. * Creates a multiview render target
  27680. * @param scene scene used with the render target
  27681. * @param size the size of the render target (used for each view)
  27682. */
  27683. constructor(scene: Scene, size?: number | {
  27684. width: number;
  27685. height: number;
  27686. } | {
  27687. ratio: number;
  27688. });
  27689. /**
  27690. * @hidden
  27691. * @param faceIndex the face index, if its a cube texture
  27692. */
  27693. _bindFrameBuffer(faceIndex?: number): void;
  27694. /**
  27695. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27696. * @returns the view count
  27697. */
  27698. getViewCount(): number;
  27699. }
  27700. }
  27701. declare module BABYLON {
  27702. interface Engine {
  27703. /**
  27704. * Creates a new multiview render target
  27705. * @param width defines the width of the texture
  27706. * @param height defines the height of the texture
  27707. * @returns the created multiview texture
  27708. */
  27709. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27710. /**
  27711. * Binds a multiview framebuffer to be drawn to
  27712. * @param multiviewTexture texture to bind
  27713. */
  27714. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27715. }
  27716. interface Camera {
  27717. /**
  27718. * @hidden
  27719. * 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)
  27720. */
  27721. _useMultiviewToSingleView: boolean;
  27722. /**
  27723. * @hidden
  27724. * 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)
  27725. */
  27726. _multiviewTexture: Nullable<RenderTargetTexture>;
  27727. /**
  27728. * @hidden
  27729. * ensures the multiview texture of the camera exists and has the specified width/height
  27730. * @param width height to set on the multiview texture
  27731. * @param height width to set on the multiview texture
  27732. */
  27733. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27734. }
  27735. interface Scene {
  27736. /** @hidden */
  27737. _transformMatrixR: Matrix;
  27738. /** @hidden */
  27739. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27740. /** @hidden */
  27741. _createMultiviewUbo(): void;
  27742. /** @hidden */
  27743. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27744. /** @hidden */
  27745. _renderMultiviewToSingleView(camera: Camera): void;
  27746. }
  27747. }
  27748. declare module BABYLON {
  27749. /**
  27750. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27751. * This will not be used for webXR as it supports displaying texture arrays directly
  27752. */
  27753. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27754. /**
  27755. * Gets a string identifying the name of the class
  27756. * @returns "VRMultiviewToSingleviewPostProcess" string
  27757. */
  27758. getClassName(): string;
  27759. /**
  27760. * Initializes a VRMultiviewToSingleview
  27761. * @param name name of the post process
  27762. * @param camera camera to be applied to
  27763. * @param scaleFactor scaling factor to the size of the output texture
  27764. */
  27765. constructor(name: string, camera: Camera, scaleFactor: number);
  27766. }
  27767. }
  27768. declare module BABYLON {
  27769. /**
  27770. * Interface used to define additional presentation attributes
  27771. */
  27772. export interface IVRPresentationAttributes {
  27773. /**
  27774. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27775. */
  27776. highRefreshRate: boolean;
  27777. /**
  27778. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27779. */
  27780. foveationLevel: number;
  27781. }
  27782. interface Engine {
  27783. /** @hidden */
  27784. _vrDisplay: any;
  27785. /** @hidden */
  27786. _vrSupported: boolean;
  27787. /** @hidden */
  27788. _oldSize: Size;
  27789. /** @hidden */
  27790. _oldHardwareScaleFactor: number;
  27791. /** @hidden */
  27792. _vrExclusivePointerMode: boolean;
  27793. /** @hidden */
  27794. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27795. /** @hidden */
  27796. _onVRDisplayPointerRestricted: () => void;
  27797. /** @hidden */
  27798. _onVRDisplayPointerUnrestricted: () => void;
  27799. /** @hidden */
  27800. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27801. /** @hidden */
  27802. _onVrDisplayDisconnect: Nullable<() => void>;
  27803. /** @hidden */
  27804. _onVrDisplayPresentChange: Nullable<() => void>;
  27805. /**
  27806. * Observable signaled when VR display mode changes
  27807. */
  27808. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27809. /**
  27810. * Observable signaled when VR request present is complete
  27811. */
  27812. onVRRequestPresentComplete: Observable<boolean>;
  27813. /**
  27814. * Observable signaled when VR request present starts
  27815. */
  27816. onVRRequestPresentStart: Observable<Engine>;
  27817. /**
  27818. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27819. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27820. */
  27821. isInVRExclusivePointerMode: boolean;
  27822. /**
  27823. * Gets a boolean indicating if a webVR device was detected
  27824. * @returns true if a webVR device was detected
  27825. */
  27826. isVRDevicePresent(): boolean;
  27827. /**
  27828. * Gets the current webVR device
  27829. * @returns the current webVR device (or null)
  27830. */
  27831. getVRDevice(): any;
  27832. /**
  27833. * Initializes a webVR display and starts listening to display change events
  27834. * The onVRDisplayChangedObservable will be notified upon these changes
  27835. * @returns A promise containing a VRDisplay and if vr is supported
  27836. */
  27837. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27838. /** @hidden */
  27839. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27840. /**
  27841. * Gets or sets the presentation attributes used to configure VR rendering
  27842. */
  27843. vrPresentationAttributes?: IVRPresentationAttributes;
  27844. /**
  27845. * Call this function to switch to webVR mode
  27846. * Will do nothing if webVR is not supported or if there is no webVR device
  27847. * @param options the webvr options provided to the camera. mainly used for multiview
  27848. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27849. */
  27850. enableVR(options: WebVROptions): void;
  27851. /** @hidden */
  27852. _onVRFullScreenTriggered(): void;
  27853. }
  27854. }
  27855. declare module BABYLON {
  27856. /**
  27857. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27858. * IMPORTANT!! The data is right-hand data.
  27859. * @export
  27860. * @interface DevicePose
  27861. */
  27862. export interface DevicePose {
  27863. /**
  27864. * The position of the device, values in array are [x,y,z].
  27865. */
  27866. readonly position: Nullable<Float32Array>;
  27867. /**
  27868. * The linearVelocity of the device, values in array are [x,y,z].
  27869. */
  27870. readonly linearVelocity: Nullable<Float32Array>;
  27871. /**
  27872. * The linearAcceleration of the device, values in array are [x,y,z].
  27873. */
  27874. readonly linearAcceleration: Nullable<Float32Array>;
  27875. /**
  27876. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27877. */
  27878. readonly orientation: Nullable<Float32Array>;
  27879. /**
  27880. * The angularVelocity of the device, values in array are [x,y,z].
  27881. */
  27882. readonly angularVelocity: Nullable<Float32Array>;
  27883. /**
  27884. * The angularAcceleration of the device, values in array are [x,y,z].
  27885. */
  27886. readonly angularAcceleration: Nullable<Float32Array>;
  27887. }
  27888. /**
  27889. * Interface representing a pose controlled object in Babylon.
  27890. * A pose controlled object has both regular pose values as well as pose values
  27891. * from an external device such as a VR head mounted display
  27892. */
  27893. export interface PoseControlled {
  27894. /**
  27895. * The position of the object in babylon space.
  27896. */
  27897. position: Vector3;
  27898. /**
  27899. * The rotation quaternion of the object in babylon space.
  27900. */
  27901. rotationQuaternion: Quaternion;
  27902. /**
  27903. * The position of the device in babylon space.
  27904. */
  27905. devicePosition?: Vector3;
  27906. /**
  27907. * The rotation quaternion of the device in babylon space.
  27908. */
  27909. deviceRotationQuaternion: Quaternion;
  27910. /**
  27911. * The raw pose coming from the device.
  27912. */
  27913. rawPose: Nullable<DevicePose>;
  27914. /**
  27915. * The scale of the device to be used when translating from device space to babylon space.
  27916. */
  27917. deviceScaleFactor: number;
  27918. /**
  27919. * Updates the poseControlled values based on the input device pose.
  27920. * @param poseData the pose data to update the object with
  27921. */
  27922. updateFromDevice(poseData: DevicePose): void;
  27923. }
  27924. /**
  27925. * Set of options to customize the webVRCamera
  27926. */
  27927. export interface WebVROptions {
  27928. /**
  27929. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27930. */
  27931. trackPosition?: boolean;
  27932. /**
  27933. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27934. */
  27935. positionScale?: number;
  27936. /**
  27937. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27938. */
  27939. displayName?: string;
  27940. /**
  27941. * Should the native controller meshes be initialized. (default: true)
  27942. */
  27943. controllerMeshes?: boolean;
  27944. /**
  27945. * Creating a default HemiLight only on controllers. (default: true)
  27946. */
  27947. defaultLightingOnControllers?: boolean;
  27948. /**
  27949. * If you don't want to use the default VR button of the helper. (default: false)
  27950. */
  27951. useCustomVRButton?: boolean;
  27952. /**
  27953. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27954. */
  27955. customVRButton?: HTMLButtonElement;
  27956. /**
  27957. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27958. */
  27959. rayLength?: number;
  27960. /**
  27961. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27962. */
  27963. defaultHeight?: number;
  27964. /**
  27965. * If multiview should be used if available (default: false)
  27966. */
  27967. useMultiview?: boolean;
  27968. }
  27969. /**
  27970. * This represents a WebVR camera.
  27971. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27972. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27973. */
  27974. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27975. private webVROptions;
  27976. /**
  27977. * @hidden
  27978. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27979. */
  27980. _vrDevice: any;
  27981. /**
  27982. * The rawPose of the vrDevice.
  27983. */
  27984. rawPose: Nullable<DevicePose>;
  27985. private _onVREnabled;
  27986. private _specsVersion;
  27987. private _attached;
  27988. private _frameData;
  27989. protected _descendants: Array<Node>;
  27990. private _deviceRoomPosition;
  27991. /** @hidden */
  27992. _deviceRoomRotationQuaternion: Quaternion;
  27993. private _standingMatrix;
  27994. /**
  27995. * Represents device position in babylon space.
  27996. */
  27997. devicePosition: Vector3;
  27998. /**
  27999. * Represents device rotation in babylon space.
  28000. */
  28001. deviceRotationQuaternion: Quaternion;
  28002. /**
  28003. * The scale of the device to be used when translating from device space to babylon space.
  28004. */
  28005. deviceScaleFactor: number;
  28006. private _deviceToWorld;
  28007. private _worldToDevice;
  28008. /**
  28009. * References to the webVR controllers for the vrDevice.
  28010. */
  28011. controllers: Array<WebVRController>;
  28012. /**
  28013. * Emits an event when a controller is attached.
  28014. */
  28015. onControllersAttachedObservable: Observable<WebVRController[]>;
  28016. /**
  28017. * Emits an event when a controller's mesh has been loaded;
  28018. */
  28019. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28020. /**
  28021. * Emits an event when the HMD's pose has been updated.
  28022. */
  28023. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28024. private _poseSet;
  28025. /**
  28026. * If the rig cameras be used as parent instead of this camera.
  28027. */
  28028. rigParenting: boolean;
  28029. private _lightOnControllers;
  28030. private _defaultHeight?;
  28031. /**
  28032. * Instantiates a WebVRFreeCamera.
  28033. * @param name The name of the WebVRFreeCamera
  28034. * @param position The starting anchor position for the camera
  28035. * @param scene The scene the camera belongs to
  28036. * @param webVROptions a set of customizable options for the webVRCamera
  28037. */
  28038. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28039. /**
  28040. * Gets the device distance from the ground in meters.
  28041. * @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.
  28042. */
  28043. deviceDistanceToRoomGround(): number;
  28044. /**
  28045. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28046. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28047. */
  28048. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28049. /**
  28050. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28051. * @returns A promise with a boolean set to if the standing matrix is supported.
  28052. */
  28053. useStandingMatrixAsync(): Promise<boolean>;
  28054. /**
  28055. * Disposes the camera
  28056. */
  28057. dispose(): void;
  28058. /**
  28059. * Gets a vrController by name.
  28060. * @param name The name of the controller to retreive
  28061. * @returns the controller matching the name specified or null if not found
  28062. */
  28063. getControllerByName(name: string): Nullable<WebVRController>;
  28064. private _leftController;
  28065. /**
  28066. * The controller corresponding to the users left hand.
  28067. */
  28068. get leftController(): Nullable<WebVRController>;
  28069. private _rightController;
  28070. /**
  28071. * The controller corresponding to the users right hand.
  28072. */
  28073. get rightController(): Nullable<WebVRController>;
  28074. /**
  28075. * Casts a ray forward from the vrCamera's gaze.
  28076. * @param length Length of the ray (default: 100)
  28077. * @returns the ray corresponding to the gaze
  28078. */
  28079. getForwardRay(length?: number): Ray;
  28080. /**
  28081. * @hidden
  28082. * Updates the camera based on device's frame data
  28083. */
  28084. _checkInputs(): void;
  28085. /**
  28086. * Updates the poseControlled values based on the input device pose.
  28087. * @param poseData Pose coming from the device
  28088. */
  28089. updateFromDevice(poseData: DevicePose): void;
  28090. private _detachIfAttached;
  28091. /**
  28092. * WebVR's attach control will start broadcasting frames to the device.
  28093. * Note that in certain browsers (chrome for example) this function must be called
  28094. * within a user-interaction callback. Example:
  28095. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28096. *
  28097. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28098. */
  28099. attachControl(noPreventDefault?: boolean): void;
  28100. /**
  28101. * Detach the current controls from the specified dom element.
  28102. */
  28103. detachControl(): void;
  28104. /**
  28105. * @returns the name of this class
  28106. */
  28107. getClassName(): string;
  28108. /**
  28109. * Calls resetPose on the vrDisplay
  28110. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28111. */
  28112. resetToCurrentRotation(): void;
  28113. /**
  28114. * @hidden
  28115. * Updates the rig cameras (left and right eye)
  28116. */
  28117. _updateRigCameras(): void;
  28118. private _workingVector;
  28119. private _oneVector;
  28120. private _workingMatrix;
  28121. private updateCacheCalled;
  28122. private _correctPositionIfNotTrackPosition;
  28123. /**
  28124. * @hidden
  28125. * Updates the cached values of the camera
  28126. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28127. */
  28128. _updateCache(ignoreParentClass?: boolean): void;
  28129. /**
  28130. * @hidden
  28131. * Get current device position in babylon world
  28132. */
  28133. _computeDevicePosition(): void;
  28134. /**
  28135. * Updates the current device position and rotation in the babylon world
  28136. */
  28137. update(): void;
  28138. /**
  28139. * @hidden
  28140. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28141. * @returns an identity matrix
  28142. */
  28143. _getViewMatrix(): Matrix;
  28144. private _tmpMatrix;
  28145. /**
  28146. * This function is called by the two RIG cameras.
  28147. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28148. * @hidden
  28149. */
  28150. _getWebVRViewMatrix(): Matrix;
  28151. /** @hidden */
  28152. _getWebVRProjectionMatrix(): Matrix;
  28153. private _onGamepadConnectedObserver;
  28154. private _onGamepadDisconnectedObserver;
  28155. private _updateCacheWhenTrackingDisabledObserver;
  28156. /**
  28157. * Initializes the controllers and their meshes
  28158. */
  28159. initControllers(): void;
  28160. }
  28161. }
  28162. declare module BABYLON {
  28163. /**
  28164. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28165. *
  28166. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28167. *
  28168. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28169. */
  28170. export class MaterialHelper {
  28171. /**
  28172. * Bind the current view position to an effect.
  28173. * @param effect The effect to be bound
  28174. * @param scene The scene the eyes position is used from
  28175. * @param variableName name of the shader variable that will hold the eye position
  28176. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  28177. * @return the computed eye position
  28178. */
  28179. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  28180. /**
  28181. * Update the scene ubo before it can be used in rendering processing
  28182. * @param scene the scene to retrieve the ubo from
  28183. * @returns the scene UniformBuffer
  28184. */
  28185. static FinalizeSceneUbo(scene: Scene): UniformBuffer;
  28186. /**
  28187. * Binds the scene's uniform buffer to the effect.
  28188. * @param effect defines the effect to bind to the scene uniform buffer
  28189. * @param sceneUbo defines the uniform buffer storing scene data
  28190. */
  28191. static BindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  28192. /**
  28193. * Helps preparing the defines values about the UVs in used in the effect.
  28194. * UVs are shared as much as we can across channels in the shaders.
  28195. * @param texture The texture we are preparing the UVs for
  28196. * @param defines The defines to update
  28197. * @param key The channel key "diffuse", "specular"... used in the shader
  28198. */
  28199. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28200. /**
  28201. * Binds a texture matrix value to its corresponding uniform
  28202. * @param texture The texture to bind the matrix for
  28203. * @param uniformBuffer The uniform buffer receiving the data
  28204. * @param key The channel key "diffuse", "specular"... used in the shader
  28205. */
  28206. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28207. /**
  28208. * Gets the current status of the fog (should it be enabled?)
  28209. * @param mesh defines the mesh to evaluate for fog support
  28210. * @param scene defines the hosting scene
  28211. * @returns true if fog must be enabled
  28212. */
  28213. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28214. /**
  28215. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28216. * @param mesh defines the current mesh
  28217. * @param scene defines the current scene
  28218. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28219. * @param pointsCloud defines if point cloud rendering has to be turned on
  28220. * @param fogEnabled defines if fog has to be turned on
  28221. * @param alphaTest defines if alpha testing has to be turned on
  28222. * @param defines defines the current list of defines
  28223. */
  28224. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28225. /**
  28226. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28227. * @param scene defines the current scene
  28228. * @param engine defines the current engine
  28229. * @param defines specifies the list of active defines
  28230. * @param useInstances defines if instances have to be turned on
  28231. * @param useClipPlane defines if clip plane have to be turned on
  28232. * @param useInstances defines if instances have to be turned on
  28233. * @param useThinInstances defines if thin instances have to be turned on
  28234. */
  28235. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28236. /**
  28237. * Prepares the defines for bones
  28238. * @param mesh The mesh containing the geometry data we will draw
  28239. * @param defines The defines to update
  28240. */
  28241. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28242. /**
  28243. * Prepares the defines for morph targets
  28244. * @param mesh The mesh containing the geometry data we will draw
  28245. * @param defines The defines to update
  28246. */
  28247. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28248. /**
  28249. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28250. * @param mesh The mesh containing the geometry data we will draw
  28251. * @param defines The defines to update
  28252. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28253. * @param useBones Precise whether bones should be used or not (override mesh info)
  28254. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28255. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28256. * @returns false if defines are considered not dirty and have not been checked
  28257. */
  28258. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28259. /**
  28260. * Prepares the defines related to multiview
  28261. * @param scene The scene we are intending to draw
  28262. * @param defines The defines to update
  28263. */
  28264. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28265. /**
  28266. * Prepares the defines related to the prepass
  28267. * @param scene The scene we are intending to draw
  28268. * @param defines The defines to update
  28269. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28270. */
  28271. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28272. /**
  28273. * Prepares the defines related to the light information passed in parameter
  28274. * @param scene The scene we are intending to draw
  28275. * @param mesh The mesh the effect is compiling for
  28276. * @param light The light the effect is compiling for
  28277. * @param lightIndex The index of the light
  28278. * @param defines The defines to update
  28279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28280. * @param state Defines the current state regarding what is needed (normals, etc...)
  28281. */
  28282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28283. needNormals: boolean;
  28284. needRebuild: boolean;
  28285. shadowEnabled: boolean;
  28286. specularEnabled: boolean;
  28287. lightmapMode: boolean;
  28288. }): void;
  28289. /**
  28290. * Prepares the defines related to the light information passed in parameter
  28291. * @param scene The scene we are intending to draw
  28292. * @param mesh The mesh the effect is compiling for
  28293. * @param defines The defines to update
  28294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28295. * @param maxSimultaneousLights Specifies how manuy lights can be added to the effect at max
  28296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28297. * @returns true if normals will be required for the rest of the effect
  28298. */
  28299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28300. /**
  28301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28302. * @param lightIndex defines the light index
  28303. * @param uniformsList The uniform list
  28304. * @param samplersList The sampler list
  28305. * @param projectedLightTexture defines if projected texture must be used
  28306. * @param uniformBuffersList defines an optional list of uniform buffers
  28307. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28308. */
  28309. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28310. /**
  28311. * Prepares the uniforms and samplers list to be used in the effect
  28312. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the list and extra information
  28313. * @param samplersList The sampler list
  28314. * @param defines The defines helping in the list generation
  28315. * @param maxSimultaneousLights The maximum number of simultaneous light allowed in the effect
  28316. */
  28317. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28318. /**
  28319. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28320. * @param defines The defines to update while falling back
  28321. * @param fallbacks The authorized effect fallbacks
  28322. * @param maxSimultaneousLights The maximum number of lights allowed
  28323. * @param rank the current rank of the Effect
  28324. * @returns The newly affected rank
  28325. */
  28326. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28327. private static _TmpMorphInfluencers;
  28328. /**
  28329. * Prepares the list of attributes required for morph targets according to the effect defines.
  28330. * @param attribs The current list of supported attribs
  28331. * @param mesh The mesh to prepare the morph targets attributes for
  28332. * @param influencers The number of influencers
  28333. */
  28334. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28335. /**
  28336. * Prepares the list of attributes required for morph targets according to the effect defines.
  28337. * @param attribs The current list of supported attribs
  28338. * @param mesh The mesh to prepare the morph targets attributes for
  28339. * @param defines The current Defines of the effect
  28340. */
  28341. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28342. /**
  28343. * Prepares the list of attributes required for bones according to the effect defines.
  28344. * @param attribs The current list of supported attribs
  28345. * @param mesh The mesh to prepare the bones attributes for
  28346. * @param defines The current Defines of the effect
  28347. * @param fallbacks The current effect fallback strategy
  28348. */
  28349. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28350. /**
  28351. * Check and prepare the list of attributes required for instances according to the effect defines.
  28352. * @param attribs The current list of supported attribs
  28353. * @param defines The current MaterialDefines of the effect
  28354. */
  28355. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28356. /**
  28357. * Add the list of attributes required for instances to the attribs array.
  28358. * @param attribs The current list of supported attribs
  28359. */
  28360. static PushAttributesForInstances(attribs: string[]): void;
  28361. /**
  28362. * Binds the light information to the effect.
  28363. * @param light The light containing the generator
  28364. * @param effect The effect we are binding the data to
  28365. * @param lightIndex The light index in the effect used to render
  28366. */
  28367. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28368. /**
  28369. * Binds the lights information from the scene to the effect for the given mesh.
  28370. * @param light Light to bind
  28371. * @param lightIndex Light index
  28372. * @param scene The scene where the light belongs to
  28373. * @param effect The effect we are binding the data to
  28374. * @param useSpecular Defines if specular is supported
  28375. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28376. */
  28377. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28378. /**
  28379. * Binds the lights information from the scene to the effect for the given mesh.
  28380. * @param scene The scene the lights belongs to
  28381. * @param mesh The mesh we are binding the information to render
  28382. * @param effect The effect we are binding the data to
  28383. * @param defines The generated defines for the effect
  28384. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28385. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28386. */
  28387. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28388. private static _tempFogColor;
  28389. /**
  28390. * Binds the fog information from the scene to the effect for the given mesh.
  28391. * @param scene The scene the lights belongs to
  28392. * @param mesh The mesh we are binding the information to render
  28393. * @param effect The effect we are binding the data to
  28394. * @param linearSpace Defines if the fog effect is applied in linear space
  28395. */
  28396. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28397. /**
  28398. * Binds the bones information from the mesh to the effect.
  28399. * @param mesh The mesh we are binding the information to render
  28400. * @param effect The effect we are binding the data to
  28401. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28402. */
  28403. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28404. private static _CopyBonesTransformationMatrices;
  28405. /**
  28406. * Binds the morph targets information from the mesh to the effect.
  28407. * @param abstractMesh The mesh we are binding the information to render
  28408. * @param effect The effect we are binding the data to
  28409. */
  28410. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28411. /**
  28412. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28413. * @param defines The generated defines used in the effect
  28414. * @param effect The effect we are binding the data to
  28415. * @param scene The scene we are willing to render with logarithmic scale for
  28416. */
  28417. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28418. /**
  28419. * Binds the clip plane information from the scene to the effect.
  28420. * @param scene The scene the clip plane information are extracted from
  28421. * @param effect The effect we are binding the data to
  28422. */
  28423. static BindClipPlane(effect: Effect, scene: Scene): void;
  28424. }
  28425. }
  28426. declare module BABYLON {
  28427. /** @hidden */
  28428. export var bayerDitherFunctions: {
  28429. name: string;
  28430. shader: string;
  28431. };
  28432. }
  28433. declare module BABYLON {
  28434. /** @hidden */
  28435. export var shadowMapFragmentDeclaration: {
  28436. name: string;
  28437. shader: string;
  28438. };
  28439. }
  28440. declare module BABYLON {
  28441. /** @hidden */
  28442. export var shadowMapFragment: {
  28443. name: string;
  28444. shader: string;
  28445. };
  28446. }
  28447. declare module BABYLON {
  28448. /** @hidden */
  28449. export var shadowMapPixelShader: {
  28450. name: string;
  28451. shader: string;
  28452. };
  28453. }
  28454. declare module BABYLON {
  28455. /** @hidden */
  28456. export var shadowMapVertexDeclaration: {
  28457. name: string;
  28458. shader: string;
  28459. };
  28460. }
  28461. declare module BABYLON {
  28462. /** @hidden */
  28463. export var shadowMapVertexNormalBias: {
  28464. name: string;
  28465. shader: string;
  28466. };
  28467. }
  28468. declare module BABYLON {
  28469. /** @hidden */
  28470. export var shadowMapVertexMetric: {
  28471. name: string;
  28472. shader: string;
  28473. };
  28474. }
  28475. declare module BABYLON {
  28476. /** @hidden */
  28477. export var shadowMapVertexShader: {
  28478. name: string;
  28479. shader: string;
  28480. };
  28481. }
  28482. declare module BABYLON {
  28483. /** @hidden */
  28484. export var depthBoxBlurPixelShader: {
  28485. name: string;
  28486. shader: string;
  28487. };
  28488. }
  28489. declare module BABYLON {
  28490. /** @hidden */
  28491. export var shadowMapFragmentSoftTransparentShadow: {
  28492. name: string;
  28493. shader: string;
  28494. };
  28495. }
  28496. declare module BABYLON {
  28497. /**
  28498. * Creates an instance based on a source mesh.
  28499. */
  28500. export class InstancedMesh extends AbstractMesh {
  28501. private _sourceMesh;
  28502. private _currentLOD;
  28503. /** @hidden */
  28504. _indexInSourceMeshInstanceArray: number;
  28505. constructor(name: string, source: Mesh);
  28506. /**
  28507. * Returns the string "InstancedMesh".
  28508. */
  28509. getClassName(): string;
  28510. /** Gets the list of lights affecting that mesh */
  28511. get lightSources(): Light[];
  28512. _resyncLightSources(): void;
  28513. _resyncLightSource(light: Light): void;
  28514. _removeLightSource(light: Light, dispose: boolean): void;
  28515. /**
  28516. * If the source mesh receives shadows
  28517. */
  28518. get receiveShadows(): boolean;
  28519. /**
  28520. * The material of the source mesh
  28521. */
  28522. get material(): Nullable<Material>;
  28523. /**
  28524. * Visibility of the source mesh
  28525. */
  28526. get visibility(): number;
  28527. /**
  28528. * Skeleton of the source mesh
  28529. */
  28530. get skeleton(): Nullable<Skeleton>;
  28531. /**
  28532. * Rendering ground id of the source mesh
  28533. */
  28534. get renderingGroupId(): number;
  28535. set renderingGroupId(value: number);
  28536. /**
  28537. * Returns the total number of vertices (integer).
  28538. */
  28539. getTotalVertices(): number;
  28540. /**
  28541. * Returns a positive integer : the total number of indices in this mesh geometry.
  28542. * @returns the numner of indices or zero if the mesh has no geometry.
  28543. */
  28544. getTotalIndices(): number;
  28545. /**
  28546. * The source mesh of the instance
  28547. */
  28548. get sourceMesh(): Mesh;
  28549. /**
  28550. * Creates a new InstancedMesh object from the mesh model.
  28551. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28552. * @param name defines the name of the new instance
  28553. * @returns a new InstancedMesh
  28554. */
  28555. createInstance(name: string): InstancedMesh;
  28556. /**
  28557. * Is this node ready to be used/rendered
  28558. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28559. * @return {boolean} is it ready
  28560. */
  28561. isReady(completeCheck?: boolean): boolean;
  28562. /**
  28563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28564. * @param kind kind of verticies to retrieve (eg. positions, normals, uvs, etc.)
  28565. * @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.
  28566. * @returns a float array or a Float32Array of the requested kind of data : positions, normals, uvs, etc.
  28567. */
  28568. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28569. /**
  28570. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28571. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28572. * The `data` are either a numeric array either a Float32Array.
  28573. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initially none) or updater.
  28574. * 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).
  28575. * Note that a new underlying VertexBuffer object is created each call.
  28576. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28577. *
  28578. * Possible `kind` values :
  28579. * - VertexBuffer.PositionKind
  28580. * - VertexBuffer.UVKind
  28581. * - VertexBuffer.UV2Kind
  28582. * - VertexBuffer.UV3Kind
  28583. * - VertexBuffer.UV4Kind
  28584. * - VertexBuffer.UV5Kind
  28585. * - VertexBuffer.UV6Kind
  28586. * - VertexBuffer.ColorKind
  28587. * - VertexBuffer.MatricesIndicesKind
  28588. * - VertexBuffer.MatricesIndicesExtraKind
  28589. * - VertexBuffer.MatricesWeightsKind
  28590. * - VertexBuffer.MatricesWeightsExtraKind
  28591. *
  28592. * Returns the Mesh.
  28593. */
  28594. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28595. /**
  28596. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28597. * If the mesh has no geometry, it is simply returned as it is.
  28598. * The `data` are either a numeric array either a Float32Array.
  28599. * No new underlying VertexBuffer object is created.
  28600. * 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.
  28601. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28602. *
  28603. * Possible `kind` values :
  28604. * - VertexBuffer.PositionKind
  28605. * - VertexBuffer.UVKind
  28606. * - VertexBuffer.UV2Kind
  28607. * - VertexBuffer.UV3Kind
  28608. * - VertexBuffer.UV4Kind
  28609. * - VertexBuffer.UV5Kind
  28610. * - VertexBuffer.UV6Kind
  28611. * - VertexBuffer.ColorKind
  28612. * - VertexBuffer.MatricesIndicesKind
  28613. * - VertexBuffer.MatricesIndicesExtraKind
  28614. * - VertexBuffer.MatricesWeightsKind
  28615. * - VertexBuffer.MatricesWeightsExtraKind
  28616. *
  28617. * Returns the Mesh.
  28618. */
  28619. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28620. /**
  28621. * Sets the mesh indices.
  28622. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28623. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28624. * This method creates a new index buffer each call.
  28625. * Returns the Mesh.
  28626. */
  28627. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28628. /**
  28629. * Boolean : True if the mesh owns the requested kind of data.
  28630. */
  28631. isVerticesDataPresent(kind: string): boolean;
  28632. /**
  28633. * Returns an array of indices (IndicesArray).
  28634. */
  28635. getIndices(): Nullable<IndicesArray>;
  28636. get _positions(): Nullable<Vector3[]>;
  28637. /**
  28638. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28639. * This means the mesh underlying bounding box and sphere are recomputed.
  28640. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28641. * @returns the current mesh
  28642. */
  28643. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28644. /** @hidden */
  28645. _preActivate(): InstancedMesh;
  28646. /** @hidden */
  28647. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28648. /** @hidden */
  28649. _postActivate(): void;
  28650. getWorldMatrix(): Matrix;
  28651. get isAnInstance(): boolean;
  28652. /**
  28653. * Returns the current associated LOD AbstractMesh.
  28654. */
  28655. getLOD(camera: Camera): AbstractMesh;
  28656. /** @hidden */
  28657. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28658. /** @hidden */
  28659. _syncSubMeshes(): InstancedMesh;
  28660. /** @hidden */
  28661. _generatePointsArray(): boolean;
  28662. /** @hidden */
  28663. _updateBoundingInfo(): AbstractMesh;
  28664. /**
  28665. * Creates a new InstancedMesh from the current mesh.
  28666. * - name (string) : the cloned mesh name
  28667. * - newParent (optional Node) : the optional Node to parent the clone to.
  28668. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28669. *
  28670. * Returns the clone.
  28671. */
  28672. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28673. /**
  28674. * Disposes the InstancedMesh.
  28675. * Returns nothing.
  28676. */
  28677. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28678. }
  28679. interface Mesh {
  28680. /**
  28681. * Register a custom buffer that will be instanced
  28682. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28683. * @param kind defines the buffer kind
  28684. * @param stride defines the stride in floats
  28685. */
  28686. registerInstancedBuffer(kind: string, stride: number): void;
  28687. /**
  28688. * Invalidate VertexArrayObjects belonging to the mesh (but not to the Geometry of the mesh).
  28689. */
  28690. _invalidateInstanceVertexArrayObject(): void;
  28691. /**
  28692. * true to use the edge renderer for all instances of this mesh
  28693. */
  28694. edgesShareWithInstances: boolean;
  28695. /** @hidden */
  28696. _userInstancedBuffersStorage: {
  28697. data: {
  28698. [key: string]: Float32Array;
  28699. };
  28700. sizes: {
  28701. [key: string]: number;
  28702. };
  28703. vertexBuffers: {
  28704. [key: string]: Nullable<VertexBuffer>;
  28705. };
  28706. strides: {
  28707. [key: string]: number;
  28708. };
  28709. vertexArrayObjects?: {
  28710. [key: string]: WebGLVertexArrayObject;
  28711. };
  28712. };
  28713. }
  28714. interface AbstractMesh {
  28715. /**
  28716. * Object used to store instanced buffers defined by user
  28717. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28718. */
  28719. instancedBuffers: {
  28720. [key: string]: any;
  28721. };
  28722. }
  28723. }
  28724. declare module BABYLON {
  28725. /**
  28726. * Defines the options associated with the creation of a shader material.
  28727. */
  28728. export interface IShaderMaterialOptions {
  28729. /**
  28730. * Does the material work in alpha blend mode
  28731. */
  28732. needAlphaBlending: boolean;
  28733. /**
  28734. * Does the material work in alpha test mode
  28735. */
  28736. needAlphaTesting: boolean;
  28737. /**
  28738. * The list of attribute names used in the shader
  28739. */
  28740. attributes: string[];
  28741. /**
  28742. * The list of uniform names used in the shader
  28743. */
  28744. uniforms: string[];
  28745. /**
  28746. * The list of UBO names used in the shader
  28747. */
  28748. uniformBuffers: string[];
  28749. /**
  28750. * The list of sampler names used in the shader
  28751. */
  28752. samplers: string[];
  28753. /**
  28754. * The list of defines used in the shader
  28755. */
  28756. defines: string[];
  28757. }
  28758. /**
  28759. * 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.
  28760. *
  28761. * This returned material effects how the mesh will look based on the code in the shaders.
  28762. *
  28763. * @see https://doc.babylonjs.com/how_to/shader_material
  28764. */
  28765. export class ShaderMaterial extends Material {
  28766. private _shaderPath;
  28767. private _options;
  28768. private _textures;
  28769. private _textureArrays;
  28770. private _floats;
  28771. private _ints;
  28772. private _floatsArrays;
  28773. private _colors3;
  28774. private _colors3Arrays;
  28775. private _colors4;
  28776. private _colors4Arrays;
  28777. private _vectors2;
  28778. private _vectors3;
  28779. private _vectors4;
  28780. private _matrices;
  28781. private _matrixArrays;
  28782. private _matrices3x3;
  28783. private _matrices2x2;
  28784. private _vectors2Arrays;
  28785. private _vectors3Arrays;
  28786. private _vectors4Arrays;
  28787. private _cachedWorldViewMatrix;
  28788. private _cachedWorldViewProjectionMatrix;
  28789. private _renderId;
  28790. private _multiview;
  28791. private _cachedDefines;
  28792. /** Define the Url to load snippets */
  28793. static SnippetUrl: string;
  28794. /** Snippet ID if the material was created from the snippet server */
  28795. snippetId: string;
  28796. /**
  28797. * Instantiate a new shader material.
  28798. * 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.
  28799. * This returned material effects how the mesh will look based on the code in the shaders.
  28800. * @see https://doc.babylonjs.com/how_to/shader_material
  28801. * @param name Define the name of the material in the scene
  28802. * @param scene Define the scene the material belongs to
  28803. * @param shaderPath Defines the route to the shader code in one of three ways:
  28804. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28805. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28806. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28807. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28808. * @param options Define the options used to create the shader
  28809. */
  28810. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28811. /**
  28812. * Gets the shader path used to define the shader code
  28813. * It can be modified to trigger a new compilation
  28814. */
  28815. get shaderPath(): any;
  28816. /**
  28817. * Sets the shader path used to define the shader code
  28818. * It can be modified to trigger a new compilation
  28819. */
  28820. set shaderPath(shaderPath: any);
  28821. /**
  28822. * Gets the options used to compile the shader.
  28823. * They can be modified to trigger a new compilation
  28824. */
  28825. get options(): IShaderMaterialOptions;
  28826. /**
  28827. * Gets the current class name of the material e.g. "ShaderMaterial"
  28828. * Mainly use in serialization.
  28829. * @returns the class name
  28830. */
  28831. getClassName(): string;
  28832. /**
  28833. * Specifies if the material will require alpha blending
  28834. * @returns a boolean specifying if alpha blending is needed
  28835. */
  28836. needAlphaBlending(): boolean;
  28837. /**
  28838. * Specifies if this material should be rendered in alpha test mode
  28839. * @returns a boolean specifying if an alpha test is needed.
  28840. */
  28841. needAlphaTesting(): boolean;
  28842. private _checkUniform;
  28843. /**
  28844. * Set a texture in the shader.
  28845. * @param name Define the name of the uniform samplers as defined in the shader
  28846. * @param texture Define the texture to bind to this sampler
  28847. * @return the material itself allowing "fluent" like uniform updates
  28848. */
  28849. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28850. /**
  28851. * Set a texture array in the shader.
  28852. * @param name Define the name of the uniform sampler array as defined in the shader
  28853. * @param textures Define the list of textures to bind to this sampler
  28854. * @return the material itself allowing "fluent" like uniform updates
  28855. */
  28856. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28857. /**
  28858. * Set a float in the shader.
  28859. * @param name Define the name of the uniform as defined in the shader
  28860. * @param value Define the value to give to the uniform
  28861. * @return the material itself allowing "fluent" like uniform updates
  28862. */
  28863. setFloat(name: string, value: number): ShaderMaterial;
  28864. /**
  28865. * Set a int in the shader.
  28866. * @param name Define the name of the uniform as defined in the shader
  28867. * @param value Define the value to give to the uniform
  28868. * @return the material itself allowing "fluent" like uniform updates
  28869. */
  28870. setInt(name: string, value: number): ShaderMaterial;
  28871. /**
  28872. * Set an array of floats in the shader.
  28873. * @param name Define the name of the uniform as defined in the shader
  28874. * @param value Define the value to give to the uniform
  28875. * @return the material itself allowing "fluent" like uniform updates
  28876. */
  28877. setFloats(name: string, value: number[]): ShaderMaterial;
  28878. /**
  28879. * Set a vec3 in the shader from a Color3.
  28880. * @param name Define the name of the uniform as defined in the shader
  28881. * @param value Define the value to give to the uniform
  28882. * @return the material itself allowing "fluent" like uniform updates
  28883. */
  28884. setColor3(name: string, value: Color3): ShaderMaterial;
  28885. /**
  28886. * Set a vec3 array in the shader from a Color3 array.
  28887. * @param name Define the name of the uniform as defined in the shader
  28888. * @param value Define the value to give to the uniform
  28889. * @return the material itself allowing "fluent" like uniform updates
  28890. */
  28891. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28892. /**
  28893. * Set a vec4 in the shader from a Color4.
  28894. * @param name Define the name of the uniform as defined in the shader
  28895. * @param value Define the value to give to the uniform
  28896. * @return the material itself allowing "fluent" like uniform updates
  28897. */
  28898. setColor4(name: string, value: Color4): ShaderMaterial;
  28899. /**
  28900. * Set a vec4 array in the shader from a Color4 array.
  28901. * @param name Define the name of the uniform as defined in the shader
  28902. * @param value Define the value to give to the uniform
  28903. * @return the material itself allowing "fluent" like uniform updates
  28904. */
  28905. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28906. /**
  28907. * Set a vec2 in the shader from a Vector2.
  28908. * @param name Define the name of the uniform as defined in the shader
  28909. * @param value Define the value to give to the uniform
  28910. * @return the material itself allowing "fluent" like uniform updates
  28911. */
  28912. setVector2(name: string, value: Vector2): ShaderMaterial;
  28913. /**
  28914. * Set a vec3 in the shader from a Vector3.
  28915. * @param name Define the name of the uniform as defined in the shader
  28916. * @param value Define the value to give to the uniform
  28917. * @return the material itself allowing "fluent" like uniform updates
  28918. */
  28919. setVector3(name: string, value: Vector3): ShaderMaterial;
  28920. /**
  28921. * Set a vec4 in the shader from a Vector4.
  28922. * @param name Define the name of the uniform as defined in the shader
  28923. * @param value Define the value to give to the uniform
  28924. * @return the material itself allowing "fluent" like uniform updates
  28925. */
  28926. setVector4(name: string, value: Vector4): ShaderMaterial;
  28927. /**
  28928. * Set a mat4 in the shader from a Matrix.
  28929. * @param name Define the name of the uniform as defined in the shader
  28930. * @param value Define the value to give to the uniform
  28931. * @return the material itself allowing "fluent" like uniform updates
  28932. */
  28933. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28934. /**
  28935. * Set a float32Array in the shader from a matrix array.
  28936. * @param name Define the name of the uniform as defined in the shader
  28937. * @param value Define the value to give to the uniform
  28938. * @return the material itself allowing "fluent" like uniform updates
  28939. */
  28940. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28941. /**
  28942. * Set a mat3 in the shader from a Float32Array.
  28943. * @param name Define the name of the uniform as defined in the shader
  28944. * @param value Define the value to give to the uniform
  28945. * @return the material itself allowing "fluent" like uniform updates
  28946. */
  28947. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28948. /**
  28949. * Set a mat2 in the shader from a Float32Array.
  28950. * @param name Define the name of the uniform as defined in the shader
  28951. * @param value Define the value to give to the uniform
  28952. * @return the material itself allowing "fluent" like uniform updates
  28953. */
  28954. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28955. /**
  28956. * Set a vec2 array in the shader from a number array.
  28957. * @param name Define the name of the uniform as defined in the shader
  28958. * @param value Define the value to give to the uniform
  28959. * @return the material itself allowing "fluent" like uniform updates
  28960. */
  28961. setArray2(name: string, value: number[]): ShaderMaterial;
  28962. /**
  28963. * Set a vec3 array in the shader from a number array.
  28964. * @param name Define the name of the uniform as defined in the shader
  28965. * @param value Define the value to give to the uniform
  28966. * @return the material itself allowing "fluent" like uniform updates
  28967. */
  28968. setArray3(name: string, value: number[]): ShaderMaterial;
  28969. /**
  28970. * Set a vec4 array in the shader from a number array.
  28971. * @param name Define the name of the uniform as defined in the shader
  28972. * @param value Define the value to give to the uniform
  28973. * @return the material itself allowing "fluent" like uniform updates
  28974. */
  28975. setArray4(name: string, value: number[]): ShaderMaterial;
  28976. private _checkCache;
  28977. /**
  28978. * Specifies that the submesh is ready to be used
  28979. * @param mesh defines the mesh to check
  28980. * @param subMesh defines which submesh to check
  28981. * @param useInstances specifies that instances should be used
  28982. * @returns a boolean indicating that the submesh is ready or not
  28983. */
  28984. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28985. /**
  28986. * Checks if the material is ready to render the requested mesh
  28987. * @param mesh Define the mesh to render
  28988. * @param useInstances Define whether or not the material is used with instances
  28989. * @returns true if ready, otherwise false
  28990. */
  28991. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28992. /**
  28993. * Binds the world matrix to the material
  28994. * @param world defines the world transformation matrix
  28995. * @param effectOverride - If provided, use this effect instead of internal effect
  28996. */
  28997. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28998. /**
  28999. * Binds the submesh to this material by preparing the effect and shader to draw
  29000. * @param world defines the world transformation matrix
  29001. * @param mesh defines the mesh containing the submesh
  29002. * @param subMesh defines the submesh to bind the material to
  29003. */
  29004. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29005. /**
  29006. * Binds the material to the mesh
  29007. * @param world defines the world transformation matrix
  29008. * @param mesh defines the mesh to bind the material to
  29009. * @param effectOverride - If provided, use this effect instead of internal effect
  29010. */
  29011. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29012. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  29013. /**
  29014. * Gets the active textures from the material
  29015. * @returns an array of textures
  29016. */
  29017. getActiveTextures(): BaseTexture[];
  29018. /**
  29019. * Specifies if the material uses a texture
  29020. * @param texture defines the texture to check against the material
  29021. * @returns a boolean specifying if the material uses the texture
  29022. */
  29023. hasTexture(texture: BaseTexture): boolean;
  29024. /**
  29025. * Makes a duplicate of the material, and gives it a new name
  29026. * @param name defines the new name for the duplicated material
  29027. * @returns the cloned material
  29028. */
  29029. clone(name: string): ShaderMaterial;
  29030. /**
  29031. * Disposes the material
  29032. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29033. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29034. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29035. */
  29036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29037. /**
  29038. * Serializes this material in a JSON representation
  29039. * @returns the serialized material object
  29040. */
  29041. serialize(): any;
  29042. /**
  29043. * Creates a shader material from parsed shader material data
  29044. * @param source defines the JSON representation of the material
  29045. * @param scene defines the hosting scene
  29046. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29047. * @returns a new material
  29048. */
  29049. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29050. /**
  29051. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29052. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29053. * @param url defines the url to load from
  29054. * @param scene defines the hosting scene
  29055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29056. * @returns a promise that will resolve to the new ShaderMaterial
  29057. */
  29058. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29059. /**
  29060. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29061. * @param snippetId defines the snippet to load
  29062. * @param scene defines the hosting scene
  29063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29064. * @returns a promise that will resolve to the new ShaderMaterial
  29065. */
  29066. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29067. }
  29068. }
  29069. declare module BABYLON {
  29070. /** @hidden */
  29071. export var colorPixelShader: {
  29072. name: string;
  29073. shader: string;
  29074. };
  29075. }
  29076. declare module BABYLON {
  29077. /** @hidden */
  29078. export var colorVertexShader: {
  29079. name: string;
  29080. shader: string;
  29081. };
  29082. }
  29083. declare module BABYLON {
  29084. /**
  29085. * Line mesh
  29086. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29087. */
  29088. export class LinesMesh extends Mesh {
  29089. /**
  29090. * If vertex color should be applied to the mesh
  29091. */
  29092. readonly useVertexColor?: boolean | undefined;
  29093. /**
  29094. * If vertex alpha should be applied to the mesh
  29095. */
  29096. readonly useVertexAlpha?: boolean | undefined;
  29097. /**
  29098. * Color of the line (Default: White)
  29099. */
  29100. color: Color3;
  29101. /**
  29102. * Alpha of the line (Default: 1)
  29103. */
  29104. alpha: number;
  29105. /**
  29106. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29107. * This margin is expressed in world space coordinates, so its value may vary.
  29108. * Default value is 0.1
  29109. */
  29110. intersectionThreshold: number;
  29111. private _colorShader;
  29112. private color4;
  29113. /**
  29114. * Creates a new LinesMesh
  29115. * @param name defines the name
  29116. * @param scene defines the hosting scene
  29117. * @param parent defines the parent mesh if any
  29118. * @param source defines the optional source LinesMesh used to clone data from
  29119. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29120. * When false, achieved by calling a clone(), also passing False.
  29121. * This will make creation of children, recursive.
  29122. * @param useVertexColor defines if this LinesMesh supports vertex color
  29123. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29124. */
  29125. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29126. /**
  29127. * If vertex color should be applied to the mesh
  29128. */
  29129. useVertexColor?: boolean | undefined,
  29130. /**
  29131. * If vertex alpha should be applied to the mesh
  29132. */
  29133. useVertexAlpha?: boolean | undefined);
  29134. private _addClipPlaneDefine;
  29135. private _removeClipPlaneDefine;
  29136. isReady(): boolean;
  29137. /**
  29138. * Returns the string "LineMesh"
  29139. */
  29140. getClassName(): string;
  29141. /**
  29142. * @hidden
  29143. */
  29144. get material(): Material;
  29145. /**
  29146. * @hidden
  29147. */
  29148. set material(value: Material);
  29149. /**
  29150. * @hidden
  29151. */
  29152. get checkCollisions(): boolean;
  29153. set checkCollisions(value: boolean);
  29154. /** @hidden */
  29155. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29156. /** @hidden */
  29157. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29158. /**
  29159. * Disposes of the line mesh
  29160. * @param doNotRecurse If children should be disposed
  29161. */
  29162. dispose(doNotRecurse?: boolean): void;
  29163. /**
  29164. * Returns a new LineMesh object cloned from the current one.
  29165. */
  29166. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29167. /**
  29168. * Creates a new InstancedLinesMesh object from the mesh model.
  29169. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29170. * @param name defines the name of the new instance
  29171. * @returns a new InstancedLinesMesh
  29172. */
  29173. createInstance(name: string): InstancedLinesMesh;
  29174. }
  29175. /**
  29176. * Creates an instance based on a source LinesMesh
  29177. */
  29178. export class InstancedLinesMesh extends InstancedMesh {
  29179. /**
  29180. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29181. * This margin is expressed in world space coordinates, so its value may vary.
  29182. * Initialized with the intersectionThreshold value of the source LinesMesh
  29183. */
  29184. intersectionThreshold: number;
  29185. constructor(name: string, source: LinesMesh);
  29186. /**
  29187. * Returns the string "InstancedLinesMesh".
  29188. */
  29189. getClassName(): string;
  29190. }
  29191. }
  29192. declare module BABYLON {
  29193. /** @hidden */
  29194. export var linePixelShader: {
  29195. name: string;
  29196. shader: string;
  29197. };
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var lineVertexShader: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. interface Scene {
  29208. /** @hidden */
  29209. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29210. }
  29211. interface AbstractMesh {
  29212. /**
  29213. * Gets the edgesRenderer associated with the mesh
  29214. */
  29215. edgesRenderer: Nullable<EdgesRenderer>;
  29216. }
  29217. interface LinesMesh {
  29218. /**
  29219. * Enables the edge rendering mode on the mesh.
  29220. * This mode makes the mesh edges visible
  29221. * @param epsilon defines the maximal distance between two angles to detect a face
  29222. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29223. * @returns the currentAbstractMesh
  29224. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29225. */
  29226. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29227. }
  29228. interface InstancedLinesMesh {
  29229. /**
  29230. * Enables the edge rendering mode on the mesh.
  29231. * This mode makes the mesh edges visible
  29232. * @param epsilon defines the maximal distance between two angles to detect a face
  29233. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29234. * @returns the current InstancedLinesMesh
  29235. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29236. */
  29237. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29238. }
  29239. /**
  29240. * Defines the minimum contract an Edges renderer should follow.
  29241. */
  29242. export interface IEdgesRenderer extends IDisposable {
  29243. /**
  29244. * Gets or sets a boolean indicating if the edgesRenderer is active
  29245. */
  29246. isEnabled: boolean;
  29247. /**
  29248. * Renders the edges of the attached mesh,
  29249. */
  29250. render(): void;
  29251. /**
  29252. * Checks whether or not the edges renderer is ready to render.
  29253. * @return true if ready, otherwise false.
  29254. */
  29255. isReady(): boolean;
  29256. /**
  29257. * List of instances to render in case the source mesh has instances
  29258. */
  29259. customInstances: SmartArray<Matrix>;
  29260. }
  29261. /**
  29262. * Defines the additional options of the edges renderer
  29263. */
  29264. export interface IEdgesRendererOptions {
  29265. /**
  29266. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29267. * If not defined, the default value is true
  29268. */
  29269. useAlternateEdgeFinder?: boolean;
  29270. /**
  29271. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29272. * If not defined, the default value is true.
  29273. * 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)
  29274. * This option is used only if useAlternateEdgeFinder = true
  29275. */
  29276. useFastVertexMerger?: boolean;
  29277. /**
  29278. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.
  29279. * The default value is 1e-6
  29280. * This option is used only if useAlternateEdgeFinder = true
  29281. */
  29282. epsilonVertexMerge?: number;
  29283. /**
  29284. * 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
  29285. * 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.
  29286. * This option is used only if useAlternateEdgeFinder = true
  29287. */
  29288. applyTessellation?: boolean;
  29289. /**
  29290. * 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
  29291. * The default value is 1e-6
  29292. * This option is used only if useAlternateEdgeFinder = true
  29293. */
  29294. epsilonVertexAligned?: number;
  29295. }
  29296. /**
  29297. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29298. */
  29299. export class EdgesRenderer implements IEdgesRenderer {
  29300. /**
  29301. * Define the size of the edges with an orthographic camera
  29302. */
  29303. edgesWidthScalerForOrthographic: number;
  29304. /**
  29305. * Define the size of the edges with a perspective camera
  29306. */
  29307. edgesWidthScalerForPerspective: number;
  29308. protected _source: AbstractMesh;
  29309. protected _linesPositions: number[];
  29310. protected _linesNormals: number[];
  29311. protected _linesIndices: number[];
  29312. protected _epsilon: number;
  29313. protected _indicesCount: number;
  29314. protected _lineShader: ShaderMaterial;
  29315. protected _ib: DataBuffer;
  29316. protected _buffers: {
  29317. [key: string]: Nullable<VertexBuffer>;
  29318. };
  29319. protected _buffersForInstances: {
  29320. [key: string]: Nullable<VertexBuffer>;
  29321. };
  29322. protected _checkVerticesInsteadOfIndices: boolean;
  29323. protected _options: Nullable<IEdgesRendererOptions>;
  29324. private _meshRebuildObserver;
  29325. private _meshDisposeObserver;
  29326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29327. isEnabled: boolean;
  29328. /** Gets the vertices generated by the edge renderer */
  29329. get linesPositions(): Immutable<Array<number>>;
  29330. /** Gets the normals generated by the edge renderer */
  29331. get linesNormals(): Immutable<Array<number>>;
  29332. /** Gets the indices generated by the edge renderer */
  29333. get linesIndices(): Immutable<Array<number>>;
  29334. /**
  29335. * List of instances to render in case the source mesh has instances
  29336. */
  29337. customInstances: SmartArray<Matrix>;
  29338. private static GetShader;
  29339. /**
  29340. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29341. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29342. * @param source Mesh used to create edges
  29343. * @param epsilon sum of angles in adjacency to check for edge
  29344. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29345. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29346. * @param options The options to apply when generating the edges
  29347. */
  29348. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29349. protected _prepareRessources(): void;
  29350. /** @hidden */
  29351. _rebuild(): void;
  29352. /**
  29353. * Releases the required resources for the edges renderer
  29354. */
  29355. dispose(): void;
  29356. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29357. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29358. /**
  29359. * Checks if the pair of p0 and p1 is en edge
  29360. * @param faceIndex
  29361. * @param edge
  29362. * @param faceNormals
  29363. * @param p0
  29364. * @param p1
  29365. * @private
  29366. */
  29367. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29368. /**
  29369. * push line into the position, normal and index buffer
  29370. * @protected
  29371. */
  29372. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29373. /**
  29374. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29375. */
  29376. private _tessellateTriangle;
  29377. private _generateEdgesLinesAlternate;
  29378. /**
  29379. * Generates lines edges from adjacencjes
  29380. * @private
  29381. */
  29382. _generateEdgesLines(): void;
  29383. /**
  29384. * Checks whether or not the edges renderer is ready to render.
  29385. * @return true if ready, otherwise false.
  29386. */
  29387. isReady(): boolean;
  29388. /**
  29389. * Renders the edges of the attached mesh,
  29390. */
  29391. render(): void;
  29392. }
  29393. /**
  29394. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29395. */
  29396. export class LineEdgesRenderer extends EdgesRenderer {
  29397. /**
  29398. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29399. * @param source LineMesh used to generate edges
  29400. * @param epsilon not important (specified angle for edge detection)
  29401. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29402. */
  29403. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29404. /**
  29405. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29406. */
  29407. _generateEdgesLines(): void;
  29408. }
  29409. }
  29410. declare module BABYLON {
  29411. /**
  29412. * This represents the object necessary to create a rendering group.
  29413. * This is exclusively used and created by the rendering manager.
  29414. * To modify the behavior, you use the available helpers in your scene or meshes.
  29415. * @hidden
  29416. */
  29417. export class RenderingGroup {
  29418. index: number;
  29419. private static _zeroVector;
  29420. private _scene;
  29421. private _opaqueSubMeshes;
  29422. private _transparentSubMeshes;
  29423. private _alphaTestSubMeshes;
  29424. private _depthOnlySubMeshes;
  29425. private _particleSystems;
  29426. private _spriteManagers;
  29427. private _opaqueSortCompareFn;
  29428. private _alphaTestSortCompareFn;
  29429. private _transparentSortCompareFn;
  29430. private _renderOpaque;
  29431. private _renderAlphaTest;
  29432. private _renderTransparent;
  29433. /** @hidden */
  29434. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29435. onBeforeTransparentRendering: () => void;
  29436. /**
  29437. * Set the opaque sort comparison function.
  29438. * If null the sub meshes will be render in the order they were created
  29439. */
  29440. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29441. /**
  29442. * Set the alpha test sort comparison function.
  29443. * If null the sub meshes will be render in the order they were created
  29444. */
  29445. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29446. /**
  29447. * Set the transparent sort comparison function.
  29448. * If null the sub meshes will be render in the order they were created
  29449. */
  29450. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29451. /**
  29452. * Creates a new rendering group.
  29453. * @param index The rendering group index
  29454. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29455. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29456. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29457. */
  29458. 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>);
  29459. /**
  29460. * Render all the sub meshes contained in the group.
  29461. * @param customRenderFunction Used to override the default render behaviour of the group.
  29462. * @returns true if rendered some submeshes.
  29463. */
  29464. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29465. /**
  29466. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29467. * @param subMeshes The submeshes to render
  29468. */
  29469. private renderOpaqueSorted;
  29470. /**
  29471. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29472. * @param subMeshes The submeshes to render
  29473. */
  29474. private renderAlphaTestSorted;
  29475. /**
  29476. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29477. * @param subMeshes The submeshes to render
  29478. */
  29479. private renderTransparentSorted;
  29480. /**
  29481. * Renders the submeshes in a specified order.
  29482. * @param subMeshes The submeshes to sort before render
  29483. * @param sortCompareFn The comparison function use to sort
  29484. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29485. * @param transparent Specifies to activate blending if true
  29486. */
  29487. private static renderSorted;
  29488. /**
  29489. * Renders the submeshes in the order they were dispatched (no sort applied).
  29490. * @param subMeshes The submeshes to render
  29491. */
  29492. private static renderUnsorted;
  29493. /**
  29494. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29495. * are rendered back to front if in the same alpha index.
  29496. *
  29497. * @param a The first submesh
  29498. * @param b The second submesh
  29499. * @returns The result of the comparison
  29500. */
  29501. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29502. /**
  29503. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29504. * are rendered back to front.
  29505. *
  29506. * @param a The first submesh
  29507. * @param b The second submesh
  29508. * @returns The result of the comparison
  29509. */
  29510. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29511. /**
  29512. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29513. * are rendered front to back (prevent overdraw).
  29514. *
  29515. * @param a The first submesh
  29516. * @param b The second submesh
  29517. * @returns The result of the comparison
  29518. */
  29519. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29520. /**
  29521. * Resets the different lists of submeshes to prepare a new frame.
  29522. */
  29523. prepare(): void;
  29524. dispose(): void;
  29525. /**
  29526. * Inserts the submesh in its correct queue depending on its material.
  29527. * @param subMesh The submesh to dispatch
  29528. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29529. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29530. */
  29531. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29532. dispatchSprites(spriteManager: ISpriteManager): void;
  29533. dispatchParticles(particleSystem: IParticleSystem): void;
  29534. private _renderParticles;
  29535. private _renderSprites;
  29536. }
  29537. }
  29538. declare module BABYLON {
  29539. /**
  29540. * Interface describing the different options available in the rendering manager
  29541. * regarding Auto Clear between groups.
  29542. */
  29543. export interface IRenderingManagerAutoClearSetup {
  29544. /**
  29545. * Defines whether or not autoclear is enable.
  29546. */
  29547. autoClear: boolean;
  29548. /**
  29549. * Defines whether or not to autoclear the depth buffer.
  29550. */
  29551. depth: boolean;
  29552. /**
  29553. * Defines whether or not to autoclear the stencil buffer.
  29554. */
  29555. stencil: boolean;
  29556. }
  29557. /**
  29558. * This class is used by the onRenderingGroupObservable
  29559. */
  29560. export class RenderingGroupInfo {
  29561. /**
  29562. * The Scene that being rendered
  29563. */
  29564. scene: Scene;
  29565. /**
  29566. * The camera currently used for the rendering pass
  29567. */
  29568. camera: Nullable<Camera>;
  29569. /**
  29570. * The ID of the renderingGroup being processed
  29571. */
  29572. renderingGroupId: number;
  29573. }
  29574. /**
  29575. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29576. * It is enable to manage the different groups as well as the different necessary sort functions.
  29577. * This should not be used directly aside of the few static configurations
  29578. */
  29579. export class RenderingManager {
  29580. /**
  29581. * The max id used for rendering groups (not included)
  29582. */
  29583. static MAX_RENDERINGGROUPS: number;
  29584. /**
  29585. * The min id used for rendering groups (included)
  29586. */
  29587. static MIN_RENDERINGGROUPS: number;
  29588. /**
  29589. * Used to globally prevent autoclearing scenes.
  29590. */
  29591. static AUTOCLEAR: boolean;
  29592. /**
  29593. * @hidden
  29594. */
  29595. _useSceneAutoClearSetup: boolean;
  29596. private _scene;
  29597. private _renderingGroups;
  29598. private _depthStencilBufferAlreadyCleaned;
  29599. private _autoClearDepthStencil;
  29600. private _customOpaqueSortCompareFn;
  29601. private _customAlphaTestSortCompareFn;
  29602. private _customTransparentSortCompareFn;
  29603. private _renderingGroupInfo;
  29604. /**
  29605. * Instantiates a new rendering group for a particular scene
  29606. * @param scene Defines the scene the groups belongs to
  29607. */
  29608. constructor(scene: Scene);
  29609. private _clearDepthStencilBuffer;
  29610. /**
  29611. * Renders the entire managed groups. This is used by the scene or the different render targets.
  29612. * @hidden
  29613. */
  29614. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29615. /**
  29616. * Resets the different information of the group to prepare a new frame
  29617. * @hidden
  29618. */
  29619. reset(): void;
  29620. /**
  29621. * Dispose and release the group and its associated resources.
  29622. * @hidden
  29623. */
  29624. dispose(): void;
  29625. /**
  29626. * Clear the info related to rendering groups preventing retention points during dispose.
  29627. */
  29628. freeRenderingGroups(): void;
  29629. private _prepareRenderingGroup;
  29630. /**
  29631. * Add a sprite manager to the rendering manager in order to render it this frame.
  29632. * @param spriteManager Define the sprite manager to render
  29633. */
  29634. dispatchSprites(spriteManager: ISpriteManager): void;
  29635. /**
  29636. * Add a particle system to the rendering manager in order to render it this frame.
  29637. * @param particleSystem Define the particle system to render
  29638. */
  29639. dispatchParticles(particleSystem: IParticleSystem): void;
  29640. /**
  29641. * Add a submesh to the manager in order to render it this frame
  29642. * @param subMesh The submesh to dispatch
  29643. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29644. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29645. */
  29646. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29647. /**
  29648. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  29649. * This allowed control for front to back rendering or reversely depending of the special needs.
  29650. *
  29651. * @param renderingGroupId The rendering group id corresponding to its index
  29652. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29653. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29654. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29655. */
  29656. 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;
  29657. /**
  29658. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29659. *
  29660. * @param renderingGroupId The rendering group id corresponding to its index
  29661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29662. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29663. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29664. */
  29665. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29666. /**
  29667. * Gets the current auto clear configuration for one rendering group of the rendering
  29668. * manager.
  29669. * @param index the rendering group index to get the information for
  29670. * @returns The auto clear setup for the requested rendering group
  29671. */
  29672. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29673. }
  29674. }
  29675. declare module BABYLON {
  29676. /**
  29677. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29678. */
  29679. export interface ICustomShaderOptions {
  29680. /**
  29681. * Gets or sets the custom shader name to use
  29682. */
  29683. shaderName: string;
  29684. /**
  29685. * The list of attribute names used in the shader
  29686. */
  29687. attributes?: string[];
  29688. /**
  29689. * The list of uniform names used in the shader
  29690. */
  29691. uniforms?: string[];
  29692. /**
  29693. * The list of sampler names used in the shader
  29694. */
  29695. samplers?: string[];
  29696. /**
  29697. * The list of defines used in the shader
  29698. */
  29699. defines?: string[];
  29700. }
  29701. /**
  29702. * Interface to implement to create a shadow generator compatible with BJS.
  29703. */
  29704. export interface IShadowGenerator {
  29705. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29706. id: string;
  29707. /**
  29708. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29709. * @returns The render target texture if present otherwise, null
  29710. */
  29711. getShadowMap(): Nullable<RenderTargetTexture>;
  29712. /**
  29713. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29714. * @param subMesh The submesh we want to render in the shadow map
  29715. * @param useInstances Defines whether will draw in the map using instances
  29716. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29717. * @returns true if ready otherwise, false
  29718. */
  29719. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29720. /**
  29721. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29722. * @param defines Defines of the material we want to update
  29723. * @param lightIndex Index of the light in the enabled light list of the material
  29724. */
  29725. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29726. /**
  29727. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29728. * defined in the generator but impacting the effect).
  29729. * It implies the uniforms available on the materials are the standard BJS ones.
  29730. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29731. * @param effect The effect we are binding the information for
  29732. */
  29733. bindShadowLight(lightIndex: string, effect: Effect): void;
  29734. /**
  29735. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29736. * (eq to shadow projection matrix * light transform matrix)
  29737. * @returns The transform matrix used to create the shadow map
  29738. */
  29739. getTransformMatrix(): Matrix;
  29740. /**
  29741. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29742. * Cube and 2D textures for instance.
  29743. */
  29744. recreateShadowMap(): void;
  29745. /**
  29746. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29747. * @param onCompiled Callback triggered at the and of the effects compilation
  29748. * @param options Sets of optional options forcing the compilation with different modes
  29749. */
  29750. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29751. useInstances: boolean;
  29752. }>): void;
  29753. /**
  29754. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  29755. * @param options Sets of optional options forcing the compilation with different modes
  29756. * @returns A promise that resolves when the compilation completes
  29757. */
  29758. forceCompilationAsync(options?: Partial<{
  29759. useInstances: boolean;
  29760. }>): Promise<void>;
  29761. /**
  29762. * Serializes the shadow generator setup to a json object.
  29763. * @returns The serialized JSON object
  29764. */
  29765. serialize(): any;
  29766. /**
  29767. * Disposes the Shadow map and related Textures and effects.
  29768. */
  29769. dispose(): void;
  29770. }
  29771. /**
  29772. * Default implementation IShadowGenerator.
  29773. * This is the main object responsible of generating shadows in the framework.
  29774. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29775. */
  29776. export class ShadowGenerator implements IShadowGenerator {
  29777. private static _Counter;
  29778. /**
  29779. * Name of the shadow generator class
  29780. */
  29781. static CLASSNAME: string;
  29782. /**
  29783. * Shadow generator mode None: no filtering applied.
  29784. */
  29785. static readonly FILTER_NONE: number;
  29786. /**
  29787. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29788. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29789. */
  29790. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29791. /**
  29792. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29793. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29794. */
  29795. static readonly FILTER_POISSONSAMPLING: number;
  29796. /**
  29797. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29798. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29799. */
  29800. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29801. /**
  29802. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29803. * edge artifacts on steep falloff.
  29804. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29805. */
  29806. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29807. /**
  29808. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29809. * edge artifacts on steep falloff.
  29810. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29811. */
  29812. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29813. /**
  29814. * Shadow generator mode PCF: Percentage Closer Filtering
  29815. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29816. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29817. */
  29818. static readonly FILTER_PCF: number;
  29819. /**
  29820. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29821. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29822. * Contact Hardening
  29823. */
  29824. static readonly FILTER_PCSS: number;
  29825. /**
  29826. * Reserved for PCF and PCSS
  29827. * Highest Quality.
  29828. *
  29829. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29830. *
  29831. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29832. */
  29833. static readonly QUALITY_HIGH: number;
  29834. /**
  29835. * Reserved for PCF and PCSS
  29836. * Good tradeoff for quality/perf cross devices
  29837. *
  29838. * Execute PCF on a 3*3 kernel.
  29839. *
  29840. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29841. */
  29842. static readonly QUALITY_MEDIUM: number;
  29843. /**
  29844. * Reserved for PCF and PCSS
  29845. * The lowest quality but the fastest.
  29846. *
  29847. * Execute PCF on a 1*1 kernel.
  29848. *
  29849. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29850. */
  29851. static readonly QUALITY_LOW: number;
  29852. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29853. id: string;
  29854. /** Gets or sets the custom shader name to use */
  29855. customShaderOptions: ICustomShaderOptions;
  29856. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29857. customAllowRendering: (subMesh: SubMesh) => boolean;
  29858. /**
  29859. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29860. */
  29861. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29862. /**
  29863. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29864. */
  29865. onAfterShadowMapRenderObservable: Observable<Effect>;
  29866. /**
  29867. * Observable triggered before a mesh is rendered in the shadow map.
  29868. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29869. */
  29870. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29871. /**
  29872. * Observable triggered after a mesh is rendered in the shadow map.
  29873. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29874. */
  29875. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29876. protected _bias: number;
  29877. /**
  29878. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29879. */
  29880. get bias(): number;
  29881. /**
  29882. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29883. */
  29884. set bias(bias: number);
  29885. protected _normalBias: number;
  29886. /**
  29887. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29888. */
  29889. get normalBias(): number;
  29890. /**
  29891. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportional to the light/normal angle).
  29892. */
  29893. set normalBias(normalBias: number);
  29894. protected _blurBoxOffset: number;
  29895. /**
  29896. * Gets the blur box offset: offset applied during the blur pass.
  29897. * Only useful if useKernelBlur = false
  29898. */
  29899. get blurBoxOffset(): number;
  29900. /**
  29901. * Sets the blur box offset: offset applied during the blur pass.
  29902. * Only useful if useKernelBlur = false
  29903. */
  29904. set blurBoxOffset(value: number);
  29905. protected _blurScale: number;
  29906. /**
  29907. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29908. * 2 means half of the size.
  29909. */
  29910. get blurScale(): number;
  29911. /**
  29912. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29913. * 2 means half of the size.
  29914. */
  29915. set blurScale(value: number);
  29916. protected _blurKernel: number;
  29917. /**
  29918. * Gets the blur kernel: kernel size of the blur pass.
  29919. * Only useful if useKernelBlur = true
  29920. */
  29921. get blurKernel(): number;
  29922. /**
  29923. * Sets the blur kernel: kernel size of the blur pass.
  29924. * Only useful if useKernelBlur = true
  29925. */
  29926. set blurKernel(value: number);
  29927. protected _useKernelBlur: boolean;
  29928. /**
  29929. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29930. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29931. */
  29932. get useKernelBlur(): boolean;
  29933. /**
  29934. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29935. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29936. */
  29937. set useKernelBlur(value: boolean);
  29938. protected _depthScale: number;
  29939. /**
  29940. * Gets the depth scale used in ESM mode.
  29941. */
  29942. get depthScale(): number;
  29943. /**
  29944. * Sets the depth scale used in ESM mode.
  29945. * This can override the scale stored on the light.
  29946. */
  29947. set depthScale(value: number);
  29948. protected _validateFilter(filter: number): number;
  29949. protected _filter: number;
  29950. /**
  29951. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29952. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29953. */
  29954. get filter(): number;
  29955. /**
  29956. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29957. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29958. */
  29959. set filter(value: number);
  29960. /**
  29961. * Gets if the current filter is set to Poisson Sampling.
  29962. */
  29963. get usePoissonSampling(): boolean;
  29964. /**
  29965. * Sets the current filter to Poisson Sampling.
  29966. */
  29967. set usePoissonSampling(value: boolean);
  29968. /**
  29969. * Gets if the current filter is set to ESM.
  29970. */
  29971. get useExponentialShadowMap(): boolean;
  29972. /**
  29973. * Sets the current filter is to ESM.
  29974. */
  29975. set useExponentialShadowMap(value: boolean);
  29976. /**
  29977. * Gets if the current filter is set to filtered ESM.
  29978. */
  29979. get useBlurExponentialShadowMap(): boolean;
  29980. /**
  29981. * Gets if the current filter is set to filtered ESM.
  29982. */
  29983. set useBlurExponentialShadowMap(value: boolean);
  29984. /**
  29985. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29986. * exponential to prevent steep falloff artifacts).
  29987. */
  29988. get useCloseExponentialShadowMap(): boolean;
  29989. /**
  29990. * Sets the current filter to "close ESM" (using the inverse of the
  29991. * exponential to prevent steep falloff artifacts).
  29992. */
  29993. set useCloseExponentialShadowMap(value: boolean);
  29994. /**
  29995. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29996. * exponential to prevent steep falloff artifacts).
  29997. */
  29998. get useBlurCloseExponentialShadowMap(): boolean;
  29999. /**
  30000. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30001. * exponential to prevent steep falloff artifacts).
  30002. */
  30003. set useBlurCloseExponentialShadowMap(value: boolean);
  30004. /**
  30005. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30006. */
  30007. get usePercentageCloserFiltering(): boolean;
  30008. /**
  30009. * Sets the current filter to "PCF" (percentage closer filtering).
  30010. */
  30011. set usePercentageCloserFiltering(value: boolean);
  30012. protected _filteringQuality: number;
  30013. /**
  30014. * Gets the PCF or PCSS Quality.
  30015. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30016. */
  30017. get filteringQuality(): number;
  30018. /**
  30019. * Sets the PCF or PCSS Quality.
  30020. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30021. */
  30022. set filteringQuality(filteringQuality: number);
  30023. /**
  30024. * Gets if the current filter is set to "PCSS" (contact hardening).
  30025. */
  30026. get useContactHardeningShadow(): boolean;
  30027. /**
  30028. * Sets the current filter to "PCSS" (contact hardening).
  30029. */
  30030. set useContactHardeningShadow(value: boolean);
  30031. protected _contactHardeningLightSizeUVRatio: number;
  30032. /**
  30033. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30034. * Using a ratio helps keeping shape stability independently of the map size.
  30035. *
  30036. * It does not account for the light projection as it was having too much
  30037. * instability during the light setup or during light position changes.
  30038. *
  30039. * Only valid if useContactHardeningShadow is true.
  30040. */
  30041. get contactHardeningLightSizeUVRatio(): number;
  30042. /**
  30043. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30044. * Using a ratio helps keeping shape stability independently of the map size.
  30045. *
  30046. * It does not account for the light projection as it was having too much
  30047. * instability during the light setup or during light position changes.
  30048. *
  30049. * Only valid if useContactHardeningShadow is true.
  30050. */
  30051. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30052. protected _darkness: number;
  30053. /** Gets or sets the actual darkness of a shadow */
  30054. get darkness(): number;
  30055. set darkness(value: number);
  30056. /**
  30057. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30058. * 0 means strongest and 1 would means no shadow.
  30059. * @returns the darkness.
  30060. */
  30061. getDarkness(): number;
  30062. /**
  30063. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30064. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30065. * @returns the shadow generator allowing fluent coding.
  30066. */
  30067. setDarkness(darkness: number): ShadowGenerator;
  30068. protected _transparencyShadow: boolean;
  30069. /** Gets or sets the ability to have transparent shadow */
  30070. get transparencyShadow(): boolean;
  30071. set transparencyShadow(value: boolean);
  30072. /**
  30073. * Sets the ability to have transparent shadow (boolean).
  30074. * @param transparent True if transparent else False
  30075. * @returns the shadow generator allowing fluent coding
  30076. */
  30077. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30078. /**
  30079. * Enables or disables shadows with varying strength based on the transparency
  30080. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30081. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30082. * mesh.visibility * alphaTexture.a
  30083. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30084. */
  30085. enableSoftTransparentShadow: boolean;
  30086. protected _shadowMap: Nullable<RenderTargetTexture>;
  30087. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30088. /**
  30089. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30090. * @returns The render target texture if present otherwise, null
  30091. */
  30092. getShadowMap(): Nullable<RenderTargetTexture>;
  30093. /**
  30094. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30095. * @returns The render target texture if the shadow map is present otherwise, null
  30096. */
  30097. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30098. /**
  30099. * Gets the class name of that object
  30100. * @returns "ShadowGenerator"
  30101. */
  30102. getClassName(): string;
  30103. /**
  30104. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30105. * @param mesh Mesh to add
  30106. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30107. * @returns the Shadow Generator itself
  30108. */
  30109. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30110. /**
  30111. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30112. * @param mesh Mesh to remove
  30113. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30114. * @returns the Shadow Generator itself
  30115. */
  30116. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30117. /**
  30118. * Controls the extent to which the shadows fade out at the edge of the frustum
  30119. */
  30120. frustumEdgeFalloff: number;
  30121. protected _light: IShadowLight;
  30122. /**
  30123. * Returns the associated light object.
  30124. * @returns the light generating the shadow
  30125. */
  30126. getLight(): IShadowLight;
  30127. /**
  30128. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30129. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30130. * It might on the other hand introduce peter panning.
  30131. */
  30132. forceBackFacesOnly: boolean;
  30133. protected _scene: Scene;
  30134. protected _lightDirection: Vector3;
  30135. protected _viewMatrix: Matrix;
  30136. protected _projectionMatrix: Matrix;
  30137. protected _transformMatrix: Matrix;
  30138. protected _cachedPosition: Vector3;
  30139. protected _cachedDirection: Vector3;
  30140. protected _cachedDefines: string;
  30141. protected _currentRenderID: number;
  30142. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30143. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30144. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30145. protected _blurPostProcesses: PostProcess[];
  30146. protected _mapSize: number;
  30147. protected _currentFaceIndex: number;
  30148. protected _currentFaceIndexCache: number;
  30149. protected _textureType: number;
  30150. protected _defaultTextureMatrix: Matrix;
  30151. protected _storedUniqueId: Nullable<number>;
  30152. protected _nameForCustomEffect: string;
  30153. /** @hidden */
  30154. static _SceneComponentInitialization: (scene: Scene) => void;
  30155. /**
  30156. * Gets or sets the size of the texture what stores the shadows
  30157. */
  30158. get mapSize(): number;
  30159. set mapSize(size: number);
  30160. /**
  30161. * Creates a ShadowGenerator object.
  30162. * A ShadowGenerator is the required tool to use the shadows.
  30163. * Each light casting shadows needs to use its own ShadowGenerator.
  30164. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30165. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30166. * @param light The light object generating the shadows.
  30167. * @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.
  30168. */
  30169. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30170. protected _initializeGenerator(): void;
  30171. protected _createTargetRenderTexture(): void;
  30172. protected _initializeShadowMap(): void;
  30173. protected _initializeBlurRTTAndPostProcesses(): void;
  30174. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30175. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30176. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30177. protected _applyFilterValues(): void;
  30178. /**
  30179. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30180. * @param onCompiled Callback triggered at the and of the effects compilation
  30181. * @param options Sets of optional options forcing the compilation with different modes
  30182. */
  30183. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30184. useInstances: boolean;
  30185. }>): void;
  30186. /**
  30187. * Forces all the attached effect to compile to enable rendering only once ready vs. lazily compiling effects.
  30188. * @param options Sets of optional options forcing the compilation with different modes
  30189. * @returns A promise that resolves when the compilation completes
  30190. */
  30191. forceCompilationAsync(options?: Partial<{
  30192. useInstances: boolean;
  30193. }>): Promise<void>;
  30194. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30195. private _prepareShadowDefines;
  30196. /**
  30197. * Determine whether the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30198. * @param subMesh The submesh we want to render in the shadow map
  30199. * @param useInstances Defines whether will draw in the map using instances
  30200. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30201. * @returns true if ready otherwise, false
  30202. */
  30203. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30204. /**
  30205. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30206. * @param defines Defines of the material we want to update
  30207. * @param lightIndex Index of the light in the enabled light list of the material
  30208. */
  30209. prepareDefines(defines: any, lightIndex: number): void;
  30210. /**
  30211. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30212. * defined in the generator but impacting the effect).
  30213. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30214. * @param effect The effect we are binding the information for
  30215. */
  30216. bindShadowLight(lightIndex: string, effect: Effect): void;
  30217. /**
  30218. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30219. * (eq to shadow projection matrix * light transform matrix)
  30220. * @returns The transform matrix used to create the shadow map
  30221. */
  30222. getTransformMatrix(): Matrix;
  30223. /**
  30224. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30225. * Cube and 2D textures for instance.
  30226. */
  30227. recreateShadowMap(): void;
  30228. protected _disposeBlurPostProcesses(): void;
  30229. protected _disposeRTTandPostProcesses(): void;
  30230. /**
  30231. * Disposes the ShadowGenerator.
  30232. * Returns nothing.
  30233. */
  30234. dispose(): void;
  30235. /**
  30236. * Serializes the shadow generator setup to a json object.
  30237. * @returns The serialized JSON object
  30238. */
  30239. serialize(): any;
  30240. /**
  30241. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30242. * @param parsedShadowGenerator The JSON object to parse
  30243. * @param scene The scene to create the shadow map for
  30244. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30245. * @returns The parsed shadow generator
  30246. */
  30247. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30248. }
  30249. }
  30250. declare module BABYLON {
  30251. /**
  30252. * Options to be used when creating a shadow depth material
  30253. */
  30254. export interface IIOptionShadowDepthMaterial {
  30255. /** Variables in the vertex shader code that need to have their names remapped.
  30256. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30257. * "var_name" should be either: worldPos or vNormalW
  30258. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30259. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30260. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30261. */
  30262. remappedVariables?: string[];
  30263. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30264. standalone?: boolean;
  30265. }
  30266. /**
  30267. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30268. */
  30269. export class ShadowDepthWrapper {
  30270. private _scene;
  30271. private _options?;
  30272. private _baseMaterial;
  30273. private _onEffectCreatedObserver;
  30274. private _subMeshToEffect;
  30275. private _subMeshToDepthEffect;
  30276. private _meshes;
  30277. /** @hidden */
  30278. _matriceNames: any;
  30279. /** Gets the standalone status of the wrapper */
  30280. get standalone(): boolean;
  30281. /** Gets the base material the wrapper is built upon */
  30282. get baseMaterial(): Material;
  30283. /**
  30284. * Instantiate a new shadow depth wrapper.
  30285. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30286. * generate the shadow depth map. For more information, please refer to the documentation:
  30287. * https://doc.babylonjs.com/babylon101/shadows
  30288. * @param baseMaterial Material to wrap
  30289. * @param scene Define the scene the material belongs to
  30290. * @param options Options used to create the wrapper
  30291. */
  30292. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30293. /**
  30294. * Gets the effect to use to generate the depth map
  30295. * @param subMesh subMesh to get the effect for
  30296. * @param shadowGenerator shadow generator to get the effect for
  30297. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30298. */
  30299. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30300. /**
  30301. * Specifies that the submesh is ready to be used for depth rendering
  30302. * @param subMesh submesh to check
  30303. * @param defines the list of defines to take into account when checking the effect
  30304. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30305. * @param useInstances specifies that instances should be used
  30306. * @returns a boolean indicating that the submesh is ready or not
  30307. */
  30308. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30309. /**
  30310. * Disposes the resources
  30311. */
  30312. dispose(): void;
  30313. private _makeEffect;
  30314. }
  30315. }
  30316. declare module BABYLON {
  30317. /**
  30318. * Options for compiling materials.
  30319. */
  30320. export interface IMaterialCompilationOptions {
  30321. /**
  30322. * Defines whether clip planes are enabled.
  30323. */
  30324. clipPlane: boolean;
  30325. /**
  30326. * Defines whether instances are enabled.
  30327. */
  30328. useInstances: boolean;
  30329. }
  30330. /**
  30331. * Options passed when calling customShaderNameResolve
  30332. */
  30333. export interface ICustomShaderNameResolveOptions {
  30334. /**
  30335. * 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
  30336. */
  30337. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30338. }
  30339. /**
  30340. * Base class for the main features of a material in Babylon.js
  30341. */
  30342. export class Material implements IAnimatable {
  30343. /**
  30344. * Returns the triangle fill mode
  30345. */
  30346. static readonly TriangleFillMode: number;
  30347. /**
  30348. * Returns the wireframe mode
  30349. */
  30350. static readonly WireFrameFillMode: number;
  30351. /**
  30352. * Returns the point fill mode
  30353. */
  30354. static readonly PointFillMode: number;
  30355. /**
  30356. * Returns the point list draw mode
  30357. */
  30358. static readonly PointListDrawMode: number;
  30359. /**
  30360. * Returns the line list draw mode
  30361. */
  30362. static readonly LineListDrawMode: number;
  30363. /**
  30364. * Returns the line loop draw mode
  30365. */
  30366. static readonly LineLoopDrawMode: number;
  30367. /**
  30368. * Returns the line strip draw mode
  30369. */
  30370. static readonly LineStripDrawMode: number;
  30371. /**
  30372. * Returns the triangle strip draw mode
  30373. */
  30374. static readonly TriangleStripDrawMode: number;
  30375. /**
  30376. * Returns the triangle fan draw mode
  30377. */
  30378. static readonly TriangleFanDrawMode: number;
  30379. /**
  30380. * Stores the clock-wise side orientation
  30381. */
  30382. static readonly ClockWiseSideOrientation: number;
  30383. /**
  30384. * Stores the counter clock-wise side orientation
  30385. */
  30386. static readonly CounterClockWiseSideOrientation: number;
  30387. /**
  30388. * The dirty texture flag value
  30389. */
  30390. static readonly TextureDirtyFlag: number;
  30391. /**
  30392. * The dirty light flag value
  30393. */
  30394. static readonly LightDirtyFlag: number;
  30395. /**
  30396. * The dirty fresnel flag value
  30397. */
  30398. static readonly FresnelDirtyFlag: number;
  30399. /**
  30400. * The dirty attribute flag value
  30401. */
  30402. static readonly AttributesDirtyFlag: number;
  30403. /**
  30404. * The dirty misc flag value
  30405. */
  30406. static readonly MiscDirtyFlag: number;
  30407. /**
  30408. * The dirty prepass flag value
  30409. */
  30410. static readonly PrePassDirtyFlag: number;
  30411. /**
  30412. * The all dirty flag value
  30413. */
  30414. static readonly AllDirtyFlag: number;
  30415. /**
  30416. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30417. */
  30418. static readonly MATERIAL_OPAQUE: number;
  30419. /**
  30420. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30421. */
  30422. static readonly MATERIAL_ALPHATEST: number;
  30423. /**
  30424. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30425. */
  30426. static readonly MATERIAL_ALPHABLEND: number;
  30427. /**
  30428. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30429. * They are also discarded below the alpha cutoff threshold to improve performances.
  30430. */
  30431. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30432. /**
  30433. * The Whiteout method is used to blend normals.
  30434. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30435. */
  30436. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30437. /**
  30438. * The Reoriented Normal Mapping method is used to blend normals.
  30439. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30440. */
  30441. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30442. /**
  30443. * Custom callback helping to override the default shader used in the material.
  30444. */
  30445. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30446. /**
  30447. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30448. */
  30449. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30450. /**
  30451. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30452. * This means that the material can keep using a previous shader while a new one is being compiled.
  30453. * This is mostly used when shader parallel compilation is supported (true by default)
  30454. */
  30455. allowShaderHotSwapping: boolean;
  30456. /**
  30457. * The ID of the material
  30458. */
  30459. id: string;
  30460. /**
  30461. * Gets or sets the unique id of the material
  30462. */
  30463. uniqueId: number;
  30464. /**
  30465. * The name of the material
  30466. */
  30467. name: string;
  30468. /**
  30469. * Gets or sets user defined metadata
  30470. */
  30471. metadata: any;
  30472. /**
  30473. * For internal use only. Please do not use.
  30474. */
  30475. reservedDataStore: any;
  30476. /**
  30477. * Specifies if the ready state should be checked on each call
  30478. */
  30479. checkReadyOnEveryCall: boolean;
  30480. /**
  30481. * Specifies if the ready state should be checked once
  30482. */
  30483. checkReadyOnlyOnce: boolean;
  30484. /**
  30485. * The state of the material
  30486. */
  30487. state: string;
  30488. /**
  30489. * If the material can be rendered to several textures with MRT extension
  30490. */
  30491. get canRenderToMRT(): boolean;
  30492. /**
  30493. * The alpha value of the material
  30494. */
  30495. protected _alpha: number;
  30496. /**
  30497. * List of inspectable custom properties (used by the Inspector)
  30498. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30499. */
  30500. inspectableCustomProperties: IInspectable[];
  30501. /**
  30502. * Sets the alpha value of the material
  30503. */
  30504. set alpha(value: number);
  30505. /**
  30506. * Gets the alpha value of the material
  30507. */
  30508. get alpha(): number;
  30509. /**
  30510. * Specifies if back face culling is enabled
  30511. */
  30512. protected _backFaceCulling: boolean;
  30513. /**
  30514. * Sets the back-face culling state
  30515. */
  30516. set backFaceCulling(value: boolean);
  30517. /**
  30518. * Gets the back-face culling state
  30519. */
  30520. get backFaceCulling(): boolean;
  30521. /**
  30522. * Stores the value for side orientation
  30523. */
  30524. sideOrientation: number;
  30525. /**
  30526. * Callback triggered when the material is compiled
  30527. */
  30528. onCompiled: Nullable<(effect: Effect) => void>;
  30529. /**
  30530. * Callback triggered when an error occurs
  30531. */
  30532. onError: Nullable<(effect: Effect, errors: string) => void>;
  30533. /**
  30534. * Callback triggered to get the render target textures
  30535. */
  30536. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30537. /**
  30538. * Gets a boolean indicating that current material needs to register RTT
  30539. */
  30540. get hasRenderTargetTextures(): boolean;
  30541. /**
  30542. * Specifies if the material should be serialized
  30543. */
  30544. doNotSerialize: boolean;
  30545. /**
  30546. * @hidden
  30547. */
  30548. _storeEffectOnSubMeshes: boolean;
  30549. /**
  30550. * Stores the animations for the material
  30551. */
  30552. animations: Nullable<Array<Animation>>;
  30553. /**
  30554. * An event triggered when the material is disposed
  30555. */
  30556. onDisposeObservable: Observable<Material>;
  30557. /**
  30558. * An observer which watches for dispose events
  30559. */
  30560. private _onDisposeObserver;
  30561. private _onUnBindObservable;
  30562. /**
  30563. * Called during a dispose event
  30564. */
  30565. set onDispose(callback: () => void);
  30566. private _onBindObservable;
  30567. /**
  30568. * An event triggered when the material is bound
  30569. */
  30570. get onBindObservable(): Observable<AbstractMesh>;
  30571. /**
  30572. * An observer which watches for bind events
  30573. */
  30574. private _onBindObserver;
  30575. /**
  30576. * Called during a bind event
  30577. */
  30578. set onBind(callback: (Mesh: AbstractMesh) => void);
  30579. /**
  30580. * An event triggered when the material is unbound
  30581. */
  30582. get onUnBindObservable(): Observable<Material>;
  30583. protected _onEffectCreatedObservable: Nullable<Observable<{
  30584. effect: Effect;
  30585. subMesh: Nullable<SubMesh>;
  30586. }>>;
  30587. /**
  30588. * An event triggered when the effect is (re)created
  30589. */
  30590. get onEffectCreatedObservable(): Observable<{
  30591. effect: Effect;
  30592. subMesh: Nullable<SubMesh>;
  30593. }>;
  30594. /**
  30595. * Stores the value of the alpha mode
  30596. */
  30597. private _alphaMode;
  30598. /**
  30599. * Sets the value of the alpha mode.
  30600. *
  30601. * | Value | Type | Description |
  30602. * | --- | --- | --- |
  30603. * | 0 | ALPHA_DISABLE | |
  30604. * | 1 | ALPHA_ADD | |
  30605. * | 2 | ALPHA_COMBINE | |
  30606. * | 3 | ALPHA_SUBTRACT | |
  30607. * | 4 | ALPHA_MULTIPLY | |
  30608. * | 5 | ALPHA_MAXIMIZED | |
  30609. * | 6 | ALPHA_ONEONE | |
  30610. * | 7 | ALPHA_PREMULTIPLIED | |
  30611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30612. * | 9 | ALPHA_INTERPOLATE | |
  30613. * | 10 | ALPHA_SCREENMODE | |
  30614. *
  30615. */
  30616. set alphaMode(value: number);
  30617. /**
  30618. * Gets the value of the alpha mode
  30619. */
  30620. get alphaMode(): number;
  30621. /**
  30622. * Stores the state of the need depth pre-pass value
  30623. */
  30624. private _needDepthPrePass;
  30625. /**
  30626. * Sets the need depth pre-pass value
  30627. */
  30628. set needDepthPrePass(value: boolean);
  30629. /**
  30630. * Gets the depth pre-pass value
  30631. */
  30632. get needDepthPrePass(): boolean;
  30633. /**
  30634. * Can this material render to prepass
  30635. */
  30636. get isPrePassCapable(): boolean;
  30637. /**
  30638. * Specifies if depth writing should be disabled
  30639. */
  30640. disableDepthWrite: boolean;
  30641. /**
  30642. * Specifies if color writing should be disabled
  30643. */
  30644. disableColorWrite: boolean;
  30645. /**
  30646. * Specifies if depth writing should be forced
  30647. */
  30648. forceDepthWrite: boolean;
  30649. /**
  30650. * Specifies the depth function that should be used. 0 means the default engine function
  30651. */
  30652. depthFunction: number;
  30653. /**
  30654. * Specifies if there should be a separate pass for culling
  30655. */
  30656. separateCullingPass: boolean;
  30657. /**
  30658. * Stores the state specifying if fog should be enabled
  30659. */
  30660. private _fogEnabled;
  30661. /**
  30662. * Sets the state for enabling fog
  30663. */
  30664. set fogEnabled(value: boolean);
  30665. /**
  30666. * Gets the value of the fog enabled state
  30667. */
  30668. get fogEnabled(): boolean;
  30669. /**
  30670. * Stores the size of points
  30671. */
  30672. pointSize: number;
  30673. /**
  30674. * Stores the z offset value
  30675. */
  30676. zOffset: number;
  30677. get wireframe(): boolean;
  30678. /**
  30679. * Sets the state of wireframe mode
  30680. */
  30681. set wireframe(value: boolean);
  30682. /**
  30683. * Gets the value specifying if point clouds are enabled
  30684. */
  30685. get pointsCloud(): boolean;
  30686. /**
  30687. * Sets the state of point cloud mode
  30688. */
  30689. set pointsCloud(value: boolean);
  30690. /**
  30691. * Gets the material fill mode
  30692. */
  30693. get fillMode(): number;
  30694. /**
  30695. * Sets the material fill mode
  30696. */
  30697. set fillMode(value: number);
  30698. /**
  30699. * @hidden
  30700. * Stores the effects for the material
  30701. */
  30702. _effect: Nullable<Effect>;
  30703. /**
  30704. * Specifies if uniform buffers should be used
  30705. */
  30706. private _useUBO;
  30707. /**
  30708. * Stores a reference to the scene
  30709. */
  30710. private _scene;
  30711. private _needToBindSceneUbo;
  30712. /**
  30713. * Stores the fill mode state
  30714. */
  30715. private _fillMode;
  30716. /**
  30717. * Specifies if the depth write state should be cached
  30718. */
  30719. private _cachedDepthWriteState;
  30720. /**
  30721. * Specifies if the color write state should be cached
  30722. */
  30723. private _cachedColorWriteState;
  30724. /**
  30725. * Specifies if the depth function state should be cached
  30726. */
  30727. private _cachedDepthFunctionState;
  30728. /**
  30729. * Stores the uniform buffer
  30730. */
  30731. protected _uniformBuffer: UniformBuffer;
  30732. /** @hidden */
  30733. _indexInSceneMaterialArray: number;
  30734. /** @hidden */
  30735. meshMap: Nullable<{
  30736. [id: string]: AbstractMesh | undefined;
  30737. }>;
  30738. /**
  30739. * Creates a material instance
  30740. * @param name defines the name of the material
  30741. * @param scene defines the scene to reference
  30742. * @param doNotAdd specifies if the material should be added to the scene
  30743. */
  30744. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30745. /**
  30746. * Returns a string representation of the current material
  30747. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30748. * @returns a string with material information
  30749. */
  30750. toString(fullDetails?: boolean): string;
  30751. /**
  30752. * Gets the class name of the material
  30753. * @returns a string with the class name of the material
  30754. */
  30755. getClassName(): string;
  30756. /**
  30757. * Specifies if updates for the material been locked
  30758. */
  30759. get isFrozen(): boolean;
  30760. /**
  30761. * Locks updates for the material
  30762. */
  30763. freeze(): void;
  30764. /**
  30765. * Unlocks updates for the material
  30766. */
  30767. unfreeze(): void;
  30768. /**
  30769. * Specifies if the material is ready to be used
  30770. * @param mesh defines the mesh to check
  30771. * @param useInstances specifies if instances should be used
  30772. * @returns a boolean indicating if the material is ready to be used
  30773. */
  30774. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30775. /**
  30776. * Specifies that the submesh is ready to be used
  30777. * @param mesh defines the mesh to check
  30778. * @param subMesh defines which submesh to check
  30779. * @param useInstances specifies that instances should be used
  30780. * @returns a boolean indicating that the submesh is ready or not
  30781. */
  30782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30783. /**
  30784. * Returns the material effect
  30785. * @returns the effect associated with the material
  30786. */
  30787. getEffect(): Nullable<Effect>;
  30788. /**
  30789. * Returns the current scene
  30790. * @returns a Scene
  30791. */
  30792. getScene(): Scene;
  30793. /**
  30794. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30795. */
  30796. protected _forceAlphaTest: boolean;
  30797. /**
  30798. * The transparency mode of the material.
  30799. */
  30800. protected _transparencyMode: Nullable<number>;
  30801. /**
  30802. * Gets the current transparency mode.
  30803. */
  30804. get transparencyMode(): Nullable<number>;
  30805. /**
  30806. * Sets the transparency mode of the material.
  30807. *
  30808. * | Value | Type | Description |
  30809. * | ----- | ----------------------------------- | ----------- |
  30810. * | 0 | OPAQUE | |
  30811. * | 1 | ALPHATEST | |
  30812. * | 2 | ALPHABLEND | |
  30813. * | 3 | ALPHATESTANDBLEND | |
  30814. *
  30815. */
  30816. set transparencyMode(value: Nullable<number>);
  30817. /**
  30818. * Returns true if alpha blending should be disabled.
  30819. */
  30820. protected get _disableAlphaBlending(): boolean;
  30821. /**
  30822. * Specifies whether or not this material should be rendered in alpha blend mode.
  30823. * @returns a boolean specifying if alpha blending is needed
  30824. */
  30825. needAlphaBlending(): boolean;
  30826. /**
  30827. * Specifies if the mesh will require alpha blending
  30828. * @param mesh defines the mesh to check
  30829. * @returns a boolean specifying if alpha blending is needed for the mesh
  30830. */
  30831. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30832. /**
  30833. * Specifies whether or not this material should be rendered in alpha test mode.
  30834. * @returns a boolean specifying if an alpha test is needed.
  30835. */
  30836. needAlphaTesting(): boolean;
  30837. /**
  30838. * Specifies if material alpha testing should be turned on for the mesh
  30839. * @param mesh defines the mesh to check
  30840. */
  30841. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30842. /**
  30843. * Gets the texture used for the alpha test
  30844. * @returns the texture to use for alpha testing
  30845. */
  30846. getAlphaTestTexture(): Nullable<BaseTexture>;
  30847. /**
  30848. * Marks the material to indicate that it needs to be re-calculated
  30849. */
  30850. markDirty(): void;
  30851. /** @hidden */
  30852. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30853. /**
  30854. * Binds the material to the mesh
  30855. * @param world defines the world transformation matrix
  30856. * @param mesh defines the mesh to bind the material to
  30857. */
  30858. bind(world: Matrix, mesh?: Mesh): void;
  30859. /**
  30860. * Binds the submesh to the material
  30861. * @param world defines the world transformation matrix
  30862. * @param mesh defines the mesh containing the submesh
  30863. * @param subMesh defines the submesh to bind the material to
  30864. */
  30865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30866. /**
  30867. * Binds the world matrix to the material
  30868. * @param world defines the world transformation matrix
  30869. */
  30870. bindOnlyWorldMatrix(world: Matrix): void;
  30871. /**
  30872. * Binds the view matrix to the effect
  30873. * @param effect defines the effect to bind the view matrix to
  30874. */
  30875. bindView(effect: Effect): void;
  30876. /**
  30877. * Binds the view projection and projection matrices to the effect
  30878. * @param effect defines the effect to bind the view projection and projection matrices to
  30879. */
  30880. bindViewProjection(effect: Effect): void;
  30881. /**
  30882. * Binds the view matrix to the effect
  30883. * @param effect defines the effect to bind the view matrix to
  30884. * @param variableName name of the shader variable that will hold the eye position
  30885. */
  30886. bindEyePosition(effect: Effect, variableName?: string): void;
  30887. /**
  30888. * Processes to execute after binding the material to a mesh
  30889. * @param mesh defines the rendered mesh
  30890. */
  30891. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30892. /**
  30893. * Unbinds the material from the mesh
  30894. */
  30895. unbind(): void;
  30896. /**
  30897. * Gets the active textures from the material
  30898. * @returns an array of textures
  30899. */
  30900. getActiveTextures(): BaseTexture[];
  30901. /**
  30902. * Specifies if the material uses a texture
  30903. * @param texture defines the texture to check against the material
  30904. * @returns a boolean specifying if the material uses the texture
  30905. */
  30906. hasTexture(texture: BaseTexture): boolean;
  30907. /**
  30908. * Makes a duplicate of the material, and gives it a new name
  30909. * @param name defines the new name for the duplicated material
  30910. * @returns the cloned material
  30911. */
  30912. clone(name: string): Nullable<Material>;
  30913. /**
  30914. * Gets the meshes bound to the material
  30915. * @returns an array of meshes bound to the material
  30916. */
  30917. getBindedMeshes(): AbstractMesh[];
  30918. /**
  30919. * Force shader compilation
  30920. * @param mesh defines the mesh associated with this material
  30921. * @param onCompiled defines a function to execute once the material is compiled
  30922. * @param options defines the options to configure the compilation
  30923. * @param onError defines a function to execute if the material fails compiling
  30924. */
  30925. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30926. /**
  30927. * Force shader compilation
  30928. * @param mesh defines the mesh that will use this material
  30929. * @param options defines additional options for compiling the shaders
  30930. * @returns a promise that resolves when the compilation completes
  30931. */
  30932. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30933. private static readonly _AllDirtyCallBack;
  30934. private static readonly _ImageProcessingDirtyCallBack;
  30935. private static readonly _TextureDirtyCallBack;
  30936. private static readonly _FresnelDirtyCallBack;
  30937. private static readonly _MiscDirtyCallBack;
  30938. private static readonly _PrePassDirtyCallBack;
  30939. private static readonly _LightsDirtyCallBack;
  30940. private static readonly _AttributeDirtyCallBack;
  30941. private static _FresnelAndMiscDirtyCallBack;
  30942. private static _TextureAndMiscDirtyCallBack;
  30943. private static readonly _DirtyCallbackArray;
  30944. private static readonly _RunDirtyCallBacks;
  30945. /**
  30946. * Marks a define in the material to indicate that it needs to be re-computed
  30947. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30948. */
  30949. markAsDirty(flag: number): void;
  30950. /**
  30951. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30952. * @param func defines a function which checks material defines against the submeshes
  30953. */
  30954. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30955. /**
  30956. * Indicates that the scene should check if the rendering now needs a prepass
  30957. */
  30958. protected _markScenePrePassDirty(): void;
  30959. /**
  30960. * Indicates that we need to re-calculated for all submeshes
  30961. */
  30962. protected _markAllSubMeshesAsAllDirty(): void;
  30963. /**
  30964. * Indicates that image processing needs to be re-calculated for all submeshes
  30965. */
  30966. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30967. /**
  30968. * Indicates that textures need to be re-calculated for all submeshes
  30969. */
  30970. protected _markAllSubMeshesAsTexturesDirty(): void;
  30971. /**
  30972. * Indicates that fresnel needs to be re-calculated for all submeshes
  30973. */
  30974. protected _markAllSubMeshesAsFresnelDirty(): void;
  30975. /**
  30976. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30977. */
  30978. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30979. /**
  30980. * Indicates that lights need to be re-calculated for all submeshes
  30981. */
  30982. protected _markAllSubMeshesAsLightsDirty(): void;
  30983. /**
  30984. * Indicates that attributes need to be re-calculated for all submeshes
  30985. */
  30986. protected _markAllSubMeshesAsAttributesDirty(): void;
  30987. /**
  30988. * Indicates that misc needs to be re-calculated for all submeshes
  30989. */
  30990. protected _markAllSubMeshesAsMiscDirty(): void;
  30991. /**
  30992. * Indicates that prepass needs to be re-calculated for all submeshes
  30993. */
  30994. protected _markAllSubMeshesAsPrePassDirty(): void;
  30995. /**
  30996. * Indicates that textures and misc need to be re-calculated for all submeshes
  30997. */
  30998. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30999. /**
  31000. * Sets the required values to the prepass renderer.
  31001. * @param prePassRenderer defines the prepass renderer to setup.
  31002. * @returns true if the pre pass is needed.
  31003. */
  31004. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31005. /**
  31006. * Disposes the material
  31007. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31008. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31009. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31010. */
  31011. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31012. /** @hidden */
  31013. private releaseVertexArrayObject;
  31014. /**
  31015. * Serializes this material
  31016. * @returns the serialized material object
  31017. */
  31018. serialize(): any;
  31019. /**
  31020. * Creates a material from parsed material data
  31021. * @param parsedMaterial defines parsed material data
  31022. * @param scene defines the hosting scene
  31023. * @param rootUrl defines the root URL to use to load textures
  31024. * @returns a new material
  31025. */
  31026. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31027. }
  31028. }
  31029. declare module BABYLON {
  31030. /**
  31031. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31032. * separate meshes. This can be use to improve performances.
  31033. * @see https://doc.babylonjs.com/how_to/multi_materials
  31034. */
  31035. export class MultiMaterial extends Material {
  31036. private _subMaterials;
  31037. /**
  31038. * Gets or Sets the list of Materials used within the multi material.
  31039. * They need to be ordered according to the submeshes order in the associated mesh
  31040. */
  31041. get subMaterials(): Nullable<Material>[];
  31042. set subMaterials(value: Nullable<Material>[]);
  31043. /**
  31044. * Function used to align with Node.getChildren()
  31045. * @returns the list of Materials used within the multi material
  31046. */
  31047. getChildren(): Nullable<Material>[];
  31048. /**
  31049. * Instantiates a new Multi Material
  31050. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31051. * separate meshes. This can be use to improve performances.
  31052. * @see https://doc.babylonjs.com/how_to/multi_materials
  31053. * @param name Define the name in the scene
  31054. * @param scene Define the scene the material belongs to
  31055. */
  31056. constructor(name: string, scene: Scene);
  31057. private _hookArray;
  31058. /**
  31059. * Get one of the submaterial by its index in the submaterials array
  31060. * @param index The index to look the sub material at
  31061. * @returns The Material if the index has been defined
  31062. */
  31063. getSubMaterial(index: number): Nullable<Material>;
  31064. /**
  31065. * Get the list of active textures for the whole sub materials list.
  31066. * @returns All the textures that will be used during the rendering
  31067. */
  31068. getActiveTextures(): BaseTexture[];
  31069. /**
  31070. * Specifies if any sub-materials of this multi-material use a given texture.
  31071. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31072. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31073. */
  31074. hasTexture(texture: BaseTexture): boolean;
  31075. /**
  31076. * Gets the current class name of the material e.g. "MultiMaterial"
  31077. * Mainly use in serialization.
  31078. * @returns the class name
  31079. */
  31080. getClassName(): string;
  31081. /**
  31082. * Checks if the material is ready to render the requested sub mesh
  31083. * @param mesh Define the mesh the submesh belongs to
  31084. * @param subMesh Define the sub mesh to look readiness for
  31085. * @param useInstances Define whether or not the material is used with instances
  31086. * @returns true if ready, otherwise false
  31087. */
  31088. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31089. /**
  31090. * Clones the current material and its related sub materials
  31091. * @param name Define the name of the newly cloned material
  31092. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31093. * @returns the cloned material
  31094. */
  31095. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31096. /**
  31097. * Serializes the materials into a JSON representation.
  31098. * @returns the JSON representation
  31099. */
  31100. serialize(): any;
  31101. /**
  31102. * Dispose the material and release its associated resources
  31103. * @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)
  31104. * @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)
  31105. * @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)
  31106. */
  31107. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31108. /**
  31109. * Creates a MultiMaterial from parsed MultiMaterial data.
  31110. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31111. * @param scene defines the hosting scene
  31112. * @returns a new MultiMaterial
  31113. */
  31114. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31115. }
  31116. }
  31117. declare module BABYLON {
  31118. /** @hidden */
  31119. export interface ICustomEffect {
  31120. effect: Effect;
  31121. defines: string;
  31122. }
  31123. /**
  31124. * Defines a subdivision inside a mesh
  31125. */
  31126. export class SubMesh implements ICullable {
  31127. /** the material index to use */
  31128. materialIndex: number;
  31129. /** vertex index start */
  31130. verticesStart: number;
  31131. /** vertices count */
  31132. verticesCount: number;
  31133. /** index start */
  31134. indexStart: number;
  31135. /** indices count */
  31136. indexCount: number;
  31137. /** @hidden */
  31138. _materialDefines: Nullable<MaterialDefines>;
  31139. /** @hidden */
  31140. _materialEffect: Nullable<Effect>;
  31141. /** @hidden */
  31142. _effectOverride: Nullable<Effect>;
  31143. private _customEffects;
  31144. /**
  31145. * Gets material defines used by the effect associated to the sub mesh
  31146. */
  31147. get materialDefines(): Nullable<MaterialDefines>;
  31148. /**
  31149. * Sets material defines used by the effect associated to the sub mesh
  31150. */
  31151. set materialDefines(defines: Nullable<MaterialDefines>);
  31152. /** @hidden */
  31153. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  31154. /** @hidden */
  31155. _removeCustomEffect(name: string): void;
  31156. /**
  31157. * Gets associated effect
  31158. */
  31159. get effect(): Nullable<Effect>;
  31160. /**
  31161. * Sets associated effect (effect used to render this submesh)
  31162. * @param effect defines the effect to associate with
  31163. * @param defines defines the set of defines used to compile this effect
  31164. */
  31165. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31166. /** @hidden */
  31167. _linesIndexCount: number;
  31168. private _mesh;
  31169. private _renderingMesh;
  31170. private _boundingInfo;
  31171. private _linesIndexBuffer;
  31172. /** @hidden */
  31173. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31174. /** @hidden */
  31175. _trianglePlanes: Plane[];
  31176. /** @hidden */
  31177. _lastColliderTransformMatrix: Nullable<Matrix>;
  31178. /** @hidden */
  31179. _renderId: number;
  31180. /** @hidden */
  31181. _alphaIndex: number;
  31182. /** @hidden */
  31183. _distanceToCamera: number;
  31184. /** @hidden */
  31185. _id: number;
  31186. private _currentMaterial;
  31187. /**
  31188. * Add a new submesh to a mesh
  31189. * @param materialIndex defines the material index to use
  31190. * @param verticesStart defines vertex index start
  31191. * @param verticesCount defines vertices count
  31192. * @param indexStart defines index start
  31193. * @param indexCount defines indices count
  31194. * @param mesh defines the parent mesh
  31195. * @param renderingMesh defines an optional rendering mesh
  31196. * @param createBoundingBox defines if bounding box should be created for this submesh
  31197. * @returns the new submesh
  31198. */
  31199. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31200. /**
  31201. * Creates a new submesh
  31202. * @param materialIndex defines the material index to use
  31203. * @param verticesStart defines vertex index start
  31204. * @param verticesCount defines vertices count
  31205. * @param indexStart defines index start
  31206. * @param indexCount defines indices count
  31207. * @param mesh defines the parent mesh
  31208. * @param renderingMesh defines an optional rendering mesh
  31209. * @param createBoundingBox defines if bounding box should be created for this submesh
  31210. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31211. */
  31212. constructor(
  31213. /** the material index to use */
  31214. materialIndex: number,
  31215. /** vertex index start */
  31216. verticesStart: number,
  31217. /** vertices count */
  31218. verticesCount: number,
  31219. /** index start */
  31220. indexStart: number,
  31221. /** indices count */
  31222. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31223. /**
  31224. * Returns true if this submesh covers the entire parent mesh
  31225. * @ignorenaming
  31226. */
  31227. get IsGlobal(): boolean;
  31228. /**
  31229. * Returns the submesh BoundingInfo object
  31230. * @returns current bounding info (or mesh's one if the submesh is global)
  31231. */
  31232. getBoundingInfo(): BoundingInfo;
  31233. /**
  31234. * Sets the submesh BoundingInfo
  31235. * @param boundingInfo defines the new bounding info to use
  31236. * @returns the SubMesh
  31237. */
  31238. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31239. /**
  31240. * Returns the mesh of the current submesh
  31241. * @return the parent mesh
  31242. */
  31243. getMesh(): AbstractMesh;
  31244. /**
  31245. * Returns the rendering mesh of the submesh
  31246. * @returns the rendering mesh (could be different from parent mesh)
  31247. */
  31248. getRenderingMesh(): Mesh;
  31249. /**
  31250. * Returns the replacement mesh of the submesh
  31251. * @returns the replacement mesh (could be different from parent mesh)
  31252. */
  31253. getReplacementMesh(): Nullable<AbstractMesh>;
  31254. /**
  31255. * Returns the effective mesh of the submesh
  31256. * @returns the effective mesh (could be different from parent mesh)
  31257. */
  31258. getEffectiveMesh(): AbstractMesh;
  31259. /**
  31260. * Returns the submesh material
  31261. * @returns null or the current material
  31262. */
  31263. getMaterial(): Nullable<Material>;
  31264. private _IsMultiMaterial;
  31265. /**
  31266. * Sets a new updated BoundingInfo object to the submesh
  31267. * @param data defines an optional position array to use to determine the bounding info
  31268. * @returns the SubMesh
  31269. */
  31270. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31271. /** @hidden */
  31272. _checkCollision(collider: Collider): boolean;
  31273. /**
  31274. * Updates the submesh BoundingInfo
  31275. * @param world defines the world matrix to use to update the bounding info
  31276. * @returns the submesh
  31277. */
  31278. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31279. /**
  31280. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31281. * @param frustumPlanes defines the frustum planes
  31282. * @returns true if the submesh is intersecting with the frustum
  31283. */
  31284. isInFrustum(frustumPlanes: Plane[]): boolean;
  31285. /**
  31286. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31287. * @param frustumPlanes defines the frustum planes
  31288. * @returns true if the submesh is inside the frustum
  31289. */
  31290. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31291. /**
  31292. * Renders the submesh
  31293. * @param enableAlphaMode defines if alpha needs to be used
  31294. * @returns the submesh
  31295. */
  31296. render(enableAlphaMode: boolean): SubMesh;
  31297. /**
  31298. * @hidden
  31299. */
  31300. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31301. /**
  31302. * Checks if the submesh intersects with a ray
  31303. * @param ray defines the ray to test
  31304. * @returns true is the passed ray intersects the submesh bounding box
  31305. */
  31306. canIntersects(ray: Ray): boolean;
  31307. /**
  31308. * Intersects current submesh with a ray
  31309. * @param ray defines the ray to test
  31310. * @param positions defines mesh's positions array
  31311. * @param indices defines mesh's indices array
  31312. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31313. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31314. * @returns intersection info or null if no intersection
  31315. */
  31316. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31317. /** @hidden */
  31318. private _intersectLines;
  31319. /** @hidden */
  31320. private _intersectUnIndexedLines;
  31321. /** @hidden */
  31322. private _intersectTriangles;
  31323. /** @hidden */
  31324. private _intersectUnIndexedTriangles;
  31325. /** @hidden */
  31326. _rebuild(): void;
  31327. /**
  31328. * Creates a new submesh from the passed mesh
  31329. * @param newMesh defines the new hosting mesh
  31330. * @param newRenderingMesh defines an optional rendering mesh
  31331. * @returns the new submesh
  31332. */
  31333. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31334. /**
  31335. * Release associated resources
  31336. */
  31337. dispose(): void;
  31338. /**
  31339. * Gets the class name
  31340. * @returns the string "SubMesh".
  31341. */
  31342. getClassName(): string;
  31343. /**
  31344. * Creates a new submesh from indices data
  31345. * @param materialIndex the index of the main mesh material
  31346. * @param startIndex the index where to start the copy in the mesh indices array
  31347. * @param indexCount the number of indices to copy then from the startIndex
  31348. * @param mesh the main mesh to create the submesh from
  31349. * @param renderingMesh the optional rendering mesh
  31350. * @returns a new submesh
  31351. */
  31352. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31353. }
  31354. }
  31355. declare module BABYLON {
  31356. /**
  31357. * Class used to represent data loading progression
  31358. */
  31359. export class SceneLoaderFlags {
  31360. private static _ForceFullSceneLoadingForIncremental;
  31361. private static _ShowLoadingScreen;
  31362. private static _CleanBoneMatrixWeights;
  31363. private static _loggingLevel;
  31364. /**
  31365. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31366. */
  31367. static get ForceFullSceneLoadingForIncremental(): boolean;
  31368. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31369. /**
  31370. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31371. */
  31372. static get ShowLoadingScreen(): boolean;
  31373. static set ShowLoadingScreen(value: boolean);
  31374. /**
  31375. * Defines the current logging level (while loading the scene)
  31376. * @ignorenaming
  31377. */
  31378. static get loggingLevel(): number;
  31379. static set loggingLevel(value: number);
  31380. /**
  31381. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31382. */
  31383. static get CleanBoneMatrixWeights(): boolean;
  31384. static set CleanBoneMatrixWeights(value: boolean);
  31385. }
  31386. }
  31387. declare module BABYLON {
  31388. /**
  31389. * Class used to store geometry data (vertex buffers + index buffer)
  31390. */
  31391. export class Geometry implements IGetSetVerticesData {
  31392. /**
  31393. * Gets or sets the ID of the geometry
  31394. */
  31395. id: string;
  31396. /**
  31397. * Gets or sets the unique ID of the geometry
  31398. */
  31399. uniqueId: number;
  31400. /**
  31401. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31402. */
  31403. delayLoadState: number;
  31404. /**
  31405. * Gets the file containing the data to load when running in delay load state
  31406. */
  31407. delayLoadingFile: Nullable<string>;
  31408. /**
  31409. * Callback called when the geometry is updated
  31410. */
  31411. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31412. private _scene;
  31413. private _engine;
  31414. private _meshes;
  31415. private _totalVertices;
  31416. /** @hidden */
  31417. _indices: IndicesArray;
  31418. /** @hidden */
  31419. _vertexBuffers: {
  31420. [key: string]: VertexBuffer;
  31421. };
  31422. private _isDisposed;
  31423. private _extend;
  31424. private _boundingBias;
  31425. /** @hidden */
  31426. _delayInfo: Array<string>;
  31427. private _indexBuffer;
  31428. private _indexBufferIsUpdatable;
  31429. /** @hidden */
  31430. _boundingInfo: Nullable<BoundingInfo>;
  31431. /** @hidden */
  31432. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31433. /** @hidden */
  31434. _softwareSkinningFrameId: number;
  31435. private _vertexArrayObjects;
  31436. private _updatable;
  31437. /** @hidden */
  31438. _positions: Nullable<Vector3[]>;
  31439. private _positionsCache;
  31440. /**
  31441. * 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
  31442. */
  31443. get boundingBias(): Vector2;
  31444. /**
  31445. * 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
  31446. */
  31447. set boundingBias(value: Vector2);
  31448. /**
  31449. * Static function used to attach a new empty geometry to a mesh
  31450. * @param mesh defines the mesh to attach the geometry to
  31451. * @returns the new Geometry
  31452. */
  31453. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31454. /** Get the list of meshes using this geometry */
  31455. get meshes(): Mesh[];
  31456. /**
  31457. * 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
  31458. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31459. */
  31460. useBoundingInfoFromGeometry: boolean;
  31461. /**
  31462. * Creates a new geometry
  31463. * @param id defines the unique ID
  31464. * @param scene defines the hosting scene
  31465. * @param vertexData defines the VertexData used to get geometry data
  31466. * @param updatable defines if geometry must be updatable (false by default)
  31467. * @param mesh defines the mesh that will be associated with the geometry
  31468. */
  31469. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31470. /**
  31471. * Gets the current extend of the geometry
  31472. */
  31473. get extend(): {
  31474. minimum: Vector3;
  31475. maximum: Vector3;
  31476. };
  31477. /**
  31478. * Gets the hosting scene
  31479. * @returns the hosting Scene
  31480. */
  31481. getScene(): Scene;
  31482. /**
  31483. * Gets the hosting engine
  31484. * @returns the hosting Engine
  31485. */
  31486. getEngine(): Engine;
  31487. /**
  31488. * Defines if the geometry is ready to use
  31489. * @returns true if the geometry is ready to be used
  31490. */
  31491. isReady(): boolean;
  31492. /**
  31493. * Gets a value indicating that the geometry should not be serialized
  31494. */
  31495. get doNotSerialize(): boolean;
  31496. /** @hidden */
  31497. _rebuild(): void;
  31498. /**
  31499. * Affects all geometry data in one call
  31500. * @param vertexData defines the geometry data
  31501. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31502. */
  31503. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31504. /**
  31505. * Set specific vertex data
  31506. * @param kind defines the data kind (Position, normal, etc...)
  31507. * @param data defines the vertex data to use
  31508. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31509. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31510. */
  31511. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31512. /**
  31513. * Removes a specific vertex data
  31514. * @param kind defines the data kind (Position, normal, etc...)
  31515. */
  31516. removeVerticesData(kind: string): void;
  31517. /**
  31518. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31519. * @param buffer defines the vertex buffer to use
  31520. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31521. */
  31522. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31523. /**
  31524. * Update a specific vertex buffer
  31525. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31526. * It will do nothing if the buffer is not updatable
  31527. * @param kind defines the data kind (Position, normal, etc...)
  31528. * @param data defines the data to use
  31529. * @param offset defines the offset in the target buffer where to store the data
  31530. * @param useBytes set to true if the offset is in bytes
  31531. */
  31532. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31533. /**
  31534. * Update a specific vertex buffer
  31535. * This function will create a new buffer if the current one is not updatable
  31536. * @param kind defines the data kind (Position, normal, etc...)
  31537. * @param data defines the data to use
  31538. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31539. */
  31540. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31541. private _updateBoundingInfo;
  31542. /** @hidden */
  31543. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>, overrideVertexBuffers?: {
  31544. [kind: string]: Nullable<VertexBuffer>;
  31545. }, overrideVertexArrayObjects?: {
  31546. [key: string]: WebGLVertexArrayObject;
  31547. }): void;
  31548. /**
  31549. * Gets total number of vertices
  31550. * @returns the total number of vertices
  31551. */
  31552. getTotalVertices(): number;
  31553. /**
  31554. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31555. * @param kind defines the data kind (Position, normal, etc...)
  31556. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31557. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31558. * @returns a float array containing vertex data
  31559. */
  31560. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31561. /**
  31562. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31563. * @param kind defines the data kind (Position, normal, etc...)
  31564. * @returns true if the vertex buffer with the specified kind is updatable
  31565. */
  31566. isVertexBufferUpdatable(kind: string): boolean;
  31567. /**
  31568. * Gets a specific vertex buffer
  31569. * @param kind defines the data kind (Position, normal, etc...)
  31570. * @returns a VertexBuffer
  31571. */
  31572. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31573. /**
  31574. * Returns all vertex buffers
  31575. * @return an object holding all vertex buffers indexed by kind
  31576. */
  31577. getVertexBuffers(): Nullable<{
  31578. [key: string]: VertexBuffer;
  31579. }>;
  31580. /**
  31581. * Gets a boolean indicating if specific vertex buffer is present
  31582. * @param kind defines the data kind (Position, normal, etc...)
  31583. * @returns true if data is present
  31584. */
  31585. isVerticesDataPresent(kind: string): boolean;
  31586. /**
  31587. * Gets a list of all attached data kinds (Position, normal, etc...)
  31588. * @returns a list of string containing all kinds
  31589. */
  31590. getVerticesDataKinds(): string[];
  31591. /**
  31592. * Update index buffer
  31593. * @param indices defines the indices to store in the index buffer
  31594. * @param offset defines the offset in the target buffer where to store the data
  31595. * @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)
  31596. */
  31597. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31598. /**
  31599. * Creates a new index buffer
  31600. * @param indices defines the indices to store in the index buffer
  31601. * @param totalVertices defines the total number of vertices (could be null)
  31602. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31603. */
  31604. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31605. /**
  31606. * Return the total number of indices
  31607. * @returns the total number of indices
  31608. */
  31609. getTotalIndices(): number;
  31610. /**
  31611. * Gets the index buffer array
  31612. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31613. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31614. * @returns the index buffer array
  31615. */
  31616. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31617. /**
  31618. * Gets the index buffer
  31619. * @return the index buffer
  31620. */
  31621. getIndexBuffer(): Nullable<DataBuffer>;
  31622. /** @hidden */
  31623. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31624. /**
  31625. * Release the associated resources for a specific mesh
  31626. * @param mesh defines the source mesh
  31627. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31628. */
  31629. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31630. /**
  31631. * Apply current geometry to a given mesh
  31632. * @param mesh defines the mesh to apply geometry to
  31633. */
  31634. applyToMesh(mesh: Mesh): void;
  31635. private _updateExtend;
  31636. private _applyToMesh;
  31637. private notifyUpdate;
  31638. /**
  31639. * Load the geometry if it was flagged as delay loaded
  31640. * @param scene defines the hosting scene
  31641. * @param onLoaded defines a callback called when the geometry is loaded
  31642. */
  31643. load(scene: Scene, onLoaded?: () => void): void;
  31644. private _queueLoad;
  31645. /**
  31646. * Invert the geometry to move from a right handed system to a left handed one.
  31647. */
  31648. toLeftHanded(): void;
  31649. /** @hidden */
  31650. _resetPointsArrayCache(): void;
  31651. /** @hidden */
  31652. _generatePointsArray(): boolean;
  31653. /**
  31654. * Gets a value indicating if the geometry is disposed
  31655. * @returns true if the geometry was disposed
  31656. */
  31657. isDisposed(): boolean;
  31658. private _disposeVertexArrayObjects;
  31659. /**
  31660. * Free all associated resources
  31661. */
  31662. dispose(): void;
  31663. /**
  31664. * Clone the current geometry into a new geometry
  31665. * @param id defines the unique ID of the new geometry
  31666. * @returns a new geometry object
  31667. */
  31668. copy(id: string): Geometry;
  31669. /**
  31670. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31671. * @return a JSON representation of the current geometry data (without the vertices data)
  31672. */
  31673. serialize(): any;
  31674. private toNumberArray;
  31675. /**
  31676. * Serialize all vertices data into a JSON object
  31677. * @returns a JSON representation of the current geometry data
  31678. */
  31679. serializeVerticeData(): any;
  31680. /**
  31681. * Extracts a clone of a mesh geometry
  31682. * @param mesh defines the source mesh
  31683. * @param id defines the unique ID of the new geometry object
  31684. * @returns the new geometry object
  31685. */
  31686. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31687. /**
  31688. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31689. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31690. * Be aware Math.random() could cause collisions, but:
  31691. * "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"
  31692. * @returns a string containing a new GUID
  31693. */
  31694. static RandomId(): string;
  31695. /** @hidden */
  31696. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31697. private static _CleanMatricesWeights;
  31698. /**
  31699. * Create a new geometry from persisted data (Using .babylon file format)
  31700. * @param parsedVertexData defines the persisted data
  31701. * @param scene defines the hosting scene
  31702. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31703. * @returns the new geometry object
  31704. */
  31705. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31706. }
  31707. }
  31708. declare module BABYLON {
  31709. /**
  31710. * Defines a target to use with MorphTargetManager
  31711. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31712. */
  31713. export class MorphTarget implements IAnimatable {
  31714. /** defines the name of the target */
  31715. name: string;
  31716. /**
  31717. * Gets or sets the list of animations
  31718. */
  31719. animations: Animation[];
  31720. private _scene;
  31721. private _positions;
  31722. private _normals;
  31723. private _tangents;
  31724. private _uvs;
  31725. private _influence;
  31726. private _uniqueId;
  31727. /**
  31728. * Observable raised when the influence changes
  31729. */
  31730. onInfluenceChanged: Observable<boolean>;
  31731. /** @hidden */
  31732. _onDataLayoutChanged: Observable<void>;
  31733. /**
  31734. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31735. */
  31736. get influence(): number;
  31737. set influence(influence: number);
  31738. /**
  31739. * Gets or sets the id of the morph Target
  31740. */
  31741. id: string;
  31742. private _animationPropertiesOverride;
  31743. /**
  31744. * Gets or sets the animation properties override
  31745. */
  31746. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31747. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31748. /**
  31749. * Creates a new MorphTarget
  31750. * @param name defines the name of the target
  31751. * @param influence defines the influence to use
  31752. * @param scene defines the scene the morphtarget belongs to
  31753. */
  31754. constructor(
  31755. /** defines the name of the target */
  31756. name: string, influence?: number, scene?: Nullable<Scene>);
  31757. /**
  31758. * Gets the unique ID of this manager
  31759. */
  31760. get uniqueId(): number;
  31761. /**
  31762. * Gets a boolean defining if the target contains position data
  31763. */
  31764. get hasPositions(): boolean;
  31765. /**
  31766. * Gets a boolean defining if the target contains normal data
  31767. */
  31768. get hasNormals(): boolean;
  31769. /**
  31770. * Gets a boolean defining if the target contains tangent data
  31771. */
  31772. get hasTangents(): boolean;
  31773. /**
  31774. * Gets a boolean defining if the target contains texture coordinates data
  31775. */
  31776. get hasUVs(): boolean;
  31777. /**
  31778. * Affects position data to this target
  31779. * @param data defines the position data to use
  31780. */
  31781. setPositions(data: Nullable<FloatArray>): void;
  31782. /**
  31783. * Gets the position data stored in this target
  31784. * @returns a FloatArray containing the position data (or null if not present)
  31785. */
  31786. getPositions(): Nullable<FloatArray>;
  31787. /**
  31788. * Affects normal data to this target
  31789. * @param data defines the normal data to use
  31790. */
  31791. setNormals(data: Nullable<FloatArray>): void;
  31792. /**
  31793. * Gets the normal data stored in this target
  31794. * @returns a FloatArray containing the normal data (or null if not present)
  31795. */
  31796. getNormals(): Nullable<FloatArray>;
  31797. /**
  31798. * Affects tangent data to this target
  31799. * @param data defines the tangent data to use
  31800. */
  31801. setTangents(data: Nullable<FloatArray>): void;
  31802. /**
  31803. * Gets the tangent data stored in this target
  31804. * @returns a FloatArray containing the tangent data (or null if not present)
  31805. */
  31806. getTangents(): Nullable<FloatArray>;
  31807. /**
  31808. * Affects texture coordinates data to this target
  31809. * @param data defines the texture coordinates data to use
  31810. */
  31811. setUVs(data: Nullable<FloatArray>): void;
  31812. /**
  31813. * Gets the texture coordinates data stored in this target
  31814. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31815. */
  31816. getUVs(): Nullable<FloatArray>;
  31817. /**
  31818. * Clone the current target
  31819. * @returns a new MorphTarget
  31820. */
  31821. clone(): MorphTarget;
  31822. /**
  31823. * Serializes the current target into a Serialization object
  31824. * @returns the serialized object
  31825. */
  31826. serialize(): any;
  31827. /**
  31828. * Returns the string "MorphTarget"
  31829. * @returns "MorphTarget"
  31830. */
  31831. getClassName(): string;
  31832. /**
  31833. * Creates a new target from serialized data
  31834. * @param serializationObject defines the serialized data to use
  31835. * @returns a new MorphTarget
  31836. */
  31837. static Parse(serializationObject: any): MorphTarget;
  31838. /**
  31839. * Creates a MorphTarget from mesh data
  31840. * @param mesh defines the source mesh
  31841. * @param name defines the name to use for the new target
  31842. * @param influence defines the influence to attach to the target
  31843. * @returns a new MorphTarget
  31844. */
  31845. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31846. }
  31847. }
  31848. declare module BABYLON {
  31849. /**
  31850. * Class used to store 2D array textures containing user data
  31851. */
  31852. export class RawTexture2DArray extends Texture {
  31853. /** Gets or sets the texture format to use */
  31854. format: number;
  31855. private _depth;
  31856. /**
  31857. * Gets the number of layers of the texture
  31858. */
  31859. get depth(): number;
  31860. /**
  31861. * Create a new RawTexture2DArray
  31862. * @param data defines the data of the texture
  31863. * @param width defines the width of the texture
  31864. * @param height defines the height of the texture
  31865. * @param depth defines the number of layers of the texture
  31866. * @param format defines the texture format to use
  31867. * @param scene defines the hosting scene
  31868. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  31869. * @param invertY defines if texture must be stored with Y axis inverted
  31870. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  31871. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  31872. */
  31873. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  31874. /** Gets or sets the texture format to use */
  31875. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  31876. /**
  31877. * Update the texture with new data
  31878. * @param data defines the data to store in the texture
  31879. */
  31880. update(data: ArrayBufferView): void;
  31881. /**
  31882. * Creates a RGBA texture from some data.
  31883. * @param data Define the texture data
  31884. * @param width Define the width of the texture
  31885. * @param height Define the height of the texture
  31886. * @param depth defines the number of layers of the texture
  31887. * @param scene defines the scene the texture will belong to
  31888. * @param generateMipMaps Define whether or not to create mip maps for the texture
  31889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  31890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  31891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  31892. * @returns the RGBA texture
  31893. */
  31894. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, depth: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture2DArray;
  31895. }
  31896. }
  31897. declare module BABYLON {
  31898. /**
  31899. * This class is used to deform meshes using morphing between different targets
  31900. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31901. */
  31902. export class MorphTargetManager implements IDisposable {
  31903. private _targets;
  31904. private _targetInfluenceChangedObservers;
  31905. private _targetDataLayoutChangedObservers;
  31906. private _activeTargets;
  31907. private _scene;
  31908. private _influences;
  31909. private _supportsNormals;
  31910. private _supportsTangents;
  31911. private _supportsUVs;
  31912. private _vertexCount;
  31913. private _textureVertexStride;
  31914. private _textureWidth;
  31915. private _textureHeight;
  31916. private _uniqueId;
  31917. private _tempInfluences;
  31918. private _canUseTextureForTargets;
  31919. /** @hidden */
  31920. _targetStoreTexture: Nullable<RawTexture2DArray>;
  31921. /**
  31922. * Gets or sets a boolean indicating if normals must be morphed
  31923. */
  31924. enableNormalMorphing: boolean;
  31925. /**
  31926. * Gets or sets a boolean indicating if tangents must be morphed
  31927. */
  31928. enableTangentMorphing: boolean;
  31929. /**
  31930. * Gets or sets a boolean indicating if UV must be morphed
  31931. */
  31932. enableUVMorphing: boolean;
  31933. /**
  31934. * Creates a new MorphTargetManager
  31935. * @param scene defines the current scene
  31936. */
  31937. constructor(scene?: Nullable<Scene>);
  31938. /**
  31939. * Gets the unique ID of this manager
  31940. */
  31941. get uniqueId(): number;
  31942. /**
  31943. * Gets the number of vertices handled by this manager
  31944. */
  31945. get vertexCount(): number;
  31946. /**
  31947. * Gets a boolean indicating if this manager supports morphing of normals
  31948. */
  31949. get supportsNormals(): boolean;
  31950. /**
  31951. * Gets a boolean indicating if this manager supports morphing of tangents
  31952. */
  31953. get supportsTangents(): boolean;
  31954. /**
  31955. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31956. */
  31957. get supportsUVs(): boolean;
  31958. /**
  31959. * Gets the number of targets stored in this manager
  31960. */
  31961. get numTargets(): number;
  31962. /**
  31963. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31964. */
  31965. get numInfluencers(): number;
  31966. /**
  31967. * Gets the list of influences (one per target)
  31968. */
  31969. get influences(): Float32Array;
  31970. private _useTextureToStoreTargets;
  31971. /**
  31972. * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true).
  31973. * Please note that this option is not available if the hardware does not support it
  31974. */
  31975. get useTextureToStoreTargets(): boolean;
  31976. set useTextureToStoreTargets(value: boolean);
  31977. /**
  31978. * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes)
  31979. */
  31980. get isUsingTextureForTargets(): boolean;
  31981. /**
  31982. * Gets the active target at specified index. An active target is a target with an influence > 0
  31983. * @param index defines the index to check
  31984. * @returns the requested target
  31985. */
  31986. getActiveTarget(index: number): MorphTarget;
  31987. /**
  31988. * Gets the target at specified index
  31989. * @param index defines the index to check
  31990. * @returns the requested target
  31991. */
  31992. getTarget(index: number): MorphTarget;
  31993. /**
  31994. * Add a new target to this manager
  31995. * @param target defines the target to add
  31996. */
  31997. addTarget(target: MorphTarget): void;
  31998. /**
  31999. * Removes a target from the manager
  32000. * @param target defines the target to remove
  32001. */
  32002. removeTarget(target: MorphTarget): void;
  32003. /** @hidden */
  32004. _bind(effect: Effect): void;
  32005. /**
  32006. * Clone the current manager
  32007. * @returns a new MorphTargetManager
  32008. */
  32009. clone(): MorphTargetManager;
  32010. /**
  32011. * Serializes the current manager into a Serialization object
  32012. * @returns the serialized object
  32013. */
  32014. serialize(): any;
  32015. private _syncActiveTargets;
  32016. /**
  32017. * Synchronize the targets with all the meshes using this morph target manager
  32018. */
  32019. synchronize(): void;
  32020. /**
  32021. * Release all resources
  32022. */
  32023. dispose(): void;
  32024. /**
  32025. * Creates a new MorphTargetManager from serialized data
  32026. * @param serializationObject defines the serialized data
  32027. * @param scene defines the hosting scene
  32028. * @returns the new MorphTargetManager
  32029. */
  32030. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32031. }
  32032. }
  32033. declare module BABYLON {
  32034. /**
  32035. * Class used to represent a specific level of detail of a mesh
  32036. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32037. */
  32038. export class MeshLODLevel {
  32039. /** Defines the distance where this level should start being displayed */
  32040. distance: number;
  32041. /** Defines the mesh to use to render this level */
  32042. mesh: Nullable<Mesh>;
  32043. /**
  32044. * Creates a new LOD level
  32045. * @param distance defines the distance where this level should star being displayed
  32046. * @param mesh defines the mesh to use to render this level
  32047. */
  32048. constructor(
  32049. /** Defines the distance where this level should start being displayed */
  32050. distance: number,
  32051. /** Defines the mesh to use to render this level */
  32052. mesh: Nullable<Mesh>);
  32053. }
  32054. }
  32055. declare module BABYLON {
  32056. /**
  32057. * Helper class used to generate a canvas to manipulate images
  32058. */
  32059. export class CanvasGenerator {
  32060. /**
  32061. * Create a new canvas (or offscreen canvas depending on the context)
  32062. * @param width defines the expected width
  32063. * @param height defines the expected height
  32064. * @return a new canvas or offscreen canvas
  32065. */
  32066. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32067. }
  32068. }
  32069. declare module BABYLON {
  32070. /**
  32071. * Mesh representing the ground
  32072. */
  32073. export class GroundMesh extends Mesh {
  32074. /** If octree should be generated */
  32075. generateOctree: boolean;
  32076. private _heightQuads;
  32077. /** @hidden */
  32078. _subdivisionsX: number;
  32079. /** @hidden */
  32080. _subdivisionsY: number;
  32081. /** @hidden */
  32082. _width: number;
  32083. /** @hidden */
  32084. _height: number;
  32085. /** @hidden */
  32086. _minX: number;
  32087. /** @hidden */
  32088. _maxX: number;
  32089. /** @hidden */
  32090. _minZ: number;
  32091. /** @hidden */
  32092. _maxZ: number;
  32093. constructor(name: string, scene: Scene);
  32094. /**
  32095. * "GroundMesh"
  32096. * @returns "GroundMesh"
  32097. */
  32098. getClassName(): string;
  32099. /**
  32100. * The minimum of x and y subdivisions
  32101. */
  32102. get subdivisions(): number;
  32103. /**
  32104. * X subdivisions
  32105. */
  32106. get subdivisionsX(): number;
  32107. /**
  32108. * Y subdivisions
  32109. */
  32110. get subdivisionsY(): number;
  32111. /**
  32112. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32113. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32114. * @param chunksCount the number of subdivisions for x and y
  32115. * @param octreeBlocksSize (Default: 32)
  32116. */
  32117. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32118. /**
  32119. * Returns a height (y) value in the World system :
  32120. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32121. * @param x x coordinate
  32122. * @param z z coordinate
  32123. * @returns the ground y position if (x, z) are outside the ground surface.
  32124. */
  32125. getHeightAtCoordinates(x: number, z: number): number;
  32126. /**
  32127. * Returns a normalized vector (Vector3) orthogonal to the ground
  32128. * at the ground coordinates (x, z) expressed in the World system.
  32129. * @param x x coordinate
  32130. * @param z z coordinate
  32131. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32132. */
  32133. getNormalAtCoordinates(x: number, z: number): Vector3;
  32134. /**
  32135. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32136. * at the ground coordinates (x, z) expressed in the World system.
  32137. * Doesn't update the reference Vector3 if (x, z) are outside the ground surface.
  32138. * @param x x coordinate
  32139. * @param z z coordinate
  32140. * @param ref vector to store the result
  32141. * @returns the GroundMesh.
  32142. */
  32143. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32144. /**
  32145. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32146. * if the ground has been updated.
  32147. * This can be used in the render loop.
  32148. * @returns the GroundMesh.
  32149. */
  32150. updateCoordinateHeights(): GroundMesh;
  32151. private _getFacetAt;
  32152. private _initHeightQuads;
  32153. private _computeHeightQuads;
  32154. /**
  32155. * Serializes this ground mesh
  32156. * @param serializationObject object to write serialization to
  32157. */
  32158. serialize(serializationObject: any): void;
  32159. /**
  32160. * Parses a serialized ground mesh
  32161. * @param parsedMesh the serialized mesh
  32162. * @param scene the scene to create the ground mesh in
  32163. * @returns the created ground mesh
  32164. */
  32165. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32166. }
  32167. }
  32168. declare module BABYLON {
  32169. /**
  32170. * Interface for Physics-Joint data
  32171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32172. */
  32173. export interface PhysicsJointData {
  32174. /**
  32175. * The main pivot of the joint
  32176. */
  32177. mainPivot?: Vector3;
  32178. /**
  32179. * The connected pivot of the joint
  32180. */
  32181. connectedPivot?: Vector3;
  32182. /**
  32183. * The main axis of the joint
  32184. */
  32185. mainAxis?: Vector3;
  32186. /**
  32187. * The connected axis of the joint
  32188. */
  32189. connectedAxis?: Vector3;
  32190. /**
  32191. * The collision of the joint
  32192. */
  32193. collision?: boolean;
  32194. /**
  32195. * Native Oimo/Cannon/Energy data
  32196. */
  32197. nativeParams?: any;
  32198. }
  32199. /**
  32200. * This is a holder class for the physics joint created by the physics plugin
  32201. * It holds a set of functions to control the underlying joint
  32202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32203. */
  32204. export class PhysicsJoint {
  32205. /**
  32206. * The type of the physics joint
  32207. */
  32208. type: number;
  32209. /**
  32210. * The data for the physics joint
  32211. */
  32212. jointData: PhysicsJointData;
  32213. private _physicsJoint;
  32214. protected _physicsPlugin: IPhysicsEnginePlugin;
  32215. /**
  32216. * Initializes the physics joint
  32217. * @param type The type of the physics joint
  32218. * @param jointData The data for the physics joint
  32219. */
  32220. constructor(
  32221. /**
  32222. * The type of the physics joint
  32223. */
  32224. type: number,
  32225. /**
  32226. * The data for the physics joint
  32227. */
  32228. jointData: PhysicsJointData);
  32229. /**
  32230. * Gets the physics joint
  32231. */
  32232. get physicsJoint(): any;
  32233. /**
  32234. * Sets the physics joint
  32235. */
  32236. set physicsJoint(newJoint: any);
  32237. /**
  32238. * Sets the physics plugin
  32239. */
  32240. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32241. /**
  32242. * Execute a function that is physics-plugin specific.
  32243. * @param {Function} func the function that will be executed.
  32244. * It accepts two parameters: the physics world and the physics joint
  32245. */
  32246. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32247. /**
  32248. * Distance-Joint type
  32249. */
  32250. static DistanceJoint: number;
  32251. /**
  32252. * Hinge-Joint type
  32253. */
  32254. static HingeJoint: number;
  32255. /**
  32256. * Ball-and-Socket joint type
  32257. */
  32258. static BallAndSocketJoint: number;
  32259. /**
  32260. * Wheel-Joint type
  32261. */
  32262. static WheelJoint: number;
  32263. /**
  32264. * Slider-Joint type
  32265. */
  32266. static SliderJoint: number;
  32267. /**
  32268. * Prismatic-Joint type
  32269. */
  32270. static PrismaticJoint: number;
  32271. /**
  32272. * Universal-Joint type
  32273. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32274. */
  32275. static UniversalJoint: number;
  32276. /**
  32277. * Hinge-Joint 2 type
  32278. */
  32279. static Hinge2Joint: number;
  32280. /**
  32281. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32282. */
  32283. static PointToPointJoint: number;
  32284. /**
  32285. * Spring-Joint type
  32286. */
  32287. static SpringJoint: number;
  32288. /**
  32289. * Lock-Joint type
  32290. */
  32291. static LockJoint: number;
  32292. }
  32293. /**
  32294. * A class representing a physics distance joint
  32295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32296. */
  32297. export class DistanceJoint extends PhysicsJoint {
  32298. /**
  32299. *
  32300. * @param jointData The data for the Distance-Joint
  32301. */
  32302. constructor(jointData: DistanceJointData);
  32303. /**
  32304. * Update the predefined distance.
  32305. * @param maxDistance The maximum preferred distance
  32306. * @param minDistance The minimum preferred distance
  32307. */
  32308. updateDistance(maxDistance: number, minDistance?: number): void;
  32309. }
  32310. /**
  32311. * Represents a Motor-Enabled Joint
  32312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32313. */
  32314. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32315. /**
  32316. * Initializes the Motor-Enabled Joint
  32317. * @param type The type of the joint
  32318. * @param jointData The physical joint data for the joint
  32319. */
  32320. constructor(type: number, jointData: PhysicsJointData);
  32321. /**
  32322. * Set the motor values.
  32323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32324. * @param force the force to apply
  32325. * @param maxForce max force for this motor.
  32326. */
  32327. setMotor(force?: number, maxForce?: number): void;
  32328. /**
  32329. * Set the motor's limits.
  32330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32331. * @param upperLimit The upper limit of the motor
  32332. * @param lowerLimit The lower limit of the motor
  32333. */
  32334. setLimit(upperLimit: number, lowerLimit?: number): void;
  32335. }
  32336. /**
  32337. * This class represents a single physics Hinge-Joint
  32338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32339. */
  32340. export class HingeJoint extends MotorEnabledJoint {
  32341. /**
  32342. * Initializes the Hinge-Joint
  32343. * @param jointData The joint data for the Hinge-Joint
  32344. */
  32345. constructor(jointData: PhysicsJointData);
  32346. /**
  32347. * Set the motor values.
  32348. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32349. * @param {number} force the force to apply
  32350. * @param {number} maxForce max force for this motor.
  32351. */
  32352. setMotor(force?: number, maxForce?: number): void;
  32353. /**
  32354. * Set the motor's limits.
  32355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32356. * @param upperLimit The upper limit of the motor
  32357. * @param lowerLimit The lower limit of the motor
  32358. */
  32359. setLimit(upperLimit: number, lowerLimit?: number): void;
  32360. }
  32361. /**
  32362. * This class represents a dual hinge physics joint (same as wheel joint)
  32363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32364. */
  32365. export class Hinge2Joint extends MotorEnabledJoint {
  32366. /**
  32367. * Initializes the Hinge2-Joint
  32368. * @param jointData The joint data for the Hinge2-Joint
  32369. */
  32370. constructor(jointData: PhysicsJointData);
  32371. /**
  32372. * Set the motor values.
  32373. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32374. * @param {number} targetSpeed the speed the motor is to reach
  32375. * @param {number} maxForce max force for this motor.
  32376. * @param {motorIndex} the motor's index, 0 or 1.
  32377. */
  32378. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32379. /**
  32380. * Set the motor limits.
  32381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32382. * @param {number} upperLimit the upper limit
  32383. * @param {number} lowerLimit lower limit
  32384. * @param {motorIndex} the motor's index, 0 or 1.
  32385. */
  32386. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32387. }
  32388. /**
  32389. * Interface for a motor enabled joint
  32390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32391. */
  32392. export interface IMotorEnabledJoint {
  32393. /**
  32394. * Physics joint
  32395. */
  32396. physicsJoint: any;
  32397. /**
  32398. * Sets the motor of the motor-enabled joint
  32399. * @param force The force of the motor
  32400. * @param maxForce The maximum force of the motor
  32401. * @param motorIndex The index of the motor
  32402. */
  32403. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32404. /**
  32405. * Sets the limit of the motor
  32406. * @param upperLimit The upper limit of the motor
  32407. * @param lowerLimit The lower limit of the motor
  32408. * @param motorIndex The index of the motor
  32409. */
  32410. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32411. }
  32412. /**
  32413. * Joint data for a Distance-Joint
  32414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32415. */
  32416. export interface DistanceJointData extends PhysicsJointData {
  32417. /**
  32418. * Max distance the 2 joint objects can be apart
  32419. */
  32420. maxDistance: number;
  32421. }
  32422. /**
  32423. * Joint data from a spring joint
  32424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32425. */
  32426. export interface SpringJointData extends PhysicsJointData {
  32427. /**
  32428. * Length of the spring
  32429. */
  32430. length: number;
  32431. /**
  32432. * Stiffness of the spring
  32433. */
  32434. stiffness: number;
  32435. /**
  32436. * Damping of the spring
  32437. */
  32438. damping: number;
  32439. /** this callback will be called when applying the force to the impostors. */
  32440. forceApplicationCallback: () => void;
  32441. }
  32442. }
  32443. declare module BABYLON {
  32444. /**
  32445. * Holds the data for the raycast result
  32446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32447. */
  32448. export class PhysicsRaycastResult {
  32449. private _hasHit;
  32450. private _hitDistance;
  32451. private _hitNormalWorld;
  32452. private _hitPointWorld;
  32453. private _rayFromWorld;
  32454. private _rayToWorld;
  32455. /**
  32456. * Gets if there was a hit
  32457. */
  32458. get hasHit(): boolean;
  32459. /**
  32460. * Gets the distance from the hit
  32461. */
  32462. get hitDistance(): number;
  32463. /**
  32464. * Gets the hit normal/direction in the world
  32465. */
  32466. get hitNormalWorld(): Vector3;
  32467. /**
  32468. * Gets the hit point in the world
  32469. */
  32470. get hitPointWorld(): Vector3;
  32471. /**
  32472. * Gets the ray "start point" of the ray in the world
  32473. */
  32474. get rayFromWorld(): Vector3;
  32475. /**
  32476. * Gets the ray "end point" of the ray in the world
  32477. */
  32478. get rayToWorld(): Vector3;
  32479. /**
  32480. * Sets the hit data (normal & point in world space)
  32481. * @param hitNormalWorld defines the normal in world space
  32482. * @param hitPointWorld defines the point in world space
  32483. */
  32484. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32485. /**
  32486. * Sets the distance from the start point to the hit point
  32487. * @param distance
  32488. */
  32489. setHitDistance(distance: number): void;
  32490. /**
  32491. * Calculates the distance manually
  32492. */
  32493. calculateHitDistance(): void;
  32494. /**
  32495. * Resets all the values to default
  32496. * @param from The from point on world space
  32497. * @param to The to point on world space
  32498. */
  32499. reset(from?: Vector3, to?: Vector3): void;
  32500. }
  32501. /**
  32502. * Interface for the size containing width and height
  32503. */
  32504. interface IXYZ {
  32505. /**
  32506. * X
  32507. */
  32508. x: number;
  32509. /**
  32510. * Y
  32511. */
  32512. y: number;
  32513. /**
  32514. * Z
  32515. */
  32516. z: number;
  32517. }
  32518. }
  32519. declare module BABYLON {
  32520. /**
  32521. * Interface used to describe a physics joint
  32522. */
  32523. export interface PhysicsImpostorJoint {
  32524. /** Defines the main impostor to which the joint is linked */
  32525. mainImpostor: PhysicsImpostor;
  32526. /** Defines the impostor that is connected to the main impostor using this joint */
  32527. connectedImpostor: PhysicsImpostor;
  32528. /** Defines the joint itself */
  32529. joint: PhysicsJoint;
  32530. }
  32531. /** @hidden */
  32532. export interface IPhysicsEnginePlugin {
  32533. world: any;
  32534. name: string;
  32535. setGravity(gravity: Vector3): void;
  32536. setTimeStep(timeStep: number): void;
  32537. getTimeStep(): number;
  32538. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32539. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32540. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32541. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32542. removePhysicsBody(impostor: PhysicsImpostor): void;
  32543. generateJoint(joint: PhysicsImpostorJoint): void;
  32544. removeJoint(joint: PhysicsImpostorJoint): void;
  32545. isSupported(): boolean;
  32546. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32547. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32548. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32549. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32550. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32551. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32552. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32553. getBodyMass(impostor: PhysicsImpostor): number;
  32554. getBodyFriction(impostor: PhysicsImpostor): number;
  32555. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32556. getBodyRestitution(impostor: PhysicsImpostor): number;
  32557. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32558. getBodyPressure?(impostor: PhysicsImpostor): number;
  32559. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32560. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32561. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32562. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32563. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32564. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32565. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32566. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32567. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32568. sleepBody(impostor: PhysicsImpostor): void;
  32569. wakeUpBody(impostor: PhysicsImpostor): void;
  32570. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32571. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32572. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32573. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32574. getRadius(impostor: PhysicsImpostor): number;
  32575. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32576. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32577. dispose(): void;
  32578. }
  32579. /**
  32580. * Interface used to define a physics engine
  32581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32582. */
  32583. export interface IPhysicsEngine {
  32584. /**
  32585. * Gets the gravity vector used by the simulation
  32586. */
  32587. gravity: Vector3;
  32588. /**
  32589. * Sets the gravity vector used by the simulation
  32590. * @param gravity defines the gravity vector to use
  32591. */
  32592. setGravity(gravity: Vector3): void;
  32593. /**
  32594. * Set the time step of the physics engine.
  32595. * Default is 1/60.
  32596. * To slow it down, enter 1/600 for example.
  32597. * To speed it up, 1/30
  32598. * @param newTimeStep the new timestep to apply to this world.
  32599. */
  32600. setTimeStep(newTimeStep: number): void;
  32601. /**
  32602. * Get the time step of the physics engine.
  32603. * @returns the current time step
  32604. */
  32605. getTimeStep(): number;
  32606. /**
  32607. * Set the sub time step of the physics engine.
  32608. * Default is 0 meaning there is no sub steps
  32609. * To increase physics resolution precision, set a small value (like 1 ms)
  32610. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32611. */
  32612. setSubTimeStep(subTimeStep: number): void;
  32613. /**
  32614. * Get the sub time step of the physics engine.
  32615. * @returns the current sub time step
  32616. */
  32617. getSubTimeStep(): number;
  32618. /**
  32619. * Release all resources
  32620. */
  32621. dispose(): void;
  32622. /**
  32623. * Gets the name of the current physics plugin
  32624. * @returns the name of the plugin
  32625. */
  32626. getPhysicsPluginName(): string;
  32627. /**
  32628. * Adding a new impostor for the impostor tracking.
  32629. * This will be done by the impostor itself.
  32630. * @param impostor the impostor to add
  32631. */
  32632. addImpostor(impostor: PhysicsImpostor): void;
  32633. /**
  32634. * Remove an impostor from the engine.
  32635. * This impostor and its mesh will not longer be updated by the physics engine.
  32636. * @param impostor the impostor to remove
  32637. */
  32638. removeImpostor(impostor: PhysicsImpostor): void;
  32639. /**
  32640. * Add a joint to the physics engine
  32641. * @param mainImpostor defines the main impostor to which the joint is added.
  32642. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32643. * @param joint defines the joint that will connect both impostors.
  32644. */
  32645. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32646. /**
  32647. * Removes a joint from the simulation
  32648. * @param mainImpostor defines the impostor used with the joint
  32649. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32650. * @param joint defines the joint to remove
  32651. */
  32652. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32653. /**
  32654. * Gets the current plugin used to run the simulation
  32655. * @returns current plugin
  32656. */
  32657. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32658. /**
  32659. * Gets the list of physic impostors
  32660. * @returns an array of PhysicsImpostor
  32661. */
  32662. getImpostors(): Array<PhysicsImpostor>;
  32663. /**
  32664. * Gets the impostor for a physics enabled object
  32665. * @param object defines the object impersonated by the impostor
  32666. * @returns the PhysicsImpostor or null if not found
  32667. */
  32668. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32669. /**
  32670. * Gets the impostor for a physics body object
  32671. * @param body defines physics body used by the impostor
  32672. * @returns the PhysicsImpostor or null if not found
  32673. */
  32674. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32675. /**
  32676. * Does a raycast in the physics world
  32677. * @param from when should the ray start?
  32678. * @param to when should the ray end?
  32679. * @returns PhysicsRaycastResult
  32680. */
  32681. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32682. /**
  32683. * Called by the scene. No need to call it.
  32684. * @param delta defines the timespan between frames
  32685. */
  32686. _step(delta: number): void;
  32687. }
  32688. }
  32689. declare module BABYLON {
  32690. /**
  32691. * The interface for the physics imposter parameters
  32692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32693. */
  32694. export interface PhysicsImpostorParameters {
  32695. /**
  32696. * The mass of the physics imposter
  32697. */
  32698. mass: number;
  32699. /**
  32700. * The friction of the physics imposter
  32701. */
  32702. friction?: number;
  32703. /**
  32704. * The coefficient of restitution of the physics imposter
  32705. */
  32706. restitution?: number;
  32707. /**
  32708. * The native options of the physics imposter
  32709. */
  32710. nativeOptions?: any;
  32711. /**
  32712. * Specifies if the parent should be ignored
  32713. */
  32714. ignoreParent?: boolean;
  32715. /**
  32716. * Specifies if bi-directional transformations should be disabled
  32717. */
  32718. disableBidirectionalTransformation?: boolean;
  32719. /**
  32720. * The pressure inside the physics imposter, soft object only
  32721. */
  32722. pressure?: number;
  32723. /**
  32724. * The stiffness the physics imposter, soft object only
  32725. */
  32726. stiffness?: number;
  32727. /**
  32728. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32729. */
  32730. velocityIterations?: number;
  32731. /**
  32732. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32733. */
  32734. positionIterations?: number;
  32735. /**
  32736. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32737. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32738. * Add to fix multiple points
  32739. */
  32740. fixedPoints?: number;
  32741. /**
  32742. * The collision margin around a soft object
  32743. */
  32744. margin?: number;
  32745. /**
  32746. * The collision margin around a soft object
  32747. */
  32748. damping?: number;
  32749. /**
  32750. * The path for a rope based on an extrusion
  32751. */
  32752. path?: any;
  32753. /**
  32754. * The shape of an extrusion used for a rope based on an extrusion
  32755. */
  32756. shape?: any;
  32757. }
  32758. /**
  32759. * Interface for a physics-enabled object
  32760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32761. */
  32762. export interface IPhysicsEnabledObject {
  32763. /**
  32764. * The position of the physics-enabled object
  32765. */
  32766. position: Vector3;
  32767. /**
  32768. * The rotation of the physics-enabled object
  32769. */
  32770. rotationQuaternion: Nullable<Quaternion>;
  32771. /**
  32772. * The scale of the physics-enabled object
  32773. */
  32774. scaling: Vector3;
  32775. /**
  32776. * The rotation of the physics-enabled object
  32777. */
  32778. rotation?: Vector3;
  32779. /**
  32780. * The parent of the physics-enabled object
  32781. */
  32782. parent?: any;
  32783. /**
  32784. * The bounding info of the physics-enabled object
  32785. * @returns The bounding info of the physics-enabled object
  32786. */
  32787. getBoundingInfo(): BoundingInfo;
  32788. /**
  32789. * Computes the world matrix
  32790. * @param force Specifies if the world matrix should be computed by force
  32791. * @returns A world matrix
  32792. */
  32793. computeWorldMatrix(force: boolean): Matrix;
  32794. /**
  32795. * Gets the world matrix
  32796. * @returns A world matrix
  32797. */
  32798. getWorldMatrix?(): Matrix;
  32799. /**
  32800. * Gets the child meshes
  32801. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32802. * @returns An array of abstract meshes
  32803. */
  32804. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32805. /**
  32806. * Gets the vertex data
  32807. * @param kind The type of vertex data
  32808. * @returns A nullable array of numbers, or a float32 array
  32809. */
  32810. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32811. /**
  32812. * Gets the indices from the mesh
  32813. * @returns A nullable array of index arrays
  32814. */
  32815. getIndices?(): Nullable<IndicesArray>;
  32816. /**
  32817. * Gets the scene from the mesh
  32818. * @returns the indices array or null
  32819. */
  32820. getScene?(): Scene;
  32821. /**
  32822. * Gets the absolute position from the mesh
  32823. * @returns the absolute position
  32824. */
  32825. getAbsolutePosition(): Vector3;
  32826. /**
  32827. * Gets the absolute pivot point from the mesh
  32828. * @returns the absolute pivot point
  32829. */
  32830. getAbsolutePivotPoint(): Vector3;
  32831. /**
  32832. * Rotates the mesh
  32833. * @param axis The axis of rotation
  32834. * @param amount The amount of rotation
  32835. * @param space The space of the rotation
  32836. * @returns The rotation transform node
  32837. */
  32838. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32839. /**
  32840. * Translates the mesh
  32841. * @param axis The axis of translation
  32842. * @param distance The distance of translation
  32843. * @param space The space of the translation
  32844. * @returns The transform node
  32845. */
  32846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32847. /**
  32848. * Sets the absolute position of the mesh
  32849. * @param absolutePosition The absolute position of the mesh
  32850. * @returns The transform node
  32851. */
  32852. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32853. /**
  32854. * Gets the class name of the mesh
  32855. * @returns The class name
  32856. */
  32857. getClassName(): string;
  32858. }
  32859. /**
  32860. * Represents a physics imposter
  32861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32862. */
  32863. export class PhysicsImpostor {
  32864. /**
  32865. * The physics-enabled object used as the physics imposter
  32866. */
  32867. object: IPhysicsEnabledObject;
  32868. /**
  32869. * The type of the physics imposter
  32870. */
  32871. type: number;
  32872. private _options;
  32873. private _scene?;
  32874. /**
  32875. * The default object size of the imposter
  32876. */
  32877. static DEFAULT_OBJECT_SIZE: Vector3;
  32878. /**
  32879. * The identity quaternion of the imposter
  32880. */
  32881. static IDENTITY_QUATERNION: Quaternion;
  32882. /** @hidden */
  32883. _pluginData: any;
  32884. private _physicsEngine;
  32885. private _physicsBody;
  32886. private _bodyUpdateRequired;
  32887. private _onBeforePhysicsStepCallbacks;
  32888. private _onAfterPhysicsStepCallbacks;
  32889. /** @hidden */
  32890. _onPhysicsCollideCallbacks: Array<{
  32891. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32892. otherImpostors: Array<PhysicsImpostor>;
  32893. }>;
  32894. private _deltaPosition;
  32895. private _deltaRotation;
  32896. private _deltaRotationConjugated;
  32897. /** @hidden */
  32898. _isFromLine: boolean;
  32899. private _parent;
  32900. private _isDisposed;
  32901. private static _tmpVecs;
  32902. private static _tmpQuat;
  32903. /**
  32904. * Specifies if the physics imposter is disposed
  32905. */
  32906. get isDisposed(): boolean;
  32907. /**
  32908. * Gets the mass of the physics imposter
  32909. */
  32910. get mass(): number;
  32911. set mass(value: number);
  32912. /**
  32913. * Gets the coefficient of friction
  32914. */
  32915. get friction(): number;
  32916. /**
  32917. * Sets the coefficient of friction
  32918. */
  32919. set friction(value: number);
  32920. /**
  32921. * Gets the coefficient of restitution
  32922. */
  32923. get restitution(): number;
  32924. /**
  32925. * Sets the coefficient of restitution
  32926. */
  32927. set restitution(value: number);
  32928. /**
  32929. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32930. */
  32931. get pressure(): number;
  32932. /**
  32933. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32934. */
  32935. set pressure(value: number);
  32936. /**
  32937. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32938. */
  32939. get stiffness(): number;
  32940. /**
  32941. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32942. */
  32943. set stiffness(value: number);
  32944. /**
  32945. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32946. */
  32947. get velocityIterations(): number;
  32948. /**
  32949. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32950. */
  32951. set velocityIterations(value: number);
  32952. /**
  32953. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32954. */
  32955. get positionIterations(): number;
  32956. /**
  32957. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32958. */
  32959. set positionIterations(value: number);
  32960. /**
  32961. * The unique id of the physics imposter
  32962. * set by the physics engine when adding this impostor to the array
  32963. */
  32964. uniqueId: number;
  32965. /**
  32966. * @hidden
  32967. */
  32968. soft: boolean;
  32969. /**
  32970. * @hidden
  32971. */
  32972. segments: number;
  32973. private _joints;
  32974. /**
  32975. * Initializes the physics imposter
  32976. * @param object The physics-enabled object used as the physics imposter
  32977. * @param type The type of the physics imposter
  32978. * @param _options The options for the physics imposter
  32979. * @param _scene The Babylon scene
  32980. */
  32981. constructor(
  32982. /**
  32983. * The physics-enabled object used as the physics imposter
  32984. */
  32985. object: IPhysicsEnabledObject,
  32986. /**
  32987. * The type of the physics imposter
  32988. */
  32989. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32990. /**
  32991. * This function will completely initialize this impostor.
  32992. * It will create a new body - but only if this mesh has no parent.
  32993. * If it has, this impostor will not be used other than to define the impostor
  32994. * of the child mesh.
  32995. * @hidden
  32996. */
  32997. _init(): void;
  32998. private _getPhysicsParent;
  32999. /**
  33000. * Should a new body be generated.
  33001. * @returns boolean specifying if body initialization is required
  33002. */
  33003. isBodyInitRequired(): boolean;
  33004. /**
  33005. * Sets the updated scaling
  33006. * @param updated Specifies if the scaling is updated
  33007. */
  33008. setScalingUpdated(): void;
  33009. /**
  33010. * Force a regeneration of this or the parent's impostor's body.
  33011. * Use under cautious - This will remove all joints already implemented.
  33012. */
  33013. forceUpdate(): void;
  33014. /**
  33015. * Gets the body that holds this impostor. Either its own, or its parent.
  33016. */
  33017. get physicsBody(): any;
  33018. /**
  33019. * Get the parent of the physics imposter
  33020. * @returns Physics imposter or null
  33021. */
  33022. get parent(): Nullable<PhysicsImpostor>;
  33023. /**
  33024. * Sets the parent of the physics imposter
  33025. */
  33026. set parent(value: Nullable<PhysicsImpostor>);
  33027. /**
  33028. * Set the physics body. Used mainly by the physics engine/plugin
  33029. */
  33030. set physicsBody(physicsBody: any);
  33031. /**
  33032. * Resets the update flags
  33033. */
  33034. resetUpdateFlags(): void;
  33035. /**
  33036. * Gets the object extend size
  33037. * @returns the object extend size
  33038. */
  33039. getObjectExtendSize(): Vector3;
  33040. /**
  33041. * Gets the object center
  33042. * @returns The object center
  33043. */
  33044. getObjectCenter(): Vector3;
  33045. /**
  33046. * Get a specific parameter from the options parameters
  33047. * @param paramName The object parameter name
  33048. * @returns The object parameter
  33049. */
  33050. getParam(paramName: string): any;
  33051. /**
  33052. * Sets a specific parameter in the options given to the physics plugin
  33053. * @param paramName The parameter name
  33054. * @param value The value of the parameter
  33055. */
  33056. setParam(paramName: string, value: number): void;
  33057. /**
  33058. * Specifically change the body's mass option. Won't recreate the physics body object
  33059. * @param mass The mass of the physics imposter
  33060. */
  33061. setMass(mass: number): void;
  33062. /**
  33063. * Gets the linear velocity
  33064. * @returns linear velocity or null
  33065. */
  33066. getLinearVelocity(): Nullable<Vector3>;
  33067. /**
  33068. * Sets the linear velocity
  33069. * @param velocity linear velocity or null
  33070. */
  33071. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33072. /**
  33073. * Gets the angular velocity
  33074. * @returns angular velocity or null
  33075. */
  33076. getAngularVelocity(): Nullable<Vector3>;
  33077. /**
  33078. * Sets the angular velocity
  33079. * @param velocity The velocity or null
  33080. */
  33081. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33082. /**
  33083. * Execute a function with the physics plugin native code
  33084. * Provide a function the will have two variables - the world object and the physics body object
  33085. * @param func The function to execute with the physics plugin native code
  33086. */
  33087. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33088. /**
  33089. * Register a function that will be executed before the physics world is stepping forward
  33090. * @param func The function to execute before the physics world is stepped forward
  33091. */
  33092. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33093. /**
  33094. * Unregister a function that will be executed before the physics world is stepping forward
  33095. * @param func The function to execute before the physics world is stepped forward
  33096. */
  33097. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33098. /**
  33099. * Register a function that will be executed after the physics step
  33100. * @param func The function to execute after physics step
  33101. */
  33102. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33103. /**
  33104. * Unregisters a function that will be executed after the physics step
  33105. * @param func The function to execute after physics step
  33106. */
  33107. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33108. /**
  33109. * register a function that will be executed when this impostor collides against a different body
  33110. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33111. * @param func Callback that is executed on collision
  33112. */
  33113. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33114. /**
  33115. * Unregisters the physics imposter on contact
  33116. * @param collideAgainst The physics object to collide against
  33117. * @param func Callback to execute on collision
  33118. */
  33119. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33120. private _tmpQuat;
  33121. private _tmpQuat2;
  33122. /**
  33123. * Get the parent rotation
  33124. * @returns The parent rotation
  33125. */
  33126. getParentsRotation(): Quaternion;
  33127. /**
  33128. * this function is executed by the physics engine.
  33129. */
  33130. beforeStep: () => void;
  33131. /**
  33132. * this function is executed by the physics engine
  33133. */
  33134. afterStep: () => void;
  33135. /**
  33136. * Legacy collision detection event support
  33137. */
  33138. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33139. /**
  33140. * event and body object due to cannon's event-based architecture.
  33141. */
  33142. onCollide: (e: {
  33143. body: any;
  33144. point: Nullable<Vector3>;
  33145. }) => void;
  33146. /**
  33147. * Apply a force
  33148. * @param force The force to apply
  33149. * @param contactPoint The contact point for the force
  33150. * @returns The physics imposter
  33151. */
  33152. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33153. /**
  33154. * Apply an impulse
  33155. * @param force The impulse force
  33156. * @param contactPoint The contact point for the impulse force
  33157. * @returns The physics imposter
  33158. */
  33159. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33160. /**
  33161. * A help function to create a joint
  33162. * @param otherImpostor A physics imposter used to create a joint
  33163. * @param jointType The type of joint
  33164. * @param jointData The data for the joint
  33165. * @returns The physics imposter
  33166. */
  33167. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33168. /**
  33169. * Add a joint to this impostor with a different impostor
  33170. * @param otherImpostor A physics imposter used to add a joint
  33171. * @param joint The joint to add
  33172. * @returns The physics imposter
  33173. */
  33174. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33175. /**
  33176. * Add an anchor to a cloth impostor
  33177. * @param otherImpostor rigid impostor to anchor to
  33178. * @param width ratio across width from 0 to 1
  33179. * @param height ratio up height from 0 to 1
  33180. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  33181. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33182. * @returns impostor the soft imposter
  33183. */
  33184. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33185. /**
  33186. * Add a hook to a rope impostor
  33187. * @param otherImpostor rigid impostor to anchor to
  33188. * @param length ratio across rope from 0 to 1
  33189. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
  33190. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33191. * @returns impostor the rope imposter
  33192. */
  33193. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33194. /**
  33195. * Will keep this body still, in a sleep mode.
  33196. * @returns the physics imposter
  33197. */
  33198. sleep(): PhysicsImpostor;
  33199. /**
  33200. * Wake the body up.
  33201. * @returns The physics imposter
  33202. */
  33203. wakeUp(): PhysicsImpostor;
  33204. /**
  33205. * Clones the physics imposter
  33206. * @param newObject The physics imposter clones to this physics-enabled object
  33207. * @returns A nullable physics imposter
  33208. */
  33209. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33210. /**
  33211. * Disposes the physics imposter
  33212. */
  33213. dispose(): void;
  33214. /**
  33215. * Sets the delta position
  33216. * @param position The delta position amount
  33217. */
  33218. setDeltaPosition(position: Vector3): void;
  33219. /**
  33220. * Sets the delta rotation
  33221. * @param rotation The delta rotation amount
  33222. */
  33223. setDeltaRotation(rotation: Quaternion): void;
  33224. /**
  33225. * Gets the box size of the physics imposter and stores the result in the input parameter
  33226. * @param result Stores the box size
  33227. * @returns The physics imposter
  33228. */
  33229. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33230. /**
  33231. * Gets the radius of the physics imposter
  33232. * @returns Radius of the physics imposter
  33233. */
  33234. getRadius(): number;
  33235. /**
  33236. * Sync a bone with this impostor
  33237. * @param bone The bone to sync to the impostor.
  33238. * @param boneMesh The mesh that the bone is influencing.
  33239. * @param jointPivot The pivot of the joint / bone in local space.
  33240. * @param distToJoint Optional distance from the impostor to the joint.
  33241. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33242. */
  33243. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33244. /**
  33245. * Sync impostor to a bone
  33246. * @param bone The bone that the impostor will be synced to.
  33247. * @param boneMesh The mesh that the bone is influencing.
  33248. * @param jointPivot The pivot of the joint / bone in local space.
  33249. * @param distToJoint Optional distance from the impostor to the joint.
  33250. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33251. * @param boneAxis Optional vector3 axis the bone is aligned with
  33252. */
  33253. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33254. /**
  33255. * No-Imposter type
  33256. */
  33257. static NoImpostor: number;
  33258. /**
  33259. * Sphere-Imposter type
  33260. */
  33261. static SphereImpostor: number;
  33262. /**
  33263. * Box-Imposter type
  33264. */
  33265. static BoxImpostor: number;
  33266. /**
  33267. * Plane-Imposter type
  33268. */
  33269. static PlaneImpostor: number;
  33270. /**
  33271. * Mesh-imposter type
  33272. */
  33273. static MeshImpostor: number;
  33274. /**
  33275. * Capsule-Impostor type (Ammo.js plugin only)
  33276. */
  33277. static CapsuleImpostor: number;
  33278. /**
  33279. * Cylinder-Imposter type
  33280. */
  33281. static CylinderImpostor: number;
  33282. /**
  33283. * Particle-Imposter type
  33284. */
  33285. static ParticleImpostor: number;
  33286. /**
  33287. * Heightmap-Imposter type
  33288. */
  33289. static HeightmapImpostor: number;
  33290. /**
  33291. * ConvexHull-Impostor type (Ammo.js plugin only)
  33292. */
  33293. static ConvexHullImpostor: number;
  33294. /**
  33295. * Custom-Imposter type (Ammo.js plugin only)
  33296. */
  33297. static CustomImpostor: number;
  33298. /**
  33299. * Rope-Imposter type
  33300. */
  33301. static RopeImpostor: number;
  33302. /**
  33303. * Cloth-Imposter type
  33304. */
  33305. static ClothImpostor: number;
  33306. /**
  33307. * Softbody-Imposter type
  33308. */
  33309. static SoftbodyImpostor: number;
  33310. }
  33311. }
  33312. declare module BABYLON {
  33313. /**
  33314. * @hidden
  33315. **/
  33316. export class _CreationDataStorage {
  33317. closePath?: boolean;
  33318. closeArray?: boolean;
  33319. idx: number[];
  33320. dashSize: number;
  33321. gapSize: number;
  33322. path3D: Path3D;
  33323. pathArray: Vector3[][];
  33324. arc: number;
  33325. radius: number;
  33326. cap: number;
  33327. tessellation: number;
  33328. }
  33329. /**
  33330. * @hidden
  33331. **/
  33332. class _InstanceDataStorage {
  33333. visibleInstances: any;
  33334. batchCache: _InstancesBatch;
  33335. instancesBufferSize: number;
  33336. instancesBuffer: Nullable<Buffer>;
  33337. instancesData: Float32Array;
  33338. overridenInstanceCount: number;
  33339. isFrozen: boolean;
  33340. previousBatch: Nullable<_InstancesBatch>;
  33341. hardwareInstancedRendering: boolean;
  33342. sideOrientation: number;
  33343. manualUpdate: boolean;
  33344. previousRenderId: number;
  33345. }
  33346. /**
  33347. * @hidden
  33348. **/
  33349. export class _InstancesBatch {
  33350. mustReturn: boolean;
  33351. visibleInstances: Nullable<InstancedMesh[]>[];
  33352. renderSelf: boolean[];
  33353. hardwareInstancedRendering: boolean[];
  33354. }
  33355. /**
  33356. * @hidden
  33357. **/
  33358. class _ThinInstanceDataStorage {
  33359. instancesCount: number;
  33360. matrixBuffer: Nullable<Buffer>;
  33361. matrixBufferSize: number;
  33362. matrixData: Nullable<Float32Array>;
  33363. boundingVectors: Array<Vector3>;
  33364. worldMatrices: Nullable<Matrix[]>;
  33365. }
  33366. /**
  33367. * Class used to represent renderable models
  33368. */
  33369. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33370. /**
  33371. * Mesh side orientation : usually the external or front surface
  33372. */
  33373. static readonly FRONTSIDE: number;
  33374. /**
  33375. * Mesh side orientation : usually the internal or back surface
  33376. */
  33377. static readonly BACKSIDE: number;
  33378. /**
  33379. * Mesh side orientation : both internal and external or front and back surfaces
  33380. */
  33381. static readonly DOUBLESIDE: number;
  33382. /**
  33383. * Mesh side orientation : by default, `FRONTSIDE`
  33384. */
  33385. static readonly DEFAULTSIDE: number;
  33386. /**
  33387. * Mesh cap setting : no cap
  33388. */
  33389. static readonly NO_CAP: number;
  33390. /**
  33391. * Mesh cap setting : one cap at the beginning of the mesh
  33392. */
  33393. static readonly CAP_START: number;
  33394. /**
  33395. * Mesh cap setting : one cap at the end of the mesh
  33396. */
  33397. static readonly CAP_END: number;
  33398. /**
  33399. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33400. */
  33401. static readonly CAP_ALL: number;
  33402. /**
  33403. * Mesh pattern setting : no flip or rotate
  33404. */
  33405. static readonly NO_FLIP: number;
  33406. /**
  33407. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33408. */
  33409. static readonly FLIP_TILE: number;
  33410. /**
  33411. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33412. */
  33413. static readonly ROTATE_TILE: number;
  33414. /**
  33415. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33416. */
  33417. static readonly FLIP_ROW: number;
  33418. /**
  33419. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33420. */
  33421. static readonly ROTATE_ROW: number;
  33422. /**
  33423. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33424. */
  33425. static readonly FLIP_N_ROTATE_TILE: number;
  33426. /**
  33427. * Mesh pattern setting : rotate pattern and rotate
  33428. */
  33429. static readonly FLIP_N_ROTATE_ROW: number;
  33430. /**
  33431. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33432. */
  33433. static readonly CENTER: number;
  33434. /**
  33435. * Mesh tile positioning : part tiles on left
  33436. */
  33437. static readonly LEFT: number;
  33438. /**
  33439. * Mesh tile positioning : part tiles on right
  33440. */
  33441. static readonly RIGHT: number;
  33442. /**
  33443. * Mesh tile positioning : part tiles on top
  33444. */
  33445. static readonly TOP: number;
  33446. /**
  33447. * Mesh tile positioning : part tiles on bottom
  33448. */
  33449. static readonly BOTTOM: number;
  33450. /**
  33451. * Gets the default side orientation.
  33452. * @param orientation the orientation to value to attempt to get
  33453. * @returns the default orientation
  33454. * @hidden
  33455. */
  33456. static _GetDefaultSideOrientation(orientation?: number): number;
  33457. private _internalMeshDataInfo;
  33458. get computeBonesUsingShaders(): boolean;
  33459. set computeBonesUsingShaders(value: boolean);
  33460. /**
  33461. * An event triggered before rendering the mesh
  33462. */
  33463. get onBeforeRenderObservable(): Observable<Mesh>;
  33464. /**
  33465. * An event triggered before binding the mesh
  33466. */
  33467. get onBeforeBindObservable(): Observable<Mesh>;
  33468. /**
  33469. * An event triggered after rendering the mesh
  33470. */
  33471. get onAfterRenderObservable(): Observable<Mesh>;
  33472. /**
  33473. * An event triggered before drawing the mesh
  33474. */
  33475. get onBeforeDrawObservable(): Observable<Mesh>;
  33476. private _onBeforeDrawObserver;
  33477. /**
  33478. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33479. */
  33480. set onBeforeDraw(callback: () => void);
  33481. get hasInstances(): boolean;
  33482. get hasThinInstances(): boolean;
  33483. /**
  33484. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33485. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33486. */
  33487. delayLoadState: number;
  33488. /**
  33489. * Gets the list of instances created from this mesh
  33490. * it is not supposed to be modified manually.
  33491. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33492. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33493. */
  33494. instances: InstancedMesh[];
  33495. /**
  33496. * Gets the file containing delay loading data for this mesh
  33497. */
  33498. delayLoadingFile: string;
  33499. /** @hidden */
  33500. _binaryInfo: any;
  33501. /**
  33502. * User defined function used to change how LOD level selection is done
  33503. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33504. */
  33505. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33506. /**
  33507. * Gets or sets the morph target manager
  33508. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33509. */
  33510. get morphTargetManager(): Nullable<MorphTargetManager>;
  33511. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33512. /** @hidden */
  33513. _creationDataStorage: Nullable<_CreationDataStorage>;
  33514. /** @hidden */
  33515. _geometry: Nullable<Geometry>;
  33516. /** @hidden */
  33517. _delayInfo: Array<string>;
  33518. /** @hidden */
  33519. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33520. /** @hidden */
  33521. _instanceDataStorage: _InstanceDataStorage;
  33522. /** @hidden */
  33523. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33524. private _effectiveMaterial;
  33525. /** @hidden */
  33526. _shouldGenerateFlatShading: boolean;
  33527. /** @hidden */
  33528. _originalBuilderSideOrientation: number;
  33529. /**
  33530. * Use this property to change the original side orientation defined at construction time
  33531. */
  33532. overrideMaterialSideOrientation: Nullable<number>;
  33533. /**
  33534. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33535. * Note this will reduce performance when set to true.
  33536. */
  33537. ignoreCameraMaxZ: boolean;
  33538. /**
  33539. * Gets the source mesh (the one used to clone this one from)
  33540. */
  33541. get source(): Nullable<Mesh>;
  33542. /**
  33543. * Gets the list of clones of this mesh
  33544. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33545. * Note that useClonedMeshMap=true is the default setting
  33546. */
  33547. get cloneMeshMap(): Nullable<{
  33548. [id: string]: Mesh | undefined;
  33549. }>;
  33550. /**
  33551. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33552. */
  33553. get isUnIndexed(): boolean;
  33554. set isUnIndexed(value: boolean);
  33555. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33556. get worldMatrixInstancedBuffer(): Float32Array;
  33557. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33558. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33559. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33560. /**
  33561. * @constructor
  33562. * @param name The value used by scene.getMeshByName() to do a lookup.
  33563. * @param scene The scene to add this mesh to.
  33564. * @param parent The parent of this mesh, if it has one
  33565. * @param source An optional Mesh from which geometry is shared, cloned.
  33566. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33567. * When false, achieved by calling a clone(), also passing False.
  33568. * This will make creation of children, recursive.
  33569. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33570. */
  33571. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33572. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33573. doNotInstantiate: boolean;
  33574. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33575. /**
  33576. * Gets the class name
  33577. * @returns the string "Mesh".
  33578. */
  33579. getClassName(): string;
  33580. /** @hidden */
  33581. get _isMesh(): boolean;
  33582. /**
  33583. * Returns a description of this mesh
  33584. * @param fullDetails define if full details about this mesh must be used
  33585. * @returns a descriptive string representing this mesh
  33586. */
  33587. toString(fullDetails?: boolean): string;
  33588. /** @hidden */
  33589. _unBindEffect(): void;
  33590. /**
  33591. * Gets a boolean indicating if this mesh has LOD
  33592. */
  33593. get hasLODLevels(): boolean;
  33594. /**
  33595. * Gets the list of MeshLODLevel associated with the current mesh
  33596. * @returns an array of MeshLODLevel
  33597. */
  33598. getLODLevels(): MeshLODLevel[];
  33599. private _sortLODLevels;
  33600. /**
  33601. * Add a mesh as LOD level triggered at the given distance.
  33602. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33603. * @param distance The distance from the center of the object to show this level
  33604. * @param mesh The mesh to be added as LOD level (can be null)
  33605. * @return This mesh (for chaining)
  33606. */
  33607. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33608. /**
  33609. * Returns the LOD level mesh at the passed distance or null if not found.
  33610. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33611. * @param distance The distance from the center of the object to show this level
  33612. * @returns a Mesh or `null`
  33613. */
  33614. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33615. /**
  33616. * Remove a mesh from the LOD array
  33617. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33618. * @param mesh defines the mesh to be removed
  33619. * @return This mesh (for chaining)
  33620. */
  33621. removeLODLevel(mesh: Mesh): Mesh;
  33622. /**
  33623. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33624. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33625. * @param camera defines the camera to use to compute distance
  33626. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33627. * @return This mesh (for chaining)
  33628. */
  33629. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33630. /**
  33631. * Gets the mesh internal Geometry object
  33632. */
  33633. get geometry(): Nullable<Geometry>;
  33634. /**
  33635. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33636. * @returns the total number of vertices
  33637. */
  33638. getTotalVertices(): number;
  33639. /**
  33640. * Returns the content of an associated vertex buffer
  33641. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33642. * - VertexBuffer.PositionKind
  33643. * - VertexBuffer.UVKind
  33644. * - VertexBuffer.UV2Kind
  33645. * - VertexBuffer.UV3Kind
  33646. * - VertexBuffer.UV4Kind
  33647. * - VertexBuffer.UV5Kind
  33648. * - VertexBuffer.UV6Kind
  33649. * - VertexBuffer.ColorKind
  33650. * - VertexBuffer.MatricesIndicesKind
  33651. * - VertexBuffer.MatricesIndicesExtraKind
  33652. * - VertexBuffer.MatricesWeightsKind
  33653. * - VertexBuffer.MatricesWeightsExtraKind
  33654. * @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
  33655. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33656. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33657. */
  33658. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33659. /**
  33660. * Returns the mesh VertexBuffer object from the requested `kind`
  33661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33662. * - VertexBuffer.PositionKind
  33663. * - VertexBuffer.NormalKind
  33664. * - VertexBuffer.UVKind
  33665. * - VertexBuffer.UV2Kind
  33666. * - VertexBuffer.UV3Kind
  33667. * - VertexBuffer.UV4Kind
  33668. * - VertexBuffer.UV5Kind
  33669. * - VertexBuffer.UV6Kind
  33670. * - VertexBuffer.ColorKind
  33671. * - VertexBuffer.MatricesIndicesKind
  33672. * - VertexBuffer.MatricesIndicesExtraKind
  33673. * - VertexBuffer.MatricesWeightsKind
  33674. * - VertexBuffer.MatricesWeightsExtraKind
  33675. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33676. */
  33677. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33678. /**
  33679. * Tests if a specific vertex buffer is associated with this mesh
  33680. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33681. * - VertexBuffer.PositionKind
  33682. * - VertexBuffer.NormalKind
  33683. * - VertexBuffer.UVKind
  33684. * - VertexBuffer.UV2Kind
  33685. * - VertexBuffer.UV3Kind
  33686. * - VertexBuffer.UV4Kind
  33687. * - VertexBuffer.UV5Kind
  33688. * - VertexBuffer.UV6Kind
  33689. * - VertexBuffer.ColorKind
  33690. * - VertexBuffer.MatricesIndicesKind
  33691. * - VertexBuffer.MatricesIndicesExtraKind
  33692. * - VertexBuffer.MatricesWeightsKind
  33693. * - VertexBuffer.MatricesWeightsExtraKind
  33694. * @returns a boolean
  33695. */
  33696. isVerticesDataPresent(kind: string): boolean;
  33697. /**
  33698. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33699. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33700. * - VertexBuffer.PositionKind
  33701. * - VertexBuffer.UVKind
  33702. * - VertexBuffer.UV2Kind
  33703. * - VertexBuffer.UV3Kind
  33704. * - VertexBuffer.UV4Kind
  33705. * - VertexBuffer.UV5Kind
  33706. * - VertexBuffer.UV6Kind
  33707. * - VertexBuffer.ColorKind
  33708. * - VertexBuffer.MatricesIndicesKind
  33709. * - VertexBuffer.MatricesIndicesExtraKind
  33710. * - VertexBuffer.MatricesWeightsKind
  33711. * - VertexBuffer.MatricesWeightsExtraKind
  33712. * @returns a boolean
  33713. */
  33714. isVertexBufferUpdatable(kind: string): boolean;
  33715. /**
  33716. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33717. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33718. * - VertexBuffer.PositionKind
  33719. * - VertexBuffer.NormalKind
  33720. * - VertexBuffer.UVKind
  33721. * - VertexBuffer.UV2Kind
  33722. * - VertexBuffer.UV3Kind
  33723. * - VertexBuffer.UV4Kind
  33724. * - VertexBuffer.UV5Kind
  33725. * - VertexBuffer.UV6Kind
  33726. * - VertexBuffer.ColorKind
  33727. * - VertexBuffer.MatricesIndicesKind
  33728. * - VertexBuffer.MatricesIndicesExtraKind
  33729. * - VertexBuffer.MatricesWeightsKind
  33730. * - VertexBuffer.MatricesWeightsExtraKind
  33731. * @returns an array of strings
  33732. */
  33733. getVerticesDataKinds(): string[];
  33734. /**
  33735. * Returns a positive integer : the total number of indices in this mesh geometry.
  33736. * @returns the numner of indices or zero if the mesh has no geometry.
  33737. */
  33738. getTotalIndices(): number;
  33739. /**
  33740. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33741. * @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.
  33742. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33743. * @returns the indices array or an empty array if the mesh has no geometry
  33744. */
  33745. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33746. get isBlocked(): boolean;
  33747. /**
  33748. * Determine if the current mesh is ready to be rendered
  33749. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33750. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33751. * @returns true if all associated assets are ready (material, textures, shaders)
  33752. */
  33753. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33754. /**
  33755. * 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.
  33756. */
  33757. get areNormalsFrozen(): boolean;
  33758. /**
  33759. * 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.
  33760. * @returns the current mesh
  33761. */
  33762. freezeNormals(): Mesh;
  33763. /**
  33764. * 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
  33765. * @returns the current mesh
  33766. */
  33767. unfreezeNormals(): Mesh;
  33768. /**
  33769. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33770. */
  33771. set overridenInstanceCount(count: number);
  33772. /** @hidden */
  33773. _preActivate(): Mesh;
  33774. /** @hidden */
  33775. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33776. /** @hidden */
  33777. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33778. protected _afterComputeWorldMatrix(): void;
  33779. /** @hidden */
  33780. _postActivate(): void;
  33781. /**
  33782. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33783. * This means the mesh underlying bounding box and sphere are recomputed.
  33784. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33785. * @returns the current mesh
  33786. */
  33787. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33788. /** @hidden */
  33789. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33790. /**
  33791. * This function will subdivide the mesh into multiple submeshes
  33792. * @param count defines the expected number of submeshes
  33793. */
  33794. subdivide(count: number): void;
  33795. /**
  33796. * Copy a FloatArray into a specific associated vertex buffer
  33797. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33798. * - VertexBuffer.PositionKind
  33799. * - VertexBuffer.UVKind
  33800. * - VertexBuffer.UV2Kind
  33801. * - VertexBuffer.UV3Kind
  33802. * - VertexBuffer.UV4Kind
  33803. * - VertexBuffer.UV5Kind
  33804. * - VertexBuffer.UV6Kind
  33805. * - VertexBuffer.ColorKind
  33806. * - VertexBuffer.MatricesIndicesKind
  33807. * - VertexBuffer.MatricesIndicesExtraKind
  33808. * - VertexBuffer.MatricesWeightsKind
  33809. * - VertexBuffer.MatricesWeightsExtraKind
  33810. * @param data defines the data source
  33811. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33812. * @param stride defines the data stride size (can be null)
  33813. * @returns the current mesh
  33814. */
  33815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33816. /**
  33817. * Delete a vertex buffer associated with this mesh
  33818. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33819. * - VertexBuffer.PositionKind
  33820. * - VertexBuffer.UVKind
  33821. * - VertexBuffer.UV2Kind
  33822. * - VertexBuffer.UV3Kind
  33823. * - VertexBuffer.UV4Kind
  33824. * - VertexBuffer.UV5Kind
  33825. * - VertexBuffer.UV6Kind
  33826. * - VertexBuffer.ColorKind
  33827. * - VertexBuffer.MatricesIndicesKind
  33828. * - VertexBuffer.MatricesIndicesExtraKind
  33829. * - VertexBuffer.MatricesWeightsKind
  33830. * - VertexBuffer.MatricesWeightsExtraKind
  33831. */
  33832. removeVerticesData(kind: string): void;
  33833. /**
  33834. * Flags an associated vertex buffer as updatable
  33835. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33836. * - VertexBuffer.PositionKind
  33837. * - VertexBuffer.UVKind
  33838. * - VertexBuffer.UV2Kind
  33839. * - VertexBuffer.UV3Kind
  33840. * - VertexBuffer.UV4Kind
  33841. * - VertexBuffer.UV5Kind
  33842. * - VertexBuffer.UV6Kind
  33843. * - VertexBuffer.ColorKind
  33844. * - VertexBuffer.MatricesIndicesKind
  33845. * - VertexBuffer.MatricesIndicesExtraKind
  33846. * - VertexBuffer.MatricesWeightsKind
  33847. * - VertexBuffer.MatricesWeightsExtraKind
  33848. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33849. */
  33850. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33851. /**
  33852. * Sets the mesh global Vertex Buffer
  33853. * @param buffer defines the buffer to use
  33854. * @returns the current mesh
  33855. */
  33856. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33857. /**
  33858. * Update a specific associated vertex buffer
  33859. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33860. * - VertexBuffer.PositionKind
  33861. * - VertexBuffer.UVKind
  33862. * - VertexBuffer.UV2Kind
  33863. * - VertexBuffer.UV3Kind
  33864. * - VertexBuffer.UV4Kind
  33865. * - VertexBuffer.UV5Kind
  33866. * - VertexBuffer.UV6Kind
  33867. * - VertexBuffer.ColorKind
  33868. * - VertexBuffer.MatricesIndicesKind
  33869. * - VertexBuffer.MatricesIndicesExtraKind
  33870. * - VertexBuffer.MatricesWeightsKind
  33871. * - VertexBuffer.MatricesWeightsExtraKind
  33872. * @param data defines the data source
  33873. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33874. * @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)
  33875. * @returns the current mesh
  33876. */
  33877. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33878. /**
  33879. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33880. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33881. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33882. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33883. * @returns the current mesh
  33884. */
  33885. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33886. /**
  33887. * Creates a un-shared specific occurence of the geometry for the mesh.
  33888. * @returns the current mesh
  33889. */
  33890. makeGeometryUnique(): Mesh;
  33891. /**
  33892. * Set the index buffer of this mesh
  33893. * @param indices defines the source data
  33894. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33895. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33896. * @returns the current mesh
  33897. */
  33898. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33899. /**
  33900. * Update the current index buffer
  33901. * @param indices defines the source data
  33902. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33903. * @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)
  33904. * @returns the current mesh
  33905. */
  33906. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33907. /**
  33908. * Invert the geometry to move from a right handed system to a left handed one.
  33909. * @returns the current mesh
  33910. */
  33911. toLeftHanded(): Mesh;
  33912. /** @hidden */
  33913. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33914. /** @hidden */
  33915. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33916. /**
  33917. * Registers for this mesh a javascript function called just before the rendering process
  33918. * @param func defines the function to call before rendering this mesh
  33919. * @returns the current mesh
  33920. */
  33921. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33922. /**
  33923. * Disposes a previously registered javascript function called before the rendering
  33924. * @param func defines the function to remove
  33925. * @returns the current mesh
  33926. */
  33927. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33928. /**
  33929. * Registers for this mesh a javascript function called just after the rendering is complete
  33930. * @param func defines the function to call after rendering this mesh
  33931. * @returns the current mesh
  33932. */
  33933. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33934. /**
  33935. * Disposes a previously registered javascript function called after the rendering.
  33936. * @param func defines the function to remove
  33937. * @returns the current mesh
  33938. */
  33939. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33940. /** @hidden */
  33941. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33942. /** @hidden */
  33943. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33944. /** @hidden */
  33945. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33946. /** @hidden */
  33947. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33948. /** @hidden */
  33949. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33950. /** @hidden */
  33951. _rebuild(): void;
  33952. /** @hidden */
  33953. _freeze(): void;
  33954. /** @hidden */
  33955. _unFreeze(): void;
  33956. /**
  33957. * 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
  33958. * @param subMesh defines the subMesh to render
  33959. * @param enableAlphaMode defines if alpha mode can be changed
  33960. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33961. * @returns the current mesh
  33962. */
  33963. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33964. private _onBeforeDraw;
  33965. /**
  33966. * Renormalize the mesh and patch it up if there are no weights
  33967. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33968. * However in the case of zero weights then we set just a single influence to 1.
  33969. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33970. */
  33971. cleanMatrixWeights(): void;
  33972. private normalizeSkinFourWeights;
  33973. private normalizeSkinWeightsAndExtra;
  33974. /**
  33975. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33976. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33977. * the user know there was an issue with importing the mesh
  33978. * @returns a validation object with skinned, valid and report string
  33979. */
  33980. validateSkinning(): {
  33981. skinned: boolean;
  33982. valid: boolean;
  33983. report: string;
  33984. };
  33985. /** @hidden */
  33986. _checkDelayState(): Mesh;
  33987. private _queueLoad;
  33988. /**
  33989. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33990. * A mesh is in the frustum if its bounding box intersects the frustum
  33991. * @param frustumPlanes defines the frustum to test
  33992. * @returns true if the mesh is in the frustum planes
  33993. */
  33994. isInFrustum(frustumPlanes: Plane[]): boolean;
  33995. /**
  33996. * Sets the mesh material by the material or multiMaterial `id` property
  33997. * @param id is a string identifying the material or the multiMaterial
  33998. * @returns the current mesh
  33999. */
  34000. setMaterialByID(id: string): Mesh;
  34001. /**
  34002. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34003. * @returns an array of IAnimatable
  34004. */
  34005. getAnimatables(): IAnimatable[];
  34006. /**
  34007. * Modifies the mesh geometry according to the passed transformation matrix.
  34008. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34009. * The mesh normals are modified using the same transformation.
  34010. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34011. * @param transform defines the transform matrix to use
  34012. * @see https://doc.babylonjs.com/resources/baking_transformations
  34013. * @returns the current mesh
  34014. */
  34015. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34016. /**
  34017. * Modifies the mesh geometry according to its own current World Matrix.
  34018. * The mesh World Matrix is then reset.
  34019. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34020. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34021. * @see https://doc.babylonjs.com/resources/baking_transformations
  34022. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34023. * @returns the current mesh
  34024. */
  34025. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34026. /** @hidden */
  34027. get _positions(): Nullable<Vector3[]>;
  34028. /** @hidden */
  34029. _resetPointsArrayCache(): Mesh;
  34030. /** @hidden */
  34031. _generatePointsArray(): boolean;
  34032. /**
  34033. * Returns a new Mesh object generated from the current mesh properties.
  34034. * This method must not get confused with createInstance()
  34035. * @param name is a string, the name given to the new mesh
  34036. * @param newParent can be any Node object (default `null`)
  34037. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34038. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34039. * @returns a new mesh
  34040. */
  34041. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34042. /**
  34043. * Releases resources associated with this mesh.
  34044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34046. */
  34047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34048. /** @hidden */
  34049. _disposeInstanceSpecificData(): void;
  34050. /** @hidden */
  34051. _disposeThinInstanceSpecificData(): void;
  34052. /**
  34053. * Modifies the mesh geometry according to a displacement map.
  34054. * 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.
  34055. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34056. * @param url is a string, the URL from the image file is to be downloaded.
  34057. * @param minHeight is the lower limit of the displacement.
  34058. * @param maxHeight is the upper limit of the displacement.
  34059. * @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.
  34060. * @param uvOffset is an optional vector2 used to offset UV.
  34061. * @param uvScale is an optional vector2 used to scale UV.
  34062. * @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.
  34063. * @returns the Mesh.
  34064. */
  34065. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34066. /**
  34067. * Modifies the mesh geometry according to a displacementMap buffer.
  34068. * 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.
  34069. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34070. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34071. * @param heightMapWidth is the width of the buffer image.
  34072. * @param heightMapHeight is the height of the buffer image.
  34073. * @param minHeight is the lower limit of the displacement.
  34074. * @param maxHeight is the upper limit of the displacement.
  34075. * @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.
  34076. * @param uvOffset is an optional vector2 used to offset UV.
  34077. * @param uvScale is an optional vector2 used to scale UV.
  34078. * @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.
  34079. * @returns the Mesh.
  34080. */
  34081. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34082. /**
  34083. * Modify the mesh to get a flat shading rendering.
  34084. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34085. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34086. * @returns current mesh
  34087. */
  34088. convertToFlatShadedMesh(): Mesh;
  34089. /**
  34090. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34091. * In other words, more vertices, no more indices and a single bigger VBO.
  34092. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34093. * @returns current mesh
  34094. */
  34095. convertToUnIndexedMesh(): Mesh;
  34096. /**
  34097. * Inverses facet orientations.
  34098. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34099. * @param flipNormals will also inverts the normals
  34100. * @returns current mesh
  34101. */
  34102. flipFaces(flipNormals?: boolean): Mesh;
  34103. /**
  34104. * Increase the number of facets and hence vertices in a mesh
  34105. * Vertex normals are interpolated from existing vertex normals
  34106. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34107. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34108. */
  34109. increaseVertices(numberPerEdge: number): void;
  34110. /**
  34111. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34112. * This will undo any application of covertToFlatShadedMesh
  34113. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34114. */
  34115. forceSharedVertices(): void;
  34116. /** @hidden */
  34117. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34118. /** @hidden */
  34119. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34120. /**
  34121. * Creates a new InstancedMesh object from the mesh model.
  34122. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34123. * @param name defines the name of the new instance
  34124. * @returns a new InstancedMesh
  34125. */
  34126. createInstance(name: string): InstancedMesh;
  34127. /**
  34128. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34129. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34130. * @returns the current mesh
  34131. */
  34132. synchronizeInstances(): Mesh;
  34133. /**
  34134. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34135. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34136. * This should be used together with the simplification to avoid disappearing triangles.
  34137. * @param successCallback an optional success callback to be called after the optimization finished.
  34138. * @returns the current mesh
  34139. */
  34140. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34141. /**
  34142. * Serialize current mesh
  34143. * @param serializationObject defines the object which will receive the serialization data
  34144. */
  34145. serialize(serializationObject: any): void;
  34146. /** @hidden */
  34147. _syncGeometryWithMorphTargetManager(): void;
  34148. /** @hidden */
  34149. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34150. /**
  34151. * Returns a new Mesh object parsed from the source provided.
  34152. * @param parsedMesh is the source
  34153. * @param scene defines the hosting scene
  34154. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34155. * @returns a new Mesh
  34156. */
  34157. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34158. /**
  34159. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34160. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34161. * @param name defines the name of the mesh to create
  34162. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34163. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34164. * @param closePath creates a seam between the first and the last points of each path of the path array
  34165. * @param offset is taken in account only if the `pathArray` is containing a single path
  34166. * @param scene defines the hosting scene
  34167. * @param updatable defines if the mesh must be flagged as updatable
  34168. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34169. * @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)
  34170. * @returns a new Mesh
  34171. */
  34172. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34173. /**
  34174. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34175. * @param name defines the name of the mesh to create
  34176. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34177. * @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
  34178. * @param scene defines the hosting scene
  34179. * @param updatable defines if the mesh must be flagged as updatable
  34180. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34181. * @returns a new Mesh
  34182. */
  34183. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34184. /**
  34185. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34186. * @param name defines the name of the mesh to create
  34187. * @param size sets the size (float) of each box side (default 1)
  34188. * @param scene defines the hosting scene
  34189. * @param updatable defines if the mesh must be flagged as updatable
  34190. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34191. * @returns a new Mesh
  34192. */
  34193. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34194. /**
  34195. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34196. * @param name defines the name of the mesh to create
  34197. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34198. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34199. * @param scene defines the hosting scene
  34200. * @param updatable defines if the mesh must be flagged as updatable
  34201. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34202. * @returns a new Mesh
  34203. */
  34204. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34205. /**
  34206. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34207. * @param name defines the name of the mesh to create
  34208. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34209. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34210. * @param scene defines the hosting scene
  34211. * @returns a new Mesh
  34212. */
  34213. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34214. /**
  34215. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34216. * @param name defines the name of the mesh to create
  34217. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34218. * @param diameterTop set the top cap diameter (floats, default 1)
  34219. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34220. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34221. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34222. * @param scene defines the hosting scene
  34223. * @param updatable defines if the mesh must be flagged as updatable
  34224. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34225. * @returns a new Mesh
  34226. */
  34227. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34228. /**
  34229. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34230. * @param name defines the name of the mesh to create
  34231. * @param diameter sets the diameter size (float) of the torus (default 1)
  34232. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34233. * @param tessellation sets the number of torus sides (positive integer, default 16)
  34234. * @param scene defines the hosting scene
  34235. * @param updatable defines if the mesh must be flagged as updatable
  34236. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34237. * @returns a new Mesh
  34238. */
  34239. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34240. /**
  34241. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34242. * @param name defines the name of the mesh to create
  34243. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34244. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34245. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34246. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34247. * @param p the number of windings on X axis (positive integers, default 2)
  34248. * @param q the number of windings on Y axis (positive integers, default 3)
  34249. * @param scene defines the hosting scene
  34250. * @param updatable defines if the mesh must be flagged as updatable
  34251. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34252. * @returns a new Mesh
  34253. */
  34254. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34255. /**
  34256. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34257. * @param name defines the name of the mesh to create
  34258. * @param points is an array successive Vector3
  34259. * @param scene defines the hosting scene
  34260. * @param updatable defines if the mesh must be flagged as updatable
  34261. * @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).
  34262. * @returns a new Mesh
  34263. */
  34264. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34265. /**
  34266. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34267. * @param name defines the name of the mesh to create
  34268. * @param points is an array successive Vector3
  34269. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34270. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34271. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34272. * @param scene defines the hosting scene
  34273. * @param updatable defines if the mesh must be flagged as updatable
  34274. * @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)
  34275. * @returns a new Mesh
  34276. */
  34277. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34278. /**
  34279. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34280. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34281. * 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.
  34282. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34283. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34284. * Remember you can only change the shape positions, not their number when updating a polygon.
  34285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34286. * @param name defines the name of the mesh to create
  34287. * @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
  34288. * @param scene defines the hosting scene
  34289. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34290. * @param updatable defines if the mesh must be flagged as updatable
  34291. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34292. * @param earcutInjection can be used to inject your own earcut reference
  34293. * @returns a new Mesh
  34294. */
  34295. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34296. /**
  34297. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34299. * @param name defines the name of the mesh to create
  34300. * @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
  34301. * @param depth defines the height of extrusion
  34302. * @param scene defines the hosting scene
  34303. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34304. * @param updatable defines if the mesh must be flagged as updatable
  34305. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34306. * @param earcutInjection can be used to inject your own earcut reference
  34307. * @returns a new Mesh
  34308. */
  34309. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34310. /**
  34311. * Creates an extruded shape mesh.
  34312. * 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
  34313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34315. * @param name defines the name of the mesh to create
  34316. * @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
  34317. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34318. * @param scale is the value to scale the shape
  34319. * @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
  34320. * @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
  34321. * @param scene defines the hosting scene
  34322. * @param updatable defines if the mesh must be flagged as updatable
  34323. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34324. * @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)
  34325. * @returns a new Mesh
  34326. */
  34327. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34328. /**
  34329. * Creates an custom extruded shape mesh.
  34330. * The custom extrusion is a parametric shape.
  34331. * It has no predefined shape. Its final shape will depend on the input parameters.
  34332. * Please consider using the same method from the MeshBuilder class instead
  34333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34334. * @param name defines the name of the mesh to create
  34335. * @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
  34336. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34337. * @param scaleFunction is a custom Javascript function called on each path point
  34338. * @param rotationFunction is a custom Javascript function called on each path point
  34339. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34340. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34341. * @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
  34342. * @param scene defines the hosting scene
  34343. * @param updatable defines if the mesh must be flagged as updatable
  34344. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34345. * @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)
  34346. * @returns a new Mesh
  34347. */
  34348. 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;
  34349. /**
  34350. * Creates lathe mesh.
  34351. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34352. * Please consider using the same method from the MeshBuilder class instead
  34353. * @param name defines the name of the mesh to create
  34354. * @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
  34355. * @param radius is the radius value of the lathe
  34356. * @param tessellation is the side number of the lathe.
  34357. * @param scene defines the hosting scene
  34358. * @param updatable defines if the mesh must be flagged as updatable
  34359. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34360. * @returns a new Mesh
  34361. */
  34362. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34363. /**
  34364. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34365. * @param name defines the name of the mesh to create
  34366. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34367. * @param scene defines the hosting scene
  34368. * @param updatable defines if the mesh must be flagged as updatable
  34369. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34370. * @returns a new Mesh
  34371. */
  34372. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34373. /**
  34374. * Creates a ground mesh.
  34375. * Please consider using the same method from the MeshBuilder class instead
  34376. * @param name defines the name of the mesh to create
  34377. * @param width set the width of the ground
  34378. * @param height set the height of the ground
  34379. * @param subdivisions sets the number of subdivisions per side
  34380. * @param scene defines the hosting scene
  34381. * @param updatable defines if the mesh must be flagged as updatable
  34382. * @returns a new Mesh
  34383. */
  34384. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34385. /**
  34386. * Creates a tiled ground mesh.
  34387. * Please consider using the same method from the MeshBuilder class instead
  34388. * @param name defines the name of the mesh to create
  34389. * @param xmin set the ground minimum X coordinate
  34390. * @param zmin set the ground minimum Y coordinate
  34391. * @param xmax set the ground maximum X coordinate
  34392. * @param zmax set the ground maximum Z coordinate
  34393. * @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
  34394. * @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
  34395. * @param scene defines the hosting scene
  34396. * @param updatable defines if the mesh must be flagged as updatable
  34397. * @returns a new Mesh
  34398. */
  34399. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34400. w: number;
  34401. h: number;
  34402. }, precision: {
  34403. w: number;
  34404. h: number;
  34405. }, scene: Scene, updatable?: boolean): Mesh;
  34406. /**
  34407. * Creates a ground mesh from a height map.
  34408. * Please consider using the same method from the MeshBuilder class instead
  34409. * @see https://doc.babylonjs.com/babylon101/height_map
  34410. * @param name defines the name of the mesh to create
  34411. * @param url sets the URL of the height map image resource
  34412. * @param width set the ground width size
  34413. * @param height set the ground height size
  34414. * @param subdivisions sets the number of subdivision per side
  34415. * @param minHeight is the minimum altitude on the ground
  34416. * @param maxHeight is the maximum altitude on the ground
  34417. * @param scene defines the hosting scene
  34418. * @param updatable defines if the mesh must be flagged as updatable
  34419. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34420. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34421. * @returns a new Mesh
  34422. */
  34423. 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;
  34424. /**
  34425. * Creates a tube mesh.
  34426. * The tube is a parametric shape.
  34427. * It has no predefined shape. Its final shape will depend on the input parameters.
  34428. * Please consider using the same method from the MeshBuilder class instead
  34429. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34430. * @param name defines the name of the mesh to create
  34431. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34432. * @param radius sets the tube radius size
  34433. * @param tessellation is the number of sides on the tubular surface
  34434. * @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
  34435. * @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
  34436. * @param scene defines the hosting scene
  34437. * @param updatable defines if the mesh must be flagged as updatable
  34438. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34439. * @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)
  34440. * @returns a new Mesh
  34441. */
  34442. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34443. (i: number, distance: number): number;
  34444. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34445. /**
  34446. * Creates a polyhedron mesh.
  34447. * Please consider using the same method from the MeshBuilder class instead.
  34448. * * 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
  34449. * * The parameter `size` (positive float, default 1) sets the polygon size
  34450. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34451. * * 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`
  34452. * * 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
  34453. * * 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)`)
  34454. * * 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
  34455. * * 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
  34456. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34457. * * 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
  34458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34459. * @param name defines the name of the mesh to create
  34460. * @param options defines the options used to create the mesh
  34461. * @param scene defines the hosting scene
  34462. * @returns a new Mesh
  34463. */
  34464. static CreatePolyhedron(name: string, options: {
  34465. type?: number;
  34466. size?: number;
  34467. sizeX?: number;
  34468. sizeY?: number;
  34469. sizeZ?: number;
  34470. custom?: any;
  34471. faceUV?: Vector4[];
  34472. faceColors?: Color4[];
  34473. updatable?: boolean;
  34474. sideOrientation?: number;
  34475. }, scene: Scene): Mesh;
  34476. /**
  34477. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34478. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34479. * * 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`)
  34480. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34481. * * 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
  34482. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34483. * * 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
  34484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34485. * @param name defines the name of the mesh
  34486. * @param options defines the options used to create the mesh
  34487. * @param scene defines the hosting scene
  34488. * @returns a new Mesh
  34489. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34490. */
  34491. static CreateIcoSphere(name: string, options: {
  34492. radius?: number;
  34493. flat?: boolean;
  34494. subdivisions?: number;
  34495. sideOrientation?: number;
  34496. updatable?: boolean;
  34497. }, scene: Scene): Mesh;
  34498. /**
  34499. * Creates a decal mesh.
  34500. * Please consider using the same method from the MeshBuilder class instead.
  34501. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34502. * @param name defines the name of the mesh
  34503. * @param sourceMesh defines the mesh receiving the decal
  34504. * @param position sets the position of the decal in world coordinates
  34505. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34506. * @param size sets the decal scaling
  34507. * @param angle sets the angle to rotate the decal
  34508. * @returns a new Mesh
  34509. */
  34510. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34511. /** Creates a Capsule Mesh
  34512. * @param name defines the name of the mesh.
  34513. * @param options the constructors options used to shape the mesh.
  34514. * @param scene defines the scene the mesh is scoped to.
  34515. * @returns the capsule mesh
  34516. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34517. */
  34518. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34519. /**
  34520. * Prepare internal position array for software CPU skinning
  34521. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34522. */
  34523. setPositionsForCPUSkinning(): Float32Array;
  34524. /**
  34525. * Prepare internal normal array for software CPU skinning
  34526. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34527. */
  34528. setNormalsForCPUSkinning(): Float32Array;
  34529. /**
  34530. * Updates the vertex buffer by applying transformation from the bones
  34531. * @param skeleton defines the skeleton to apply to current mesh
  34532. * @returns the current mesh
  34533. */
  34534. applySkeleton(skeleton: Skeleton): Mesh;
  34535. /**
  34536. * 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
  34537. * @param meshes defines the list of meshes to scan
  34538. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34539. */
  34540. static MinMax(meshes: AbstractMesh[]): {
  34541. min: Vector3;
  34542. max: Vector3;
  34543. };
  34544. /**
  34545. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34546. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34547. * @returns a vector3
  34548. */
  34549. static Center(meshesOrMinMaxVector: {
  34550. min: Vector3;
  34551. max: Vector3;
  34552. } | AbstractMesh[]): Vector3;
  34553. /**
  34554. * Merge the array of meshes into a single mesh for performance reasons.
  34555. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34556. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34557. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34558. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34559. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34560. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34561. * @returns a new mesh
  34562. */
  34563. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34564. /** @hidden */
  34565. addInstance(instance: InstancedMesh): void;
  34566. /** @hidden */
  34567. removeInstance(instance: InstancedMesh): void;
  34568. }
  34569. }
  34570. declare module BABYLON {
  34571. /**
  34572. * The options Interface for creating a Capsule Mesh
  34573. */
  34574. export interface ICreateCapsuleOptions {
  34575. /** The Orientation of the capsule. Default : Vector3.Up() */
  34576. orientation?: Vector3;
  34577. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34578. subdivisions: number;
  34579. /** Number of cylindrical segments on the capsule. */
  34580. tessellation: number;
  34581. /** Height or Length of the capsule. */
  34582. height: number;
  34583. /** Radius of the capsule. */
  34584. radius: number;
  34585. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34586. capSubdivisions: number;
  34587. /** Overwrite for the top radius. */
  34588. radiusTop?: number;
  34589. /** Overwrite for the bottom radius. */
  34590. radiusBottom?: number;
  34591. /** Overwrite for the top capSubdivisions. */
  34592. topCapSubdivisions?: number;
  34593. /** Overwrite for the bottom capSubdivisions. */
  34594. bottomCapSubdivisions?: number;
  34595. /** Internal geometry is supposed to change once created. */
  34596. updatable?: boolean;
  34597. }
  34598. /**
  34599. * Class containing static functions to help procedurally build meshes
  34600. */
  34601. export class CapsuleBuilder {
  34602. /**
  34603. * Creates a capsule or a pill mesh
  34604. * @param name defines the name of the mesh
  34605. * @param options The constructors options.
  34606. * @param scene The scene the mesh is scoped to.
  34607. * @returns Capsule Mesh
  34608. */
  34609. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  34610. }
  34611. }
  34612. declare module BABYLON {
  34613. /**
  34614. * Define an interface for all classes that will get and set the data on vertices
  34615. */
  34616. export interface IGetSetVerticesData {
  34617. /**
  34618. * Gets a boolean indicating if specific vertex data is present
  34619. * @param kind defines the vertex data kind to use
  34620. * @returns true is data kind is present
  34621. */
  34622. isVerticesDataPresent(kind: string): boolean;
  34623. /**
  34624. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34625. * @param kind defines the data kind (Position, normal, etc...)
  34626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34628. * @returns a float array containing vertex data
  34629. */
  34630. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34631. /**
  34632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34633. * @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.
  34634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34635. * @returns the indices array or an empty array if the mesh has no geometry
  34636. */
  34637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34638. /**
  34639. * Set specific vertex data
  34640. * @param kind defines the data kind (Position, normal, etc...)
  34641. * @param data defines the vertex data to use
  34642. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34643. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34644. */
  34645. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34646. /**
  34647. * Update a specific associated vertex buffer
  34648. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34649. * - VertexBuffer.PositionKind
  34650. * - VertexBuffer.UVKind
  34651. * - VertexBuffer.UV2Kind
  34652. * - VertexBuffer.UV3Kind
  34653. * - VertexBuffer.UV4Kind
  34654. * - VertexBuffer.UV5Kind
  34655. * - VertexBuffer.UV6Kind
  34656. * - VertexBuffer.ColorKind
  34657. * - VertexBuffer.MatricesIndicesKind
  34658. * - VertexBuffer.MatricesIndicesExtraKind
  34659. * - VertexBuffer.MatricesWeightsKind
  34660. * - VertexBuffer.MatricesWeightsExtraKind
  34661. * @param data defines the data source
  34662. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34663. * @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)
  34664. */
  34665. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34666. /**
  34667. * Creates a new index buffer
  34668. * @param indices defines the indices to store in the index buffer
  34669. * @param totalVertices defines the total number of vertices (could be null)
  34670. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34671. */
  34672. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34673. }
  34674. /**
  34675. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34676. */
  34677. export class VertexData {
  34678. /**
  34679. * Mesh side orientation : usually the external or front surface
  34680. */
  34681. static readonly FRONTSIDE: number;
  34682. /**
  34683. * Mesh side orientation : usually the internal or back surface
  34684. */
  34685. static readonly BACKSIDE: number;
  34686. /**
  34687. * Mesh side orientation : both internal and external or front and back surfaces
  34688. */
  34689. static readonly DOUBLESIDE: number;
  34690. /**
  34691. * Mesh side orientation : by default, `FRONTSIDE`
  34692. */
  34693. static readonly DEFAULTSIDE: number;
  34694. /**
  34695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34696. */
  34697. positions: Nullable<FloatArray>;
  34698. /**
  34699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34700. */
  34701. normals: Nullable<FloatArray>;
  34702. /**
  34703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34704. */
  34705. tangents: Nullable<FloatArray>;
  34706. /**
  34707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34708. */
  34709. uvs: Nullable<FloatArray>;
  34710. /**
  34711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34712. */
  34713. uvs2: Nullable<FloatArray>;
  34714. /**
  34715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34716. */
  34717. uvs3: Nullable<FloatArray>;
  34718. /**
  34719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34720. */
  34721. uvs4: Nullable<FloatArray>;
  34722. /**
  34723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34724. */
  34725. uvs5: Nullable<FloatArray>;
  34726. /**
  34727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34728. */
  34729. uvs6: Nullable<FloatArray>;
  34730. /**
  34731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34732. */
  34733. colors: Nullable<FloatArray>;
  34734. /**
  34735. * 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).
  34736. */
  34737. matricesIndices: Nullable<FloatArray>;
  34738. /**
  34739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34740. */
  34741. matricesWeights: Nullable<FloatArray>;
  34742. /**
  34743. * An array extending the number of possible indices
  34744. */
  34745. matricesIndicesExtra: Nullable<FloatArray>;
  34746. /**
  34747. * An array extending the number of possible weights when the number of indices is extended
  34748. */
  34749. matricesWeightsExtra: Nullable<FloatArray>;
  34750. /**
  34751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34752. */
  34753. indices: Nullable<IndicesArray>;
  34754. /**
  34755. * Uses the passed data array to set the set the values for the specified kind of data
  34756. * @param data a linear array of floating numbers
  34757. * @param kind the type of data that is being set, eg positions, colors etc
  34758. */
  34759. set(data: FloatArray, kind: string): void;
  34760. /**
  34761. * Associates the vertexData to the passed Mesh.
  34762. * Sets it as updatable or not (default `false`)
  34763. * @param mesh the mesh the vertexData is applied to
  34764. * @param updatable when used and having the value true allows new data to update the vertexData
  34765. * @returns the VertexData
  34766. */
  34767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34768. /**
  34769. * Associates the vertexData to the passed Geometry.
  34770. * Sets it as updatable or not (default `false`)
  34771. * @param geometry the geometry the vertexData is applied to
  34772. * @param updatable when used and having the value true allows new data to update the vertexData
  34773. * @returns VertexData
  34774. */
  34775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34776. /**
  34777. * Updates the associated mesh
  34778. * @param mesh the mesh to be updated
  34779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34780. * @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
  34781. * @returns VertexData
  34782. */
  34783. updateMesh(mesh: Mesh): VertexData;
  34784. /**
  34785. * Updates the associated geometry
  34786. * @param geometry the geometry to be updated
  34787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34788. * @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
  34789. * @returns VertexData.
  34790. */
  34791. updateGeometry(geometry: Geometry): VertexData;
  34792. private _applyTo;
  34793. private _update;
  34794. /**
  34795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34796. * @param matrix the transforming matrix
  34797. * @returns the VertexData
  34798. */
  34799. transform(matrix: Matrix): VertexData;
  34800. /**
  34801. * Merges the passed VertexData into the current one
  34802. * @param other the VertexData to be merged into the current one
  34803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34804. * @returns the modified VertexData
  34805. */
  34806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34807. private _mergeElement;
  34808. private _validate;
  34809. /**
  34810. * Serializes the VertexData
  34811. * @returns a serialized object
  34812. */
  34813. serialize(): any;
  34814. /**
  34815. * Extracts the vertexData from a mesh
  34816. * @param mesh the mesh from which to extract the VertexData
  34817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34819. * @returns the object VertexData associated to the passed mesh
  34820. */
  34821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34822. /**
  34823. * Extracts the vertexData from the geometry
  34824. * @param geometry the geometry from which to extract the VertexData
  34825. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  34826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34827. * @returns the object VertexData associated to the passed mesh
  34828. */
  34829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34830. private static _ExtractFrom;
  34831. /**
  34832. * Creates the VertexData for a Ribbon
  34833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34834. * * pathArray array of paths, each of which an array of successive Vector3
  34835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34837. * * 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
  34838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34839. * * 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)
  34840. * * 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)
  34841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34844. * @returns the VertexData of the ribbon
  34845. */
  34846. static CreateRibbon(options: {
  34847. pathArray: Vector3[][];
  34848. closeArray?: boolean;
  34849. closePath?: boolean;
  34850. offset?: number;
  34851. sideOrientation?: number;
  34852. frontUVs?: Vector4;
  34853. backUVs?: Vector4;
  34854. invertUV?: boolean;
  34855. uvs?: Vector2[];
  34856. colors?: Color4[];
  34857. }): VertexData;
  34858. /**
  34859. * Creates the VertexData for a box
  34860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34868. * * 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)
  34869. * * 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)
  34870. * @returns the VertexData of the box
  34871. */
  34872. static CreateBox(options: {
  34873. size?: number;
  34874. width?: number;
  34875. height?: number;
  34876. depth?: number;
  34877. faceUV?: Vector4[];
  34878. faceColors?: Color4[];
  34879. sideOrientation?: number;
  34880. frontUVs?: Vector4;
  34881. backUVs?: Vector4;
  34882. }): VertexData;
  34883. /**
  34884. * Creates the VertexData for a tiled box
  34885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34886. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34887. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34888. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34890. * @returns the VertexData of the box
  34891. */
  34892. static CreateTiledBox(options: {
  34893. pattern?: number;
  34894. width?: number;
  34895. height?: number;
  34896. depth?: number;
  34897. tileSize?: number;
  34898. tileWidth?: number;
  34899. tileHeight?: number;
  34900. alignHorizontal?: number;
  34901. alignVertical?: number;
  34902. faceUV?: Vector4[];
  34903. faceColors?: Color4[];
  34904. sideOrientation?: number;
  34905. }): VertexData;
  34906. /**
  34907. * Creates the VertexData for a tiled plane
  34908. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34909. * * pattern a limited pattern arrangement depending on the number
  34910. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34911. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34912. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34913. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34914. * * 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)
  34915. * * 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)
  34916. * @returns the VertexData of the tiled plane
  34917. */
  34918. static CreateTiledPlane(options: {
  34919. pattern?: number;
  34920. tileSize?: number;
  34921. tileWidth?: number;
  34922. tileHeight?: number;
  34923. size?: number;
  34924. width?: number;
  34925. height?: number;
  34926. alignHorizontal?: number;
  34927. alignVertical?: number;
  34928. sideOrientation?: number;
  34929. frontUVs?: Vector4;
  34930. backUVs?: Vector4;
  34931. }): VertexData;
  34932. /**
  34933. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34934. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34935. * * segments sets the number of horizontal strips optional, default 32
  34936. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34937. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34938. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34939. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34940. * * 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
  34941. * * 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
  34942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34943. * * 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)
  34944. * * 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)
  34945. * @returns the VertexData of the ellipsoid
  34946. */
  34947. static CreateSphere(options: {
  34948. segments?: number;
  34949. diameter?: number;
  34950. diameterX?: number;
  34951. diameterY?: number;
  34952. diameterZ?: number;
  34953. arc?: number;
  34954. slice?: number;
  34955. sideOrientation?: number;
  34956. frontUVs?: Vector4;
  34957. backUVs?: Vector4;
  34958. }): VertexData;
  34959. /**
  34960. * Creates the VertexData for a cylinder, cone or prism
  34961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34962. * * height sets the height (y direction) of the cylinder, optional, default 2
  34963. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34964. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34965. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34966. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34967. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34968. * * 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
  34969. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34970. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34971. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34972. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34974. * * 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)
  34975. * * 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)
  34976. * @returns the VertexData of the cylinder, cone or prism
  34977. */
  34978. static CreateCylinder(options: {
  34979. height?: number;
  34980. diameterTop?: number;
  34981. diameterBottom?: number;
  34982. diameter?: number;
  34983. tessellation?: number;
  34984. subdivisions?: number;
  34985. arc?: number;
  34986. faceColors?: Color4[];
  34987. faceUV?: Vector4[];
  34988. hasRings?: boolean;
  34989. enclose?: boolean;
  34990. sideOrientation?: number;
  34991. frontUVs?: Vector4;
  34992. backUVs?: Vector4;
  34993. }): VertexData;
  34994. /**
  34995. * Creates the VertexData for a torus
  34996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34997. * * diameter the diameter of the torus, optional default 1
  34998. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34999. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35000. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35001. * * 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)
  35002. * * 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)
  35003. * @returns the VertexData of the torus
  35004. */
  35005. static CreateTorus(options: {
  35006. diameter?: number;
  35007. thickness?: number;
  35008. tessellation?: number;
  35009. sideOrientation?: number;
  35010. frontUVs?: Vector4;
  35011. backUVs?: Vector4;
  35012. }): VertexData;
  35013. /**
  35014. * Creates the VertexData of the LineSystem
  35015. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35016. * - lines an array of lines, each line being an array of successive Vector3
  35017. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35018. * @returns the VertexData of the LineSystem
  35019. */
  35020. static CreateLineSystem(options: {
  35021. lines: Vector3[][];
  35022. colors?: Nullable<Color4[][]>;
  35023. }): VertexData;
  35024. /**
  35025. * Create the VertexData for a DashedLines
  35026. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35027. * - points an array successive Vector3
  35028. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35029. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35030. * - dashNb the intended total number of dashes, optional, default 200
  35031. * @returns the VertexData for the DashedLines
  35032. */
  35033. static CreateDashedLines(options: {
  35034. points: Vector3[];
  35035. dashSize?: number;
  35036. gapSize?: number;
  35037. dashNb?: number;
  35038. }): VertexData;
  35039. /**
  35040. * Creates the VertexData for a Ground
  35041. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35042. * - width the width (x direction) of the ground, optional, default 1
  35043. * - height the height (z direction) of the ground, optional, default 1
  35044. * - subdivisions the number of subdivisions per side, optional, default 1
  35045. * @returns the VertexData of the Ground
  35046. */
  35047. static CreateGround(options: {
  35048. width?: number;
  35049. height?: number;
  35050. subdivisions?: number;
  35051. subdivisionsX?: number;
  35052. subdivisionsY?: number;
  35053. }): VertexData;
  35054. /**
  35055. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35056. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35057. * * xmin the ground minimum X coordinate, optional, default -1
  35058. * * zmin the ground minimum Z coordinate, optional, default -1
  35059. * * xmax the ground maximum X coordinate, optional, default 1
  35060. * * zmax the ground maximum Z coordinate, optional, default 1
  35061. * * 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}
  35062. * * 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}
  35063. * @returns the VertexData of the TiledGround
  35064. */
  35065. static CreateTiledGround(options: {
  35066. xmin: number;
  35067. zmin: number;
  35068. xmax: number;
  35069. zmax: number;
  35070. subdivisions?: {
  35071. w: number;
  35072. h: number;
  35073. };
  35074. precision?: {
  35075. w: number;
  35076. h: number;
  35077. };
  35078. }): VertexData;
  35079. /**
  35080. * Creates the VertexData of the Ground designed from a heightmap
  35081. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35082. * * width the width (x direction) of the ground
  35083. * * height the height (z direction) of the ground
  35084. * * subdivisions the number of subdivisions per side
  35085. * * minHeight the minimum altitude on the ground, optional, default 0
  35086. * * maxHeight the maximum altitude on the ground, optional default 1
  35087. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35088. * * buffer the array holding the image color data
  35089. * * bufferWidth the width of image
  35090. * * bufferHeight the height of image
  35091. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35092. * @returns the VertexData of the Ground designed from a heightmap
  35093. */
  35094. static CreateGroundFromHeightMap(options: {
  35095. width: number;
  35096. height: number;
  35097. subdivisions: number;
  35098. minHeight: number;
  35099. maxHeight: number;
  35100. colorFilter: Color3;
  35101. buffer: Uint8Array;
  35102. bufferWidth: number;
  35103. bufferHeight: number;
  35104. alphaFilter: number;
  35105. }): VertexData;
  35106. /**
  35107. * Creates the VertexData for a Plane
  35108. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35109. * * size sets the width and height of the plane to the value of size, optional default 1
  35110. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35111. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35113. * * 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)
  35114. * * 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)
  35115. * @returns the VertexData of the box
  35116. */
  35117. static CreatePlane(options: {
  35118. size?: number;
  35119. width?: number;
  35120. height?: number;
  35121. sideOrientation?: number;
  35122. frontUVs?: Vector4;
  35123. backUVs?: Vector4;
  35124. }): VertexData;
  35125. /**
  35126. * Creates the VertexData of the Disc or regular Polygon
  35127. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35128. * * radius the radius of the disc, optional default 0.5
  35129. * * tessellation the number of polygon sides, optional, default 64
  35130. * * 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
  35131. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35132. * * 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)
  35133. * * 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)
  35134. * @returns the VertexData of the box
  35135. */
  35136. static CreateDisc(options: {
  35137. radius?: number;
  35138. tessellation?: number;
  35139. arc?: number;
  35140. sideOrientation?: number;
  35141. frontUVs?: Vector4;
  35142. backUVs?: Vector4;
  35143. }): VertexData;
  35144. /**
  35145. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35146. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35147. * @param polygon a mesh built from polygonTriangulation.build()
  35148. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35149. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35150. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35151. * @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)
  35152. * @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)
  35153. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35154. * @returns the VertexData of the Polygon
  35155. */
  35156. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35157. /**
  35158. * Creates the VertexData of the IcoSphere
  35159. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35160. * * radius the radius of the IcoSphere, optional default 1
  35161. * * radiusX allows stretching in the x direction, optional, default radius
  35162. * * radiusY allows stretching in the y direction, optional, default radius
  35163. * * radiusZ allows stretching in the z direction, optional, default radius
  35164. * * flat when true creates a flat shaded mesh, optional, default true
  35165. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35167. * * 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)
  35168. * * 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)
  35169. * @returns the VertexData of the IcoSphere
  35170. */
  35171. static CreateIcoSphere(options: {
  35172. radius?: number;
  35173. radiusX?: number;
  35174. radiusY?: number;
  35175. radiusZ?: number;
  35176. flat?: boolean;
  35177. subdivisions?: number;
  35178. sideOrientation?: number;
  35179. frontUVs?: Vector4;
  35180. backUVs?: Vector4;
  35181. }): VertexData;
  35182. /**
  35183. * Creates the VertexData for a Polyhedron
  35184. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35185. * * type provided types are:
  35186. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35187. * * 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)
  35188. * * size the size of the IcoSphere, optional default 1
  35189. * * sizeX allows stretching in the x direction, optional, default size
  35190. * * sizeY allows stretching in the y direction, optional, default size
  35191. * * sizeZ allows stretching in the z direction, optional, default size
  35192. * * 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
  35193. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35194. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35195. * * flat when true creates a flat shaded mesh, optional, default true
  35196. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35198. * * 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)
  35199. * * 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)
  35200. * @returns the VertexData of the Polyhedron
  35201. */
  35202. static CreatePolyhedron(options: {
  35203. type?: number;
  35204. size?: number;
  35205. sizeX?: number;
  35206. sizeY?: number;
  35207. sizeZ?: number;
  35208. custom?: any;
  35209. faceUV?: Vector4[];
  35210. faceColors?: Color4[];
  35211. flat?: boolean;
  35212. sideOrientation?: number;
  35213. frontUVs?: Vector4;
  35214. backUVs?: Vector4;
  35215. }): VertexData;
  35216. /**
  35217. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35218. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35219. * @returns the VertexData of the Capsule
  35220. */
  35221. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35222. /**
  35223. * Creates the VertexData for a TorusKnot
  35224. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35225. * * radius the radius of the torus knot, optional, default 2
  35226. * * tube the thickness of the tube, optional, default 0.5
  35227. * * radialSegments the number of sides on each tube segments, optional, default 32
  35228. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35229. * * p the number of windings around the z axis, optional, default 2
  35230. * * q the number of windings around the x axis, optional, default 3
  35231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35232. * * 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)
  35233. * * 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)
  35234. * @returns the VertexData of the Torus Knot
  35235. */
  35236. static CreateTorusKnot(options: {
  35237. radius?: number;
  35238. tube?: number;
  35239. radialSegments?: number;
  35240. tubularSegments?: number;
  35241. p?: number;
  35242. q?: number;
  35243. sideOrientation?: number;
  35244. frontUVs?: Vector4;
  35245. backUVs?: Vector4;
  35246. }): VertexData;
  35247. /**
  35248. * Compute normals for given positions and indices
  35249. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35250. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35251. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35252. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35253. * * facetNormals : optional array of facet normals (vector3)
  35254. * * facetPositions : optional array of facet positions (vector3)
  35255. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35256. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35257. * * bInfo : optional bounding info, required for facetPartitioning computation
  35258. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35259. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  35260. * * useRightHandedSystem: optional boolean to for right handed system computation
  35261. * * depthSort : optional boolean to enable the facet depth sort computation
  35262. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35263. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35264. */
  35265. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35266. facetNormals?: any;
  35267. facetPositions?: any;
  35268. facetPartitioning?: any;
  35269. ratio?: number;
  35270. bInfo?: any;
  35271. bbSize?: Vector3;
  35272. subDiv?: any;
  35273. useRightHandedSystem?: boolean;
  35274. depthSort?: boolean;
  35275. distanceTo?: Vector3;
  35276. depthSortedFacets?: any;
  35277. }): void;
  35278. /** @hidden */
  35279. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35280. /**
  35281. * Applies VertexData created from the imported parameters to the geometry
  35282. * @param parsedVertexData the parsed data from an imported file
  35283. * @param geometry the geometry to apply the VertexData to
  35284. */
  35285. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35286. }
  35287. }
  35288. declare module BABYLON {
  35289. /**
  35290. * Class containing static functions to help procedurally build meshes
  35291. */
  35292. export class DiscBuilder {
  35293. /**
  35294. * Creates a plane polygonal mesh. By default, this is a disc
  35295. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35296. * * 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
  35297. * * 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
  35298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35299. * * 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
  35300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35301. * @param name defines the name of the mesh
  35302. * @param options defines the options used to create the mesh
  35303. * @param scene defines the hosting scene
  35304. * @returns the plane polygonal mesh
  35305. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35306. */
  35307. static CreateDisc(name: string, options: {
  35308. radius?: number;
  35309. tessellation?: number;
  35310. arc?: number;
  35311. updatable?: boolean;
  35312. sideOrientation?: number;
  35313. frontUVs?: Vector4;
  35314. backUVs?: Vector4;
  35315. }, scene?: Nullable<Scene>): Mesh;
  35316. }
  35317. }
  35318. declare module BABYLON {
  35319. /**
  35320. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35321. *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.
  35322. * The SPS is also a particle system. It provides some methods to manage the particles.
  35323. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35324. *
  35325. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35326. */
  35327. export class SolidParticleSystem implements IDisposable {
  35328. /**
  35329. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35330. * Example : var p = SPS.particles[i];
  35331. */
  35332. particles: SolidParticle[];
  35333. /**
  35334. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35335. */
  35336. nbParticles: number;
  35337. /**
  35338. * If the particles must ever face the camera (default false). Useful for planar particles.
  35339. */
  35340. billboard: boolean;
  35341. /**
  35342. * Recompute normals when adding a shape
  35343. */
  35344. recomputeNormals: boolean;
  35345. /**
  35346. * This a counter ofr your own usage. It's not set by any SPS functions.
  35347. */
  35348. counter: number;
  35349. /**
  35350. * The SPS name. This name is also given to the underlying mesh.
  35351. */
  35352. name: string;
  35353. /**
  35354. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  35355. */
  35356. mesh: Mesh;
  35357. /**
  35358. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35359. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35360. */
  35361. vars: any;
  35362. /**
  35363. * This array is populated when the SPS is set as 'pickable'.
  35364. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35365. * Each element of this array is an object `{idx: int, faceId: int}`.
  35366. * `idx` is the picked particle index in the `SPS.particles` array
  35367. * `faceId` is the picked face index counted within this particle.
  35368. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35369. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35370. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35371. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35372. */
  35373. pickedParticles: {
  35374. idx: number;
  35375. faceId: number;
  35376. }[];
  35377. /**
  35378. * This array is populated when the SPS is set as 'pickable'
  35379. * Each key of this array is a submesh index.
  35380. * Each element of this array is a second array defined like this :
  35381. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35382. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35383. * `idx` is the picked particle index in the `SPS.particles` array
  35384. * `faceId` is the picked face index counted within this particle.
  35385. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35386. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35387. */
  35388. pickedBySubMesh: {
  35389. idx: number;
  35390. faceId: number;
  35391. }[][];
  35392. /**
  35393. * This array is populated when `enableDepthSort` is set to true.
  35394. * Each element of this array is an instance of the class DepthSortedParticle.
  35395. */
  35396. depthSortedParticles: DepthSortedParticle[];
  35397. /**
  35398. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35399. * @hidden
  35400. */
  35401. _bSphereOnly: boolean;
  35402. /**
  35403. * A number to multiply the bounding sphere radius by in order to reduce it for instance. (Internal use only)
  35404. * @hidden
  35405. */
  35406. _bSphereRadiusFactor: number;
  35407. private _scene;
  35408. private _positions;
  35409. private _indices;
  35410. private _normals;
  35411. private _colors;
  35412. private _uvs;
  35413. private _indices32;
  35414. private _positions32;
  35415. private _normals32;
  35416. private _fixedNormal32;
  35417. private _colors32;
  35418. private _uvs32;
  35419. private _index;
  35420. private _updatable;
  35421. private _pickable;
  35422. private _isVisibilityBoxLocked;
  35423. private _alwaysVisible;
  35424. private _depthSort;
  35425. private _expandable;
  35426. private _shapeCounter;
  35427. private _copy;
  35428. private _color;
  35429. private _computeParticleColor;
  35430. private _computeParticleTexture;
  35431. private _computeParticleRotation;
  35432. private _computeParticleVertex;
  35433. private _computeBoundingBox;
  35434. private _depthSortParticles;
  35435. private _camera;
  35436. private _mustUnrotateFixedNormals;
  35437. private _particlesIntersect;
  35438. private _needs32Bits;
  35439. private _isNotBuilt;
  35440. private _lastParticleId;
  35441. private _idxOfId;
  35442. private _multimaterialEnabled;
  35443. private _useModelMaterial;
  35444. private _indicesByMaterial;
  35445. private _materialIndexes;
  35446. private _depthSortFunction;
  35447. private _materialSortFunction;
  35448. private _materials;
  35449. private _multimaterial;
  35450. private _materialIndexesById;
  35451. private _defaultMaterial;
  35452. private _autoUpdateSubMeshes;
  35453. private _tmpVertex;
  35454. /**
  35455. * Creates a SPS (Solid Particle System) object.
  35456. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35457. * @param scene (Scene) is the scene in which the SPS is added.
  35458. * @param options defines the options of the sps e.g.
  35459. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35460. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35461. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35462. * * 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.
  35463. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35464. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35465. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35466. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35467. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the bounding sphere radius by in order to reduce it for instance.
  35468. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35469. */
  35470. constructor(name: string, scene: Scene, options?: {
  35471. updatable?: boolean;
  35472. isPickable?: boolean;
  35473. enableDepthSort?: boolean;
  35474. particleIntersection?: boolean;
  35475. boundingSphereOnly?: boolean;
  35476. bSphereRadiusFactor?: number;
  35477. expandable?: boolean;
  35478. useModelMaterial?: boolean;
  35479. enableMultiMaterial?: boolean;
  35480. });
  35481. /**
  35482. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35483. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35484. * @returns the created mesh
  35485. */
  35486. buildMesh(): Mesh;
  35487. /**
  35488. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35489. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35490. * Thus the particles generated from `digest()` have their property `position` set yet.
  35491. * @param mesh ( Mesh ) is the mesh to be digested
  35492. * @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
  35493. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35494. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35495. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35496. * @returns the current SPS
  35497. */
  35498. digest(mesh: Mesh, options?: {
  35499. facetNb?: number;
  35500. number?: number;
  35501. delta?: number;
  35502. storage?: [];
  35503. }): SolidParticleSystem;
  35504. /**
  35505. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35506. * @hidden
  35507. */
  35508. private _unrotateFixedNormals;
  35509. /**
  35510. * Resets the temporary working copy particle
  35511. * @hidden
  35512. */
  35513. private _resetCopy;
  35514. /**
  35515. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35516. * @param p the current index in the positions array to be updated
  35517. * @param ind the current index in the indices array
  35518. * @param shape a Vector3 array, the shape geometry
  35519. * @param positions the positions array to be updated
  35520. * @param meshInd the shape indices array
  35521. * @param indices the indices array to be updated
  35522. * @param meshUV the shape uv array
  35523. * @param uvs the uv array to be updated
  35524. * @param meshCol the shape color array
  35525. * @param colors the color array to be updated
  35526. * @param meshNor the shape normals array
  35527. * @param normals the normals array to be updated
  35528. * @param idx the particle index
  35529. * @param idxInShape the particle index in its shape
  35530. * @param options the addShape() method passed options
  35531. * @model the particle model
  35532. * @hidden
  35533. */
  35534. private _meshBuilder;
  35535. /**
  35536. * Returns a shape Vector3 array from positions float array
  35537. * @param positions float array
  35538. * @returns a vector3 array
  35539. * @hidden
  35540. */
  35541. private _posToShape;
  35542. /**
  35543. * Returns a shapeUV array from a float uvs (array deep copy)
  35544. * @param uvs as a float array
  35545. * @returns a shapeUV array
  35546. * @hidden
  35547. */
  35548. private _uvsToShapeUV;
  35549. /**
  35550. * Adds a new particle object in the particles array
  35551. * @param idx particle index in particles array
  35552. * @param id particle id
  35553. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35554. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35555. * @param model particle ModelShape object
  35556. * @param shapeId model shape identifier
  35557. * @param idxInShape index of the particle in the current model
  35558. * @param bInfo model bounding info object
  35559. * @param storage target storage array, if any
  35560. * @hidden
  35561. */
  35562. private _addParticle;
  35563. /**
  35564. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35565. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35566. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35567. * @param nb (positive integer) the number of particles to be created from this model
  35568. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35569. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35570. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35571. * @returns the number of shapes in the system
  35572. */
  35573. addShape(mesh: Mesh, nb: number, options?: {
  35574. positionFunction?: any;
  35575. vertexFunction?: any;
  35576. storage?: [];
  35577. }): number;
  35578. /**
  35579. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35580. * @hidden
  35581. */
  35582. private _rebuildParticle;
  35583. /**
  35584. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35585. * @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.
  35586. * @returns the SPS.
  35587. */
  35588. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35589. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35590. * Returns an array with the removed particles.
  35591. * 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.
  35592. * The SPS can't be empty so at least one particle needs to remain in place.
  35593. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35594. * @param start index of the first particle to remove
  35595. * @param end index of the last particle to remove (included)
  35596. * @returns an array populated with the removed particles
  35597. */
  35598. removeParticles(start: number, end: number): SolidParticle[];
  35599. /**
  35600. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35601. * @param solidParticleArray an array populated with Solid Particles objects
  35602. * @returns the SPS
  35603. */
  35604. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35605. /**
  35606. * Creates a new particle and modifies the SPS mesh geometry :
  35607. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35608. * - calls _addParticle() to populate the particle array
  35609. * factorized code from addShape() and insertParticlesFromArray()
  35610. * @param idx particle index in the particles array
  35611. * @param i particle index in its shape
  35612. * @param modelShape particle ModelShape object
  35613. * @param shape shape vertex array
  35614. * @param meshInd shape indices array
  35615. * @param meshUV shape uv array
  35616. * @param meshCol shape color array
  35617. * @param meshNor shape normals array
  35618. * @param bbInfo shape bounding info
  35619. * @param storage target particle storage
  35620. * @options addShape() passed options
  35621. * @hidden
  35622. */
  35623. private _insertNewParticle;
  35624. /**
  35625. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35626. * This method calls `updateParticle()` for each particle of the SPS.
  35627. * For an animated SPS, it is usually called within the render loop.
  35628. * 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.
  35629. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35630. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35631. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35632. * @returns the SPS.
  35633. */
  35634. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35635. /**
  35636. * Disposes the SPS.
  35637. */
  35638. dispose(): void;
  35639. /** Returns an object {idx: number faceId: number} for the picked particle from the passed pickingInfo object.
  35640. * idx is the particle index in the SPS
  35641. * faceId is the picked face index counted within this particle.
  35642. * Returns null if the pickInfo can't identify a picked particle.
  35643. * @param pickingInfo (PickingInfo object)
  35644. * @returns {idx: number, faceId: number} or null
  35645. */
  35646. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35647. idx: number;
  35648. faceId: number;
  35649. }>;
  35650. /**
  35651. * Returns a SolidParticle object from its identifier : particle.id
  35652. * @param id (integer) the particle Id
  35653. * @returns the searched particle or null if not found in the SPS.
  35654. */
  35655. getParticleById(id: number): Nullable<SolidParticle>;
  35656. /**
  35657. * Returns a new array populated with the particles having the passed shapeId.
  35658. * @param shapeId (integer) the shape identifier
  35659. * @returns a new solid particle array
  35660. */
  35661. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35662. /**
  35663. * Populates the passed array "ref" with the particles having the passed shapeId.
  35664. * @param shapeId the shape identifier
  35665. * @returns the SPS
  35666. * @param ref
  35667. */
  35668. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35669. /**
  35670. * Computes the required SubMeshes according the materials assigned to the particles.
  35671. * @returns the solid particle system.
  35672. * Does nothing if called before the SPS mesh is built.
  35673. */
  35674. computeSubMeshes(): SolidParticleSystem;
  35675. /**
  35676. * Sorts the solid particles by material when MultiMaterial is enabled.
  35677. * Updates the indices32 array.
  35678. * Updates the indicesByMaterial array.
  35679. * Updates the mesh indices array.
  35680. * @returns the SPS
  35681. * @hidden
  35682. */
  35683. private _sortParticlesByMaterial;
  35684. /**
  35685. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35686. * @hidden
  35687. */
  35688. private _setMaterialIndexesById;
  35689. /**
  35690. * Returns an array with unique values of Materials from the passed array
  35691. * @param array the material array to be checked and filtered
  35692. * @hidden
  35693. */
  35694. private _filterUniqueMaterialId;
  35695. /**
  35696. * Sets a new Standard Material as _defaultMaterial if not already set.
  35697. * @hidden
  35698. */
  35699. private _setDefaultMaterial;
  35700. /**
  35701. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  35702. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35703. * @returns the SPS.
  35704. */
  35705. refreshVisibleSize(): SolidParticleSystem;
  35706. /**
  35707. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35708. * @param size the size (float) of the visibility box
  35709. * note : this doesn't lock the SPS mesh bounding box.
  35710. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35711. */
  35712. setVisibilityBox(size: number): void;
  35713. /**
  35714. * Gets whether the SPS as always visible or not
  35715. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35716. */
  35717. get isAlwaysVisible(): boolean;
  35718. /**
  35719. * Sets the SPS as always visible or not
  35720. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35721. */
  35722. set isAlwaysVisible(val: boolean);
  35723. /**
  35724. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35725. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35726. */
  35727. set isVisibilityBoxLocked(val: boolean);
  35728. /**
  35729. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35730. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35731. */
  35732. get isVisibilityBoxLocked(): boolean;
  35733. /**
  35734. * Tells to `setParticles()` to compute the particle rotations or not.
  35735. * Default value : true. The SPS is faster when it's set to false.
  35736. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35737. */
  35738. set computeParticleRotation(val: boolean);
  35739. /**
  35740. * Tells to `setParticles()` to compute the particle colors or not.
  35741. * Default value : true. The SPS is faster when it's set to false.
  35742. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35743. */
  35744. set computeParticleColor(val: boolean);
  35745. set computeParticleTexture(val: boolean);
  35746. /**
  35747. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35748. * Default value : false. The SPS is faster when it's set to false.
  35749. * Note : the particle custom vertex positions aren't stored values.
  35750. */
  35751. set computeParticleVertex(val: boolean);
  35752. /**
  35753. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35754. */
  35755. set computeBoundingBox(val: boolean);
  35756. /**
  35757. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35758. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35759. * Default : `true`
  35760. */
  35761. set depthSortParticles(val: boolean);
  35762. /**
  35763. * Gets if `setParticles()` computes the particle rotations or not.
  35764. * Default value : true. The SPS is faster when it's set to false.
  35765. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35766. */
  35767. get computeParticleRotation(): boolean;
  35768. /**
  35769. * Gets if `setParticles()` computes the particle colors or not.
  35770. * Default value : true. The SPS is faster when it's set to false.
  35771. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35772. */
  35773. get computeParticleColor(): boolean;
  35774. /**
  35775. * Gets if `setParticles()` computes the particle textures or not.
  35776. * Default value : true. The SPS is faster when it's set to false.
  35777. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35778. */
  35779. get computeParticleTexture(): boolean;
  35780. /**
  35781. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35782. * Default value : false. The SPS is faster when it's set to false.
  35783. * Note : the particle custom vertex positions aren't stored values.
  35784. */
  35785. get computeParticleVertex(): boolean;
  35786. /**
  35787. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35788. */
  35789. get computeBoundingBox(): boolean;
  35790. /**
  35791. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35792. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35793. * Default : `true`
  35794. */
  35795. get depthSortParticles(): boolean;
  35796. /**
  35797. * Gets if the SPS is created as expandable at construction time.
  35798. * Default : `false`
  35799. */
  35800. get expandable(): boolean;
  35801. /**
  35802. * Gets if the SPS supports the Multi Materials
  35803. */
  35804. get multimaterialEnabled(): boolean;
  35805. /**
  35806. * Gets if the SPS uses the model materials for its own multimaterial.
  35807. */
  35808. get useModelMaterial(): boolean;
  35809. /**
  35810. * The SPS used material array.
  35811. */
  35812. get materials(): Material[];
  35813. /**
  35814. * Sets the SPS MultiMaterial from the passed materials.
  35815. * Note : the passed array is internally copied and not used then by reference.
  35816. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35817. */
  35818. setMultiMaterial(materials: Material[]): void;
  35819. /**
  35820. * The SPS computed multimaterial object
  35821. */
  35822. get multimaterial(): MultiMaterial;
  35823. set multimaterial(mm: MultiMaterial);
  35824. /**
  35825. * If the subMeshes must be updated on the next call to setParticles()
  35826. */
  35827. get autoUpdateSubMeshes(): boolean;
  35828. set autoUpdateSubMeshes(val: boolean);
  35829. /**
  35830. * This function does nothing. It may be overwritten to set all the particle first values.
  35831. * The SPS doesn't call this function, you may have to call it by your own.
  35832. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35833. */
  35834. initParticles(): void;
  35835. /**
  35836. * This function does nothing. It may be overwritten to recycle a particle.
  35837. * The SPS doesn't call this function, you may have to call it by your own.
  35838. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35839. * @param particle The particle to recycle
  35840. * @returns the recycled particle
  35841. */
  35842. recycleParticle(particle: SolidParticle): SolidParticle;
  35843. /**
  35844. * Updates a particle : this function should be overwritten by the user.
  35845. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35846. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35847. * @example : just set a particle position or velocity and recycle conditions
  35848. * @param particle The particle to update
  35849. * @returns the updated particle
  35850. */
  35851. updateParticle(particle: SolidParticle): SolidParticle;
  35852. /**
  35853. * Updates a vertex of a particle : it can be overwritten by the user.
  35854. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35855. * @param particle the current particle
  35856. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35857. * @param pt the index of the current vertex in the particle shape
  35858. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35859. * @example : just set a vertex particle position or color
  35860. * @returns the sps
  35861. */
  35862. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35863. /**
  35864. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35865. * This does nothing and may be overwritten by the user.
  35866. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35867. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35868. * @param update the boolean update value actually passed to setParticles()
  35869. */
  35870. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35871. /**
  35872. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35873. * This will be passed three parameters.
  35874. * This does nothing and may be overwritten by the user.
  35875. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35876. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35877. * @param update the boolean update value actually passed to setParticles()
  35878. */
  35879. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35880. }
  35881. }
  35882. declare module BABYLON {
  35883. /**
  35884. * Represents one particle of a solid particle system.
  35885. */
  35886. export class SolidParticle {
  35887. /**
  35888. * particle global index
  35889. */
  35890. idx: number;
  35891. /**
  35892. * particle identifier
  35893. */
  35894. id: number;
  35895. /**
  35896. * The color of the particle
  35897. */
  35898. color: Nullable<Color4>;
  35899. /**
  35900. * The world space position of the particle.
  35901. */
  35902. position: Vector3;
  35903. /**
  35904. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35905. */
  35906. rotation: Vector3;
  35907. /**
  35908. * The world space rotation quaternion of the particle.
  35909. */
  35910. rotationQuaternion: Nullable<Quaternion>;
  35911. /**
  35912. * The scaling of the particle.
  35913. */
  35914. scaling: Vector3;
  35915. /**
  35916. * The uvs of the particle.
  35917. */
  35918. uvs: Vector4;
  35919. /**
  35920. * The current speed of the particle.
  35921. */
  35922. velocity: Vector3;
  35923. /**
  35924. * The pivot point in the particle local space.
  35925. */
  35926. pivot: Vector3;
  35927. /**
  35928. * Must the particle be translated from its pivot point in its local space ?
  35929. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35930. * Default : false
  35931. */
  35932. translateFromPivot: boolean;
  35933. /**
  35934. * Is the particle active or not ?
  35935. */
  35936. alive: boolean;
  35937. /**
  35938. * Is the particle visible or not ?
  35939. */
  35940. isVisible: boolean;
  35941. /**
  35942. * Index of this particle in the global "positions" array (Internal use)
  35943. * @hidden
  35944. */
  35945. _pos: number;
  35946. /**
  35947. * @hidden Index of this particle in the global "indices" array (Internal use)
  35948. */
  35949. _ind: number;
  35950. /**
  35951. * @hidden ModelShape of this particle (Internal use)
  35952. */
  35953. _model: ModelShape;
  35954. /**
  35955. * ModelShape id of this particle
  35956. */
  35957. shapeId: number;
  35958. /**
  35959. * Index of the particle in its shape id
  35960. */
  35961. idxInShape: number;
  35962. /**
  35963. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35964. */
  35965. _modelBoundingInfo: BoundingInfo;
  35966. /**
  35967. * @hidden Particle BoundingInfo object (Internal use)
  35968. */
  35969. _boundingInfo: BoundingInfo;
  35970. /**
  35971. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35972. */
  35973. _sps: SolidParticleSystem;
  35974. /**
  35975. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35976. */
  35977. _stillInvisible: boolean;
  35978. /**
  35979. * @hidden Last computed particle rotation matrix
  35980. */
  35981. _rotationMatrix: number[];
  35982. /**
  35983. * Parent particle Id, if any.
  35984. * Default null.
  35985. */
  35986. parentId: Nullable<number>;
  35987. /**
  35988. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35989. */
  35990. materialIndex: Nullable<number>;
  35991. /**
  35992. * Custom object or properties.
  35993. */
  35994. props: Nullable<any>;
  35995. /**
  35996. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35997. * The possible values are :
  35998. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35999. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36000. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36001. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36002. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36003. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36004. * */
  36005. cullingStrategy: number;
  36006. /**
  36007. * @hidden Internal global position in the SPS.
  36008. */
  36009. _globalPosition: Vector3;
  36010. /**
  36011. * Creates a Solid Particle object.
  36012. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36013. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36014. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36015. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36016. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36017. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36018. * @param shapeId (integer) is the model shape identifier in the SPS.
  36019. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36020. * @param sps defines the sps it is associated to
  36021. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36022. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36023. */
  36024. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36025. /**
  36026. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36027. * @param target the particle target
  36028. * @returns the current particle
  36029. */
  36030. copyToRef(target: SolidParticle): SolidParticle;
  36031. /**
  36032. * Legacy support, changed scale to scaling
  36033. */
  36034. get scale(): Vector3;
  36035. /**
  36036. * Legacy support, changed scale to scaling
  36037. */
  36038. set scale(scale: Vector3);
  36039. /**
  36040. * Legacy support, changed quaternion to rotationQuaternion
  36041. */
  36042. get quaternion(): Nullable<Quaternion>;
  36043. /**
  36044. * Legacy support, changed quaternion to rotationQuaternion
  36045. */
  36046. set quaternion(q: Nullable<Quaternion>);
  36047. /**
  36048. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36049. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36050. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36051. * @returns true if it intersects
  36052. */
  36053. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36054. /**
  36055. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36056. * A particle is in the frustum if its bounding box intersects the frustum
  36057. * @param frustumPlanes defines the frustum to test
  36058. * @returns true if the particle is in the frustum planes
  36059. */
  36060. isInFrustum(frustumPlanes: Plane[]): boolean;
  36061. /**
  36062. * get the rotation matrix of the particle
  36063. * @hidden
  36064. */
  36065. getRotationMatrix(m: Matrix): void;
  36066. }
  36067. /**
  36068. * Represents the shape of the model used by one particle of a solid particle system.
  36069. * SPS internal tool, don't use it manually.
  36070. */
  36071. export class ModelShape {
  36072. /**
  36073. * The shape id
  36074. * @hidden
  36075. */
  36076. shapeID: number;
  36077. /**
  36078. * flat array of model positions (internal use)
  36079. * @hidden
  36080. */
  36081. _shape: Vector3[];
  36082. /**
  36083. * flat array of model UVs (internal use)
  36084. * @hidden
  36085. */
  36086. _shapeUV: number[];
  36087. /**
  36088. * color array of the model
  36089. * @hidden
  36090. */
  36091. _shapeColors: number[];
  36092. /**
  36093. * indices array of the model
  36094. * @hidden
  36095. */
  36096. _indices: number[];
  36097. /**
  36098. * normals array of the model
  36099. * @hidden
  36100. */
  36101. _normals: number[];
  36102. /**
  36103. * length of the shape in the model indices array (internal use)
  36104. * @hidden
  36105. */
  36106. _indicesLength: number;
  36107. /**
  36108. * Custom position function (internal use)
  36109. * @hidden
  36110. */
  36111. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36112. /**
  36113. * Custom vertex function (internal use)
  36114. * @hidden
  36115. */
  36116. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36117. /**
  36118. * Model material (internal use)
  36119. * @hidden
  36120. */
  36121. _material: Nullable<Material>;
  36122. /**
  36123. * 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.
  36124. * SPS internal tool, don't use it manually.
  36125. * @hidden
  36126. */
  36127. 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>);
  36128. }
  36129. /**
  36130. * Represents a Depth Sorted Particle in the solid particle system.
  36131. * @hidden
  36132. */
  36133. export class DepthSortedParticle {
  36134. /**
  36135. * Particle index
  36136. */
  36137. idx: number;
  36138. /**
  36139. * Index of the particle in the "indices" array
  36140. */
  36141. ind: number;
  36142. /**
  36143. * Length of the particle shape in the "indices" array
  36144. */
  36145. indicesLength: number;
  36146. /**
  36147. * Squared distance from the particle to the camera
  36148. */
  36149. sqDistance: number;
  36150. /**
  36151. * Material index when used with MultiMaterials
  36152. */
  36153. materialIndex: number;
  36154. /**
  36155. * Creates a new sorted particle
  36156. * @param materialIndex
  36157. */
  36158. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36159. }
  36160. /**
  36161. * Represents a solid particle vertex
  36162. */
  36163. export class SolidParticleVertex {
  36164. /**
  36165. * Vertex position
  36166. */
  36167. position: Vector3;
  36168. /**
  36169. * Vertex color
  36170. */
  36171. color: Color4;
  36172. /**
  36173. * Vertex UV
  36174. */
  36175. uv: Vector2;
  36176. /**
  36177. * Creates a new solid particle vertex
  36178. */
  36179. constructor();
  36180. /** Vertex x coordinate */
  36181. get x(): number;
  36182. set x(val: number);
  36183. /** Vertex y coordinate */
  36184. get y(): number;
  36185. set y(val: number);
  36186. /** Vertex z coordinate */
  36187. get z(): number;
  36188. set z(val: number);
  36189. }
  36190. }
  36191. declare module BABYLON {
  36192. /**
  36193. * @hidden
  36194. */
  36195. export class _MeshCollisionData {
  36196. _checkCollisions: boolean;
  36197. _collisionMask: number;
  36198. _collisionGroup: number;
  36199. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36200. _collider: Nullable<Collider>;
  36201. _oldPositionForCollisions: Vector3;
  36202. _diffPositionForCollisions: Vector3;
  36203. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36204. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36205. _collisionResponse: boolean;
  36206. }
  36207. }
  36208. declare module BABYLON {
  36209. /** @hidden */
  36210. class _FacetDataStorage {
  36211. facetPositions: Vector3[];
  36212. facetNormals: Vector3[];
  36213. facetPartitioning: number[][];
  36214. facetNb: number;
  36215. partitioningSubdivisions: number;
  36216. partitioningBBoxRatio: number;
  36217. facetDataEnabled: boolean;
  36218. facetParameters: any;
  36219. bbSize: Vector3;
  36220. subDiv: {
  36221. max: number;
  36222. X: number;
  36223. Y: number;
  36224. Z: number;
  36225. };
  36226. facetDepthSort: boolean;
  36227. facetDepthSortEnabled: boolean;
  36228. depthSortedIndices: IndicesArray;
  36229. depthSortedFacets: {
  36230. ind: number;
  36231. sqDistance: number;
  36232. }[];
  36233. facetDepthSortFunction: (f1: {
  36234. ind: number;
  36235. sqDistance: number;
  36236. }, f2: {
  36237. ind: number;
  36238. sqDistance: number;
  36239. }) => number;
  36240. facetDepthSortFrom: Vector3;
  36241. facetDepthSortOrigin: Vector3;
  36242. invertedMatrix: Matrix;
  36243. }
  36244. /**
  36245. * @hidden
  36246. **/
  36247. class _InternalAbstractMeshDataInfo {
  36248. _hasVertexAlpha: boolean;
  36249. _useVertexColors: boolean;
  36250. _numBoneInfluencers: number;
  36251. _applyFog: boolean;
  36252. _receiveShadows: boolean;
  36253. _facetData: _FacetDataStorage;
  36254. _visibility: number;
  36255. _skeleton: Nullable<Skeleton>;
  36256. _layerMask: number;
  36257. _computeBonesUsingShaders: boolean;
  36258. _isActive: boolean;
  36259. _onlyForInstances: boolean;
  36260. _isActiveIntermediate: boolean;
  36261. _onlyForInstancesIntermediate: boolean;
  36262. _actAsRegularMesh: boolean;
  36263. _currentLOD: Nullable<AbstractMesh>;
  36264. _currentLODIsUpToDate: boolean;
  36265. }
  36266. /**
  36267. * Class used to store all common mesh properties
  36268. */
  36269. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36270. /** No occlusion */
  36271. static OCCLUSION_TYPE_NONE: number;
  36272. /** Occlusion set to optimistic */
  36273. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36274. /** Occlusion set to strict */
  36275. static OCCLUSION_TYPE_STRICT: number;
  36276. /** Use an accurate occlusion algorithm */
  36277. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36278. /** Use a conservative occlusion algorithm */
  36279. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36280. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36281. * Test order :
  36282. * Is the bounding sphere outside the frustum ?
  36283. * If not, are the bounding box vertices outside the frustum ?
  36284. * It not, then the cullable object is in the frustum.
  36285. */
  36286. static readonly CULLINGSTRATEGY_STANDARD: number;
  36287. /** Culling strategy : Bounding Sphere Only.
  36288. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36289. * It's also less accurate than the standard because some not visible objects can still be selected.
  36290. * Test : is the bounding sphere outside the frustum ?
  36291. * If not, then the cullable object is in the frustum.
  36292. */
  36293. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36294. /** Culling strategy : Optimistic Inclusion.
  36295. * This in an inclusion test first, then the standard exclusion test.
  36296. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36297. * 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.
  36298. * Anyway, it's as accurate as the standard strategy.
  36299. * Test :
  36300. * Is the cullable object bounding sphere center in the frustum ?
  36301. * If not, apply the default culling strategy.
  36302. */
  36303. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36304. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36305. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36306. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36307. * 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.
  36308. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36309. * Test :
  36310. * Is the cullable object bounding sphere center in the frustum ?
  36311. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36312. */
  36313. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36314. /**
  36315. * No billboard
  36316. */
  36317. static get BILLBOARDMODE_NONE(): number;
  36318. /** Billboard on X axis */
  36319. static get BILLBOARDMODE_X(): number;
  36320. /** Billboard on Y axis */
  36321. static get BILLBOARDMODE_Y(): number;
  36322. /** Billboard on Z axis */
  36323. static get BILLBOARDMODE_Z(): number;
  36324. /** Billboard on all axes */
  36325. static get BILLBOARDMODE_ALL(): number;
  36326. /** Billboard on using position instead of orientation */
  36327. static get BILLBOARDMODE_USE_POSITION(): number;
  36328. /** @hidden */
  36329. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36330. /**
  36331. * The culling strategy to use to check whether the mesh must be rendered or not.
  36332. * This value can be changed at any time and will be used on the next render mesh selection.
  36333. * The possible values are :
  36334. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36335. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36336. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36337. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36338. * Please read each static variable documentation to get details about the culling process.
  36339. * */
  36340. cullingStrategy: number;
  36341. /**
  36342. * Gets the number of facets in the mesh
  36343. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36344. */
  36345. get facetNb(): number;
  36346. /**
  36347. * Gets or set the number (integer) of subdivisions per axis in the partitioning space
  36348. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36349. */
  36350. get partitioningSubdivisions(): number;
  36351. set partitioningSubdivisions(nb: number);
  36352. /**
  36353. * The ratio (float) to apply to the bounding box size to set to the partitioning space.
  36354. * Ex : 1.01 (default) the partitioning space is 1% bigger than the bounding box
  36355. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36356. */
  36357. get partitioningBBoxRatio(): number;
  36358. set partitioningBBoxRatio(ratio: number);
  36359. /**
  36360. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36361. * Works only for updatable meshes.
  36362. * Doesn't work with multi-materials
  36363. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36364. */
  36365. get mustDepthSortFacets(): boolean;
  36366. set mustDepthSortFacets(sort: boolean);
  36367. /**
  36368. * The location (Vector3) where the facet depth sort must be computed from.
  36369. * By default, the active camera position.
  36370. * Used only when facet depth sort is enabled
  36371. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36372. */
  36373. get facetDepthSortFrom(): Vector3;
  36374. set facetDepthSortFrom(location: Vector3);
  36375. /**
  36376. * gets a boolean indicating if facetData is enabled
  36377. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36378. */
  36379. get isFacetDataEnabled(): boolean;
  36380. /** @hidden */
  36381. _updateNonUniformScalingState(value: boolean): boolean;
  36382. /**
  36383. * An event triggered when this mesh collides with another one
  36384. */
  36385. onCollideObservable: Observable<AbstractMesh>;
  36386. /** Set a function to call when this mesh collides with another one */
  36387. set onCollide(callback: () => void);
  36388. /**
  36389. * An event triggered when the collision's position changes
  36390. */
  36391. onCollisionPositionChangeObservable: Observable<Vector3>;
  36392. /** Set a function to call when the collision's position changes */
  36393. set onCollisionPositionChange(callback: () => void);
  36394. /**
  36395. * An event triggered when material is changed
  36396. */
  36397. onMaterialChangedObservable: Observable<AbstractMesh>;
  36398. /**
  36399. * Gets or sets the orientation for POV movement & rotation
  36400. */
  36401. definedFacingForward: boolean;
  36402. /** @hidden */
  36403. _occlusionQuery: Nullable<WebGLQuery>;
  36404. /** @hidden */
  36405. _renderingGroup: Nullable<RenderingGroup>;
  36406. /**
  36407. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36408. */
  36409. get visibility(): number;
  36410. /**
  36411. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36412. */
  36413. set visibility(value: number);
  36414. /** Gets or sets the alpha index used to sort transparent meshes
  36415. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36416. */
  36417. alphaIndex: number;
  36418. /**
  36419. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36420. */
  36421. isVisible: boolean;
  36422. /**
  36423. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36424. */
  36425. isPickable: boolean;
  36426. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36427. showSubMeshesBoundingBox: boolean;
  36428. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36429. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36430. */
  36431. isBlocker: boolean;
  36432. /**
  36433. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36434. */
  36435. enablePointerMoveEvents: boolean;
  36436. private _renderingGroupId;
  36437. /**
  36438. * Specifies the rendering group id for this mesh (0 by default)
  36439. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36440. */
  36441. get renderingGroupId(): number;
  36442. set renderingGroupId(value: number);
  36443. private _material;
  36444. /** Gets or sets current material */
  36445. get material(): Nullable<Material>;
  36446. set material(value: Nullable<Material>);
  36447. /**
  36448. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36449. * @see https://doc.babylonjs.com/babylon101/shadows
  36450. */
  36451. get receiveShadows(): boolean;
  36452. set receiveShadows(value: boolean);
  36453. /** Defines color to use when rendering outline */
  36454. outlineColor: Color3;
  36455. /** Define width to use when rendering outline */
  36456. outlineWidth: number;
  36457. /** Defines color to use when rendering overlay */
  36458. overlayColor: Color3;
  36459. /** Defines alpha to use when rendering overlay */
  36460. overlayAlpha: number;
  36461. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36462. get hasVertexAlpha(): boolean;
  36463. set hasVertexAlpha(value: boolean);
  36464. /** 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) */
  36465. get useVertexColors(): boolean;
  36466. set useVertexColors(value: boolean);
  36467. /**
  36468. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36469. */
  36470. get computeBonesUsingShaders(): boolean;
  36471. set computeBonesUsingShaders(value: boolean);
  36472. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36473. get numBoneInfluencers(): number;
  36474. set numBoneInfluencers(value: number);
  36475. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36476. get applyFog(): boolean;
  36477. set applyFog(value: boolean);
  36478. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36479. useOctreeForRenderingSelection: boolean;
  36480. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36481. useOctreeForPicking: boolean;
  36482. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36483. useOctreeForCollisions: boolean;
  36484. /**
  36485. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36486. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36487. */
  36488. get layerMask(): number;
  36489. set layerMask(value: number);
  36490. /**
  36491. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36492. */
  36493. alwaysSelectAsActiveMesh: boolean;
  36494. /**
  36495. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36496. */
  36497. doNotSyncBoundingInfo: boolean;
  36498. /**
  36499. * Gets or sets the current action manager
  36500. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36501. */
  36502. actionManager: Nullable<AbstractActionManager>;
  36503. private _meshCollisionData;
  36504. /**
  36505. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36506. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36507. */
  36508. ellipsoid: Vector3;
  36509. /**
  36510. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36511. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36512. */
  36513. ellipsoidOffset: Vector3;
  36514. /**
  36515. * Gets or sets a collision mask used to mask collisions (default is -1).
  36516. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36517. */
  36518. get collisionMask(): number;
  36519. set collisionMask(mask: number);
  36520. /**
  36521. * Gets or sets a collision response flag (default is true).
  36522. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36523. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36524. * to respond to the collision.
  36525. */
  36526. get collisionResponse(): boolean;
  36527. set collisionResponse(response: boolean);
  36528. /**
  36529. * Gets or sets the current collision group mask (-1 by default).
  36530. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36531. */
  36532. get collisionGroup(): number;
  36533. set collisionGroup(mask: number);
  36534. /**
  36535. * Gets or sets current surrounding meshes (null by default).
  36536. *
  36537. * By default collision detection is tested against every mesh in the scene.
  36538. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36539. * meshes will be tested for the collision.
  36540. *
  36541. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36542. */
  36543. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36544. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36545. /**
  36546. * Defines edge width used when edgesRenderer is enabled
  36547. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36548. */
  36549. edgesWidth: number;
  36550. /**
  36551. * Defines edge color used when edgesRenderer is enabled
  36552. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36553. */
  36554. edgesColor: Color4;
  36555. /** @hidden */
  36556. _edgesRenderer: Nullable<IEdgesRenderer>;
  36557. /** @hidden */
  36558. _masterMesh: Nullable<AbstractMesh>;
  36559. /** @hidden */
  36560. _boundingInfo: Nullable<BoundingInfo>;
  36561. /** @hidden */
  36562. _renderId: number;
  36563. /**
  36564. * Gets or sets the list of subMeshes
  36565. * @see https://doc.babylonjs.com/how_to/multi_materials
  36566. */
  36567. subMeshes: SubMesh[];
  36568. /** @hidden */
  36569. _intersectionsInProgress: AbstractMesh[];
  36570. /** @hidden */
  36571. _unIndexed: boolean;
  36572. /** @hidden */
  36573. _lightSources: Light[];
  36574. /** Gets the list of lights affecting that mesh */
  36575. get lightSources(): Light[];
  36576. /** @hidden */
  36577. get _positions(): Nullable<Vector3[]>;
  36578. /** @hidden */
  36579. _waitingData: {
  36580. lods: Nullable<any>;
  36581. actions: Nullable<any>;
  36582. freezeWorldMatrix: Nullable<boolean>;
  36583. };
  36584. /** @hidden */
  36585. _bonesTransformMatrices: Nullable<Float32Array>;
  36586. /** @hidden */
  36587. _transformMatrixTexture: Nullable<RawTexture>;
  36588. /**
  36589. * Gets or sets a skeleton to apply skinning transformations
  36590. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36591. */
  36592. set skeleton(value: Nullable<Skeleton>);
  36593. get skeleton(): Nullable<Skeleton>;
  36594. /**
  36595. * An event triggered when the mesh is rebuilt.
  36596. */
  36597. onRebuildObservable: Observable<AbstractMesh>;
  36598. /**
  36599. * The current mesh uniform buffer.
  36600. * @hidden Internal use only.
  36601. */
  36602. _uniformBuffer: UniformBuffer;
  36603. /**
  36604. * Creates a new AbstractMesh
  36605. * @param name defines the name of the mesh
  36606. * @param scene defines the hosting scene
  36607. */
  36608. constructor(name: string, scene?: Nullable<Scene>);
  36609. protected _buildUniformLayout(): void;
  36610. /**
  36611. * Transfer the mesh values to its UBO.
  36612. * @param world The world matrix associated with the mesh
  36613. */
  36614. transferToEffect(world: Matrix): void;
  36615. /**
  36616. * Gets the mesh uniform buffer.
  36617. * @return the uniform buffer of the mesh.
  36618. */
  36619. getMeshUniformBuffer(): UniformBuffer;
  36620. /**
  36621. * Returns the string "AbstractMesh"
  36622. * @returns "AbstractMesh"
  36623. */
  36624. getClassName(): string;
  36625. /**
  36626. * Gets a string representation of the current mesh
  36627. * @param fullDetails defines a boolean indicating if full details must be included
  36628. * @returns a string representation of the current mesh
  36629. */
  36630. toString(fullDetails?: boolean): string;
  36631. /**
  36632. * @hidden
  36633. */
  36634. protected _getEffectiveParent(): Nullable<Node>;
  36635. /** @hidden */
  36636. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36637. /** @hidden */
  36638. _rebuild(): void;
  36639. /** @hidden */
  36640. _resyncLightSources(): void;
  36641. /** @hidden */
  36642. _resyncLightSource(light: Light): void;
  36643. /** @hidden */
  36644. _unBindEffect(): void;
  36645. /** @hidden */
  36646. _removeLightSource(light: Light, dispose: boolean): void;
  36647. private _markSubMeshesAsDirty;
  36648. /** @hidden */
  36649. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36650. /** @hidden */
  36651. _markSubMeshesAsAttributesDirty(): void;
  36652. /** @hidden */
  36653. _markSubMeshesAsMiscDirty(): void;
  36654. /**
  36655. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36656. */
  36657. get scaling(): Vector3;
  36658. set scaling(newScaling: Vector3);
  36659. /**
  36660. * Returns true if the mesh is blocked. Implemented by child classes
  36661. */
  36662. get isBlocked(): boolean;
  36663. /**
  36664. * Returns the mesh itself by default. Implemented by child classes
  36665. * @param camera defines the camera to use to pick the right LOD level
  36666. * @returns the currentAbstractMesh
  36667. */
  36668. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36669. /**
  36670. * Returns 0 by default. Implemented by child classes
  36671. * @returns an integer
  36672. */
  36673. getTotalVertices(): number;
  36674. /**
  36675. * Returns a positive integer : the total number of indices in this mesh geometry.
  36676. * @returns the number of indices or zero if the mesh has no geometry.
  36677. */
  36678. getTotalIndices(): number;
  36679. /**
  36680. * Returns null by default. Implemented by child classes
  36681. * @returns null
  36682. */
  36683. getIndices(): Nullable<IndicesArray>;
  36684. /**
  36685. * Returns the array of the requested vertex data kind. Implemented by child classes
  36686. * @param kind defines the vertex data kind to use
  36687. * @returns null
  36688. */
  36689. getVerticesData(kind: string): Nullable<FloatArray>;
  36690. /**
  36691. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36692. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36693. * Note that a new underlying VertexBuffer object is created each call.
  36694. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36695. * @param kind defines vertex data kind:
  36696. * * VertexBuffer.PositionKind
  36697. * * VertexBuffer.UVKind
  36698. * * VertexBuffer.UV2Kind
  36699. * * VertexBuffer.UV3Kind
  36700. * * VertexBuffer.UV4Kind
  36701. * * VertexBuffer.UV5Kind
  36702. * * VertexBuffer.UV6Kind
  36703. * * VertexBuffer.ColorKind
  36704. * * VertexBuffer.MatricesIndicesKind
  36705. * * VertexBuffer.MatricesIndicesExtraKind
  36706. * * VertexBuffer.MatricesWeightsKind
  36707. * * VertexBuffer.MatricesWeightsExtraKind
  36708. * @param data defines the data source
  36709. * @param updatable defines if the data must be flagged as updatable (or static)
  36710. * @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
  36711. * @returns the current mesh
  36712. */
  36713. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36714. /**
  36715. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36716. * If the mesh has no geometry, it is simply returned as it is.
  36717. * @param kind defines vertex data kind:
  36718. * * VertexBuffer.PositionKind
  36719. * * VertexBuffer.UVKind
  36720. * * VertexBuffer.UV2Kind
  36721. * * VertexBuffer.UV3Kind
  36722. * * VertexBuffer.UV4Kind
  36723. * * VertexBuffer.UV5Kind
  36724. * * VertexBuffer.UV6Kind
  36725. * * VertexBuffer.ColorKind
  36726. * * VertexBuffer.MatricesIndicesKind
  36727. * * VertexBuffer.MatricesIndicesExtraKind
  36728. * * VertexBuffer.MatricesWeightsKind
  36729. * * VertexBuffer.MatricesWeightsExtraKind
  36730. * @param data defines the data source
  36731. * @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
  36732. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36733. * @returns the current mesh
  36734. */
  36735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36736. /**
  36737. * Sets the mesh indices,
  36738. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36739. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36740. * @param totalVertices Defines the total number of vertices
  36741. * @returns the current mesh
  36742. */
  36743. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36744. /**
  36745. * Gets a boolean indicating if specific vertex data is present
  36746. * @param kind defines the vertex data kind to use
  36747. * @returns true is data kind is present
  36748. */
  36749. isVerticesDataPresent(kind: string): boolean;
  36750. /**
  36751. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36752. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36753. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36754. * @returns a BoundingInfo
  36755. */
  36756. getBoundingInfo(): BoundingInfo;
  36757. /**
  36758. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36759. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36760. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36761. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36762. * @returns the current mesh
  36763. */
  36764. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36765. /**
  36766. * Overwrite the current bounding info
  36767. * @param boundingInfo defines the new bounding info
  36768. * @returns the current mesh
  36769. */
  36770. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36771. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36772. get useBones(): boolean;
  36773. /** @hidden */
  36774. _preActivate(): void;
  36775. /** @hidden */
  36776. _preActivateForIntermediateRendering(renderId: number): void;
  36777. /** @hidden */
  36778. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36779. /** @hidden */
  36780. _postActivate(): void;
  36781. /** @hidden */
  36782. _freeze(): void;
  36783. /** @hidden */
  36784. _unFreeze(): void;
  36785. /**
  36786. * Gets the current world matrix
  36787. * @returns a Matrix
  36788. */
  36789. getWorldMatrix(): Matrix;
  36790. /** @hidden */
  36791. _getWorldMatrixDeterminant(): number;
  36792. /**
  36793. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36794. */
  36795. get isAnInstance(): boolean;
  36796. /**
  36797. * Gets a boolean indicating if this mesh has instances
  36798. */
  36799. get hasInstances(): boolean;
  36800. /**
  36801. * Gets a boolean indicating if this mesh has thin instances
  36802. */
  36803. get hasThinInstances(): boolean;
  36804. /**
  36805. * Perform relative position change from the point of view of behind the front of the mesh.
  36806. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36807. * Supports definition of mesh facing forward or backward
  36808. * @param amountRight defines the distance on the right axis
  36809. * @param amountUp defines the distance on the up axis
  36810. * @param amountForward defines the distance on the forward axis
  36811. * @returns the current mesh
  36812. */
  36813. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36814. /**
  36815. * Calculate relative position change from the point of view of behind the front of the mesh.
  36816. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36817. * Supports definition of mesh facing forward or backward
  36818. * @param amountRight defines the distance on the right axis
  36819. * @param amountUp defines the distance on the up axis
  36820. * @param amountForward defines the distance on the forward axis
  36821. * @returns the new displacement vector
  36822. */
  36823. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36824. /**
  36825. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36826. * Supports definition of mesh facing forward or backward
  36827. * @param flipBack defines the flip
  36828. * @param twirlClockwise defines the twirl
  36829. * @param tiltRight defines the tilt
  36830. * @returns the current mesh
  36831. */
  36832. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36833. /**
  36834. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36835. * Supports definition of mesh facing forward or backward.
  36836. * @param flipBack defines the flip
  36837. * @param twirlClockwise defines the twirl
  36838. * @param tiltRight defines the tilt
  36839. * @returns the new rotation vector
  36840. */
  36841. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36842. /**
  36843. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36844. * This means the mesh underlying bounding box and sphere are recomputed.
  36845. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36846. * @returns the current mesh
  36847. */
  36848. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36849. /** @hidden */
  36850. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36851. /** @hidden */
  36852. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36853. /** @hidden */
  36854. _updateBoundingInfo(): AbstractMesh;
  36855. /** @hidden */
  36856. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36857. /** @hidden */
  36858. protected _afterComputeWorldMatrix(): void;
  36859. /** @hidden */
  36860. get _effectiveMesh(): AbstractMesh;
  36861. /**
  36862. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36863. * A mesh is in the frustum if its bounding box intersects the frustum
  36864. * @param frustumPlanes defines the frustum to test
  36865. * @returns true if the mesh is in the frustum planes
  36866. */
  36867. isInFrustum(frustumPlanes: Plane[]): boolean;
  36868. /**
  36869. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36870. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36871. * @param frustumPlanes defines the frustum to test
  36872. * @returns true if the mesh is completely in the frustum planes
  36873. */
  36874. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36875. /**
  36876. * True if the mesh intersects another mesh or a SolidParticle object
  36877. * @param mesh defines a target mesh or SolidParticle to test
  36878. * @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)
  36879. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36880. * @returns true if there is an intersection
  36881. */
  36882. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36883. /**
  36884. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36885. * @param point defines the point to test
  36886. * @returns true if there is an intersection
  36887. */
  36888. intersectsPoint(point: Vector3): boolean;
  36889. /**
  36890. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36891. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36892. */
  36893. get checkCollisions(): boolean;
  36894. set checkCollisions(collisionEnabled: boolean);
  36895. /**
  36896. * Gets Collider object used to compute collisions (not physics)
  36897. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36898. */
  36899. get collider(): Nullable<Collider>;
  36900. /**
  36901. * Move the mesh using collision engine
  36902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36903. * @param displacement defines the requested displacement vector
  36904. * @returns the current mesh
  36905. */
  36906. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36907. private _onCollisionPositionChange;
  36908. /** @hidden */
  36909. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36910. /** @hidden */
  36911. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36912. /** @hidden */
  36913. _checkCollision(collider: Collider): AbstractMesh;
  36914. /** @hidden */
  36915. _generatePointsArray(): boolean;
  36916. /**
  36917. * Checks if the passed Ray intersects with the mesh
  36918. * @param ray defines the ray to use
  36919. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36921. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36922. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36923. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36924. * @returns the picking info
  36925. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36926. */
  36927. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36928. /**
  36929. * Clones the current mesh
  36930. * @param name defines the mesh name
  36931. * @param newParent defines the new mesh parent
  36932. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36933. * @returns the new mesh
  36934. */
  36935. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36936. /**
  36937. * Disposes all the submeshes of the current meshnp
  36938. * @returns the current mesh
  36939. */
  36940. releaseSubMeshes(): AbstractMesh;
  36941. /**
  36942. * Releases resources associated with this abstract mesh.
  36943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36945. */
  36946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36947. /**
  36948. * Adds the passed mesh as a child to the current mesh
  36949. * @param mesh defines the child mesh
  36950. * @returns the current mesh
  36951. */
  36952. addChild(mesh: AbstractMesh): AbstractMesh;
  36953. /**
  36954. * Removes the passed mesh from the current mesh children list
  36955. * @param mesh defines the child mesh
  36956. * @returns the current mesh
  36957. */
  36958. removeChild(mesh: AbstractMesh): AbstractMesh;
  36959. /** @hidden */
  36960. private _initFacetData;
  36961. /**
  36962. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36963. * This method can be called within the render loop.
  36964. * 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
  36965. * @returns the current mesh
  36966. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36967. */
  36968. updateFacetData(): AbstractMesh;
  36969. /**
  36970. * Returns the facetLocalNormals array.
  36971. * The normals are expressed in the mesh local spac
  36972. * @returns an array of Vector3
  36973. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36974. */
  36975. getFacetLocalNormals(): Vector3[];
  36976. /**
  36977. * Returns the facetLocalPositions array.
  36978. * The facet positions are expressed in the mesh local space
  36979. * @returns an array of Vector3
  36980. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36981. */
  36982. getFacetLocalPositions(): Vector3[];
  36983. /**
  36984. * Returns the facetLocalPartitioning array
  36985. * @returns an array of array of numbers
  36986. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36987. */
  36988. getFacetLocalPartitioning(): number[][];
  36989. /**
  36990. * Returns the i-th facet position in the world system.
  36991. * This method allocates a new Vector3 per call
  36992. * @param i defines the facet index
  36993. * @returns a new Vector3
  36994. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36995. */
  36996. getFacetPosition(i: number): Vector3;
  36997. /**
  36998. * Sets the reference Vector3 with the i-th facet position in the world system
  36999. * @param i defines the facet index
  37000. * @param ref defines the target vector
  37001. * @returns the current mesh
  37002. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37003. */
  37004. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37005. /**
  37006. * Returns the i-th facet normal in the world system.
  37007. * This method allocates a new Vector3 per call
  37008. * @param i defines the facet index
  37009. * @returns a new Vector3
  37010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37011. */
  37012. getFacetNormal(i: number): Vector3;
  37013. /**
  37014. * Sets the reference Vector3 with the i-th facet normal in the world system
  37015. * @param i defines the facet index
  37016. * @param ref defines the target vector
  37017. * @returns the current mesh
  37018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37019. */
  37020. getFacetNormalToRef(i: number, ref: Vector3): this;
  37021. /**
  37022. * 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)
  37023. * @param x defines x coordinate
  37024. * @param y defines y coordinate
  37025. * @param z defines z coordinate
  37026. * @returns the array of facet indexes
  37027. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37028. */
  37029. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37030. /**
  37031. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37032. * @param projected sets as the (x,y,z) world projection on the facet
  37033. * @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
  37034. * @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
  37035. * @param x defines x coordinate
  37036. * @param y defines y coordinate
  37037. * @param z defines z coordinate
  37038. * @returns the face index if found (or null instead)
  37039. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37040. */
  37041. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37042. /**
  37043. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37044. * @param projected sets as the (x,y,z) local projection on the facet
  37045. * @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
  37046. * @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
  37047. * @param x defines x coordinate
  37048. * @param y defines y coordinate
  37049. * @param z defines z coordinate
  37050. * @returns the face index if found (or null instead)
  37051. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37052. */
  37053. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37054. /**
  37055. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37056. * @returns the parameters
  37057. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37058. */
  37059. getFacetDataParameters(): any;
  37060. /**
  37061. * Disables the feature FacetData and frees the related memory
  37062. * @returns the current mesh
  37063. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37064. */
  37065. disableFacetData(): AbstractMesh;
  37066. /**
  37067. * Updates the AbstractMesh indices array
  37068. * @param indices defines the data source
  37069. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37070. * @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)
  37071. * @returns the current mesh
  37072. */
  37073. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37074. /**
  37075. * Creates new normals data for the mesh
  37076. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37077. * @returns the current mesh
  37078. */
  37079. createNormals(updatable: boolean): AbstractMesh;
  37080. /**
  37081. * Align the mesh with a normal
  37082. * @param normal defines the normal to use
  37083. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37084. * @returns the current mesh
  37085. */
  37086. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37087. /** @hidden */
  37088. _checkOcclusionQuery(): boolean;
  37089. /**
  37090. * Disables the mesh edge rendering mode
  37091. * @returns the currentAbstractMesh
  37092. */
  37093. disableEdgesRendering(): AbstractMesh;
  37094. /**
  37095. * Enables the edge rendering mode on the mesh.
  37096. * This mode makes the mesh edges visible
  37097. * @param epsilon defines the maximal distance between two angles to detect a face
  37098. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37099. * @param options options to the edge renderer
  37100. * @returns the currentAbstractMesh
  37101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37102. */
  37103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37104. /**
  37105. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37106. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37107. */
  37108. getConnectedParticleSystems(): IParticleSystem[];
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Interface used to define ActionEvent
  37114. */
  37115. export interface IActionEvent {
  37116. /** The mesh or sprite that triggered the action */
  37117. source: any;
  37118. /** The X mouse cursor position at the time of the event */
  37119. pointerX: number;
  37120. /** The Y mouse cursor position at the time of the event */
  37121. pointerY: number;
  37122. /** The mesh that is currently pointed at (can be null) */
  37123. meshUnderPointer: Nullable<AbstractMesh>;
  37124. /** the original (browser) event that triggered the ActionEvent */
  37125. sourceEvent?: any;
  37126. /** additional data for the event */
  37127. additionalData?: any;
  37128. }
  37129. /**
  37130. * ActionEvent is the event being sent when an action is triggered.
  37131. */
  37132. export class ActionEvent implements IActionEvent {
  37133. /** The mesh or sprite that triggered the action */
  37134. source: any;
  37135. /** The X mouse cursor position at the time of the event */
  37136. pointerX: number;
  37137. /** The Y mouse cursor position at the time of the event */
  37138. pointerY: number;
  37139. /** The mesh that is currently pointed at (can be null) */
  37140. meshUnderPointer: Nullable<AbstractMesh>;
  37141. /** the original (browser) event that triggered the ActionEvent */
  37142. sourceEvent?: any;
  37143. /** additional data for the event */
  37144. additionalData?: any;
  37145. /**
  37146. * Creates a new ActionEvent
  37147. * @param source The mesh or sprite that triggered the action
  37148. * @param pointerX The X mouse cursor position at the time of the event
  37149. * @param pointerY The Y mouse cursor position at the time of the event
  37150. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37151. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37152. * @param additionalData additional data for the event
  37153. */
  37154. constructor(
  37155. /** The mesh or sprite that triggered the action */
  37156. source: any,
  37157. /** The X mouse cursor position at the time of the event */
  37158. pointerX: number,
  37159. /** The Y mouse cursor position at the time of the event */
  37160. pointerY: number,
  37161. /** The mesh that is currently pointed at (can be null) */
  37162. meshUnderPointer: Nullable<AbstractMesh>,
  37163. /** the original (browser) event that triggered the ActionEvent */
  37164. sourceEvent?: any,
  37165. /** additional data for the event */
  37166. additionalData?: any);
  37167. /**
  37168. * Helper function to auto-create an ActionEvent from a source mesh.
  37169. * @param source The source mesh that triggered the event
  37170. * @param evt The original (browser) event
  37171. * @param additionalData additional data for the event
  37172. * @returns the new ActionEvent
  37173. */
  37174. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37175. /**
  37176. * Helper function to auto-create an ActionEvent from a source sprite
  37177. * @param source The source sprite that triggered the event
  37178. * @param scene Scene associated with the sprite
  37179. * @param evt The original (browser) event
  37180. * @param additionalData additional data for the event
  37181. * @returns the new ActionEvent
  37182. */
  37183. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37184. /**
  37185. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37186. * @param scene the scene where the event occurred
  37187. * @param evt The original (browser) event
  37188. * @returns the new ActionEvent
  37189. */
  37190. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37191. /**
  37192. * Helper function to auto-create an ActionEvent from a primitive
  37193. * @param prim defines the target primitive
  37194. * @param pointerPos defines the pointer position
  37195. * @param evt The original (browser) event
  37196. * @param additionalData additional data for the event
  37197. * @returns the new ActionEvent
  37198. */
  37199. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37200. }
  37201. }
  37202. declare module BABYLON {
  37203. /**
  37204. * Abstract class used to decouple action Manager from scene and meshes.
  37205. * Do not instantiate.
  37206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37207. */
  37208. export abstract class AbstractActionManager implements IDisposable {
  37209. /** Gets the list of active triggers */
  37210. static Triggers: {
  37211. [key: string]: number;
  37212. };
  37213. /** Gets the cursor to use when hovering items */
  37214. hoverCursor: string;
  37215. /** Gets the list of actions */
  37216. actions: IAction[];
  37217. /**
  37218. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37219. */
  37220. isRecursive: boolean;
  37221. /**
  37222. * Releases all associated resources
  37223. */
  37224. abstract dispose(): void;
  37225. /**
  37226. * Does this action manager has pointer triggers
  37227. */
  37228. abstract get hasPointerTriggers(): boolean;
  37229. /**
  37230. * Does this action manager has pick triggers
  37231. */
  37232. abstract get hasPickTriggers(): boolean;
  37233. /**
  37234. * Process a specific trigger
  37235. * @param trigger defines the trigger to process
  37236. * @param evt defines the event details to be processed
  37237. */
  37238. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37239. /**
  37240. * Does this action manager handles actions of any of the given triggers
  37241. * @param triggers defines the triggers to be tested
  37242. * @return a boolean indicating whether one (or more) of the triggers is handled
  37243. */
  37244. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37245. /**
  37246. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37247. * speed.
  37248. * @param triggerA defines the trigger to be tested
  37249. * @param triggerB defines the trigger to be tested
  37250. * @return a boolean indicating whether one (or more) of the triggers is handled
  37251. */
  37252. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37253. /**
  37254. * Does this action manager handles actions of a given trigger
  37255. * @param trigger defines the trigger to be tested
  37256. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37257. * @return whether the trigger is handled
  37258. */
  37259. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37260. /**
  37261. * Serialize this manager to a JSON object
  37262. * @param name defines the property name to store this manager
  37263. * @returns a JSON representation of this manager
  37264. */
  37265. abstract serialize(name: string): any;
  37266. /**
  37267. * Registers an action to this action manager
  37268. * @param action defines the action to be registered
  37269. * @return the action amended (prepared) after registration
  37270. */
  37271. abstract registerAction(action: IAction): Nullable<IAction>;
  37272. /**
  37273. * Unregisters an action to this action manager
  37274. * @param action defines the action to be unregistered
  37275. * @return a boolean indicating whether the action has been unregistered
  37276. */
  37277. abstract unregisterAction(action: IAction): Boolean;
  37278. /**
  37279. * Does exist one action manager with at least one trigger
  37280. **/
  37281. static get HasTriggers(): boolean;
  37282. /**
  37283. * Does exist one action manager with at least one pick trigger
  37284. **/
  37285. static get HasPickTriggers(): boolean;
  37286. /**
  37287. * Does exist one action manager that handles actions of a given trigger
  37288. * @param trigger defines the trigger to be tested
  37289. * @return a boolean indicating whether the trigger is handled by at least one action manager
  37290. **/
  37291. static HasSpecificTrigger(trigger: number): boolean;
  37292. }
  37293. }
  37294. declare module BABYLON {
  37295. /**
  37296. * Defines how a node can be built from a string name.
  37297. */
  37298. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37299. /**
  37300. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37301. */
  37302. export class Node implements IBehaviorAware<Node> {
  37303. /** @hidden */
  37304. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37305. private static _NodeConstructors;
  37306. /**
  37307. * Add a new node constructor
  37308. * @param type defines the type name of the node to construct
  37309. * @param constructorFunc defines the constructor function
  37310. */
  37311. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37312. /**
  37313. * Returns a node constructor based on type name
  37314. * @param type defines the type name
  37315. * @param name defines the new node name
  37316. * @param scene defines the hosting scene
  37317. * @param options defines optional options to transmit to constructors
  37318. * @returns the new constructor or null
  37319. */
  37320. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37321. /**
  37322. * Gets or sets the name of the node
  37323. */
  37324. name: string;
  37325. /**
  37326. * Gets or sets the id of the node
  37327. */
  37328. id: string;
  37329. /**
  37330. * Gets or sets the unique id of the node
  37331. */
  37332. uniqueId: number;
  37333. /**
  37334. * Gets or sets a string used to store user defined state for the node
  37335. */
  37336. state: string;
  37337. /**
  37338. * Gets or sets an object used to store user defined information for the node
  37339. */
  37340. metadata: any;
  37341. /**
  37342. * For internal use only. Please do not use.
  37343. */
  37344. reservedDataStore: any;
  37345. /**
  37346. * List of inspectable custom properties (used by the Inspector)
  37347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37348. */
  37349. inspectableCustomProperties: IInspectable[];
  37350. private _doNotSerialize;
  37351. /**
  37352. * Gets or sets a boolean used to define if the node must be serialized
  37353. */
  37354. get doNotSerialize(): boolean;
  37355. set doNotSerialize(value: boolean);
  37356. /** @hidden */
  37357. _isDisposed: boolean;
  37358. /**
  37359. * Gets a list of Animations associated with the node
  37360. */
  37361. animations: Animation[];
  37362. protected _ranges: {
  37363. [name: string]: Nullable<AnimationRange>;
  37364. };
  37365. /**
  37366. * Callback raised when the node is ready to be used
  37367. */
  37368. onReady: Nullable<(node: Node) => void>;
  37369. private _isEnabled;
  37370. private _isParentEnabled;
  37371. private _isReady;
  37372. /** @hidden */
  37373. _currentRenderId: number;
  37374. private _parentUpdateId;
  37375. /** @hidden */
  37376. _childUpdateId: number;
  37377. /** @hidden */
  37378. _waitingParentId: Nullable<string>;
  37379. /** @hidden */
  37380. _scene: Scene;
  37381. /** @hidden */
  37382. _cache: any;
  37383. private _parentNode;
  37384. private _children;
  37385. /** @hidden */
  37386. _worldMatrix: Matrix;
  37387. /** @hidden */
  37388. _worldMatrixDeterminant: number;
  37389. /** @hidden */
  37390. _worldMatrixDeterminantIsDirty: boolean;
  37391. /** @hidden */
  37392. private _sceneRootNodesIndex;
  37393. /**
  37394. * Gets a boolean indicating if the node has been disposed
  37395. * @returns true if the node was disposed
  37396. */
  37397. isDisposed(): boolean;
  37398. /**
  37399. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37400. * @see https://doc.babylonjs.com/how_to/parenting
  37401. */
  37402. set parent(parent: Nullable<Node>);
  37403. get parent(): Nullable<Node>;
  37404. /** @hidden */
  37405. _addToSceneRootNodes(): void;
  37406. /** @hidden */
  37407. _removeFromSceneRootNodes(): void;
  37408. private _animationPropertiesOverride;
  37409. /**
  37410. * Gets or sets the animation properties override
  37411. */
  37412. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37413. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37414. /**
  37415. * Gets a string identifying the name of the class
  37416. * @returns "Node" string
  37417. */
  37418. getClassName(): string;
  37419. /** @hidden */
  37420. readonly _isNode: boolean;
  37421. /**
  37422. * An event triggered when the mesh is disposed
  37423. */
  37424. onDisposeObservable: Observable<Node>;
  37425. private _onDisposeObserver;
  37426. /**
  37427. * Sets a callback that will be raised when the node will be disposed
  37428. */
  37429. set onDispose(callback: () => void);
  37430. /**
  37431. * Creates a new Node
  37432. * @param name the name and id to be given to this node
  37433. * @param scene the scene this node will be added to
  37434. */
  37435. constructor(name: string, scene?: Nullable<Scene>);
  37436. /**
  37437. * Gets the scene of the node
  37438. * @returns a scene
  37439. */
  37440. getScene(): Scene;
  37441. /**
  37442. * Gets the engine of the node
  37443. * @returns a Engine
  37444. */
  37445. getEngine(): Engine;
  37446. private _behaviors;
  37447. /**
  37448. * Attach a behavior to the node
  37449. * @see https://doc.babylonjs.com/features/behaviour
  37450. * @param behavior defines the behavior to attach
  37451. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37452. * @returns the current Node
  37453. */
  37454. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37455. /**
  37456. * Remove an attached behavior
  37457. * @see https://doc.babylonjs.com/features/behaviour
  37458. * @param behavior defines the behavior to attach
  37459. * @returns the current Node
  37460. */
  37461. removeBehavior(behavior: Behavior<Node>): Node;
  37462. /**
  37463. * Gets the list of attached behaviors
  37464. * @see https://doc.babylonjs.com/features/behaviour
  37465. */
  37466. get behaviors(): Behavior<Node>[];
  37467. /**
  37468. * Gets an attached behavior by name
  37469. * @param name defines the name of the behavior to look for
  37470. * @see https://doc.babylonjs.com/features/behaviour
  37471. * @returns null if behavior was not found else the requested behavior
  37472. */
  37473. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37474. /**
  37475. * Returns the latest update of the World matrix
  37476. * @returns a Matrix
  37477. */
  37478. getWorldMatrix(): Matrix;
  37479. /** @hidden */
  37480. _getWorldMatrixDeterminant(): number;
  37481. /**
  37482. * Returns directly the latest state of the mesh World matrix.
  37483. * A Matrix is returned.
  37484. */
  37485. get worldMatrixFromCache(): Matrix;
  37486. /** @hidden */
  37487. _initCache(): void;
  37488. /** @hidden */
  37489. updateCache(force?: boolean): void;
  37490. /** @hidden */
  37491. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37492. /** @hidden */
  37493. _updateCache(ignoreParentClass?: boolean): void;
  37494. /** @hidden */
  37495. _isSynchronized(): boolean;
  37496. /** @hidden */
  37497. _markSyncedWithParent(): void;
  37498. /** @hidden */
  37499. isSynchronizedWithParent(): boolean;
  37500. /** @hidden */
  37501. isSynchronized(): boolean;
  37502. /**
  37503. * Is this node ready to be used/rendered
  37504. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37505. * @return true if the node is ready
  37506. */
  37507. isReady(completeCheck?: boolean): boolean;
  37508. /**
  37509. * Is this node enabled?
  37510. * 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
  37511. * @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
  37512. * @return whether this node (and its parent) is enabled
  37513. */
  37514. isEnabled(checkAncestors?: boolean): boolean;
  37515. /** @hidden */
  37516. protected _syncParentEnabledState(): void;
  37517. /**
  37518. * Set the enabled state of this node
  37519. * @param value defines the new enabled state
  37520. */
  37521. setEnabled(value: boolean): void;
  37522. /**
  37523. * Is this node a descendant of the given node?
  37524. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37525. * @param ancestor defines the parent node to inspect
  37526. * @returns a boolean indicating if this node is a descendant of the given node
  37527. */
  37528. isDescendantOf(ancestor: Node): boolean;
  37529. /** @hidden */
  37530. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37531. /**
  37532. * Will return all nodes that have this node as ascendant
  37533. * @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
  37534. * @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
  37535. * @return all children nodes of all types
  37536. */
  37537. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37538. /**
  37539. * Get all child-meshes of this node
  37540. * @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)
  37541. * @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
  37542. * @returns an array of AbstractMesh
  37543. */
  37544. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37545. /**
  37546. * Get all direct children of this node
  37547. * @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
  37548. * @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)
  37549. * @returns an array of Node
  37550. */
  37551. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37552. /** @hidden */
  37553. _setReady(state: boolean): void;
  37554. /**
  37555. * Get an animation by name
  37556. * @param name defines the name of the animation to look for
  37557. * @returns null if not found else the requested animation
  37558. */
  37559. getAnimationByName(name: string): Nullable<Animation>;
  37560. /**
  37561. * Creates an animation range for this node
  37562. * @param name defines the name of the range
  37563. * @param from defines the starting key
  37564. * @param to defines the end key
  37565. */
  37566. createAnimationRange(name: string, from: number, to: number): void;
  37567. /**
  37568. * Delete a specific animation range
  37569. * @param name defines the name of the range to delete
  37570. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37571. */
  37572. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37573. /**
  37574. * Get an animation range by name
  37575. * @param name defines the name of the animation range to look for
  37576. * @returns null if not found else the requested animation range
  37577. */
  37578. getAnimationRange(name: string): Nullable<AnimationRange>;
  37579. /**
  37580. * Gets the list of all animation ranges defined on this node
  37581. * @returns an array
  37582. */
  37583. getAnimationRanges(): Nullable<AnimationRange>[];
  37584. /**
  37585. * Will start the animation sequence
  37586. * @param name defines the range frames for animation sequence
  37587. * @param loop defines if the animation should loop (false by default)
  37588. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37589. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37590. * @returns the object created for this animation. If range does not exist, it will return null
  37591. */
  37592. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37593. /**
  37594. * Serialize animation ranges into a JSON compatible object
  37595. * @returns serialization object
  37596. */
  37597. serializeAnimationRanges(): any;
  37598. /**
  37599. * Computes the world matrix of the node
  37600. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37601. * @returns the world matrix
  37602. */
  37603. computeWorldMatrix(force?: boolean): Matrix;
  37604. /**
  37605. * Releases resources associated with this node.
  37606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37608. */
  37609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37610. /**
  37611. * Parse animation range data from a serialization object and store them into a given node
  37612. * @param node defines where to store the animation ranges
  37613. * @param parsedNode defines the serialization object to read data from
  37614. * @param scene defines the hosting scene
  37615. */
  37616. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37617. /**
  37618. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37619. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37620. * @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
  37621. * @returns the new bounding vectors
  37622. */
  37623. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37624. min: Vector3;
  37625. max: Vector3;
  37626. };
  37627. }
  37628. }
  37629. declare module BABYLON {
  37630. /**
  37631. * @hidden
  37632. */
  37633. export class _IAnimationState {
  37634. key: number;
  37635. repeatCount: number;
  37636. workValue?: any;
  37637. loopMode?: number;
  37638. offsetValue?: any;
  37639. highLimitValue?: any;
  37640. }
  37641. /**
  37642. * Class used to store any kind of animation
  37643. */
  37644. export class Animation {
  37645. /**Name of the animation */
  37646. name: string;
  37647. /**Property to animate */
  37648. targetProperty: string;
  37649. /**The frames per second of the animation */
  37650. framePerSecond: number;
  37651. /**The data type of the animation */
  37652. dataType: number;
  37653. /**The loop mode of the animation */
  37654. loopMode?: number | undefined;
  37655. /**Specifies if blending should be enabled */
  37656. enableBlending?: boolean | undefined;
  37657. /**
  37658. * Use matrix interpolation instead of using direct key value when animating matrices
  37659. */
  37660. static AllowMatricesInterpolation: boolean;
  37661. /**
  37662. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37663. */
  37664. static AllowMatrixDecomposeForInterpolation: boolean;
  37665. /** Define the Url to load snippets */
  37666. static SnippetUrl: string;
  37667. /** Snippet ID if the animation was created from the snippet server */
  37668. snippetId: string;
  37669. /**
  37670. * Stores the key frames of the animation
  37671. */
  37672. private _keys;
  37673. /**
  37674. * Stores the easing function of the animation
  37675. */
  37676. private _easingFunction;
  37677. /**
  37678. * @hidden Internal use only
  37679. */
  37680. _runtimeAnimations: RuntimeAnimation[];
  37681. /**
  37682. * The set of event that will be linked to this animation
  37683. */
  37684. private _events;
  37685. /**
  37686. * Stores an array of target property paths
  37687. */
  37688. targetPropertyPath: string[];
  37689. /**
  37690. * Stores the blending speed of the animation
  37691. */
  37692. blendingSpeed: number;
  37693. /**
  37694. * Stores the animation ranges for the animation
  37695. */
  37696. private _ranges;
  37697. /**
  37698. * @hidden Internal use
  37699. */
  37700. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37701. /**
  37702. * Sets up an animation
  37703. * @param property The property to animate
  37704. * @param animationType The animation type to apply
  37705. * @param framePerSecond The frames per second of the animation
  37706. * @param easingFunction The easing function used in the animation
  37707. * @returns The created animation
  37708. */
  37709. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37710. /**
  37711. * Create and start an animation on a node
  37712. * @param name defines the name of the global animation that will be run on all nodes
  37713. * @param node defines the root node where the animation will take place
  37714. * @param targetProperty defines property to animate
  37715. * @param framePerSecond defines the number of frame per second yo use
  37716. * @param totalFrame defines the number of frames in total
  37717. * @param from defines the initial value
  37718. * @param to defines the final value
  37719. * @param loopMode defines which loop mode you want to use (off by default)
  37720. * @param easingFunction defines the easing function to use (linear by default)
  37721. * @param onAnimationEnd defines the callback to call when animation end
  37722. * @returns the animatable created for this animation
  37723. */
  37724. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37725. /**
  37726. * Create and start an animation on a node and its descendants
  37727. * @param name defines the name of the global animation that will be run on all nodes
  37728. * @param node defines the root node where the animation will take place
  37729. * @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
  37730. * @param targetProperty defines property to animate
  37731. * @param framePerSecond defines the number of frame per second to use
  37732. * @param totalFrame defines the number of frames in total
  37733. * @param from defines the initial value
  37734. * @param to defines the final value
  37735. * @param loopMode defines which loop mode you want to use (off by default)
  37736. * @param easingFunction defines the easing function to use (linear by default)
  37737. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37738. * @returns the list of animatables created for all nodes
  37739. * @example https://www.babylonjs-playground.com/#MH0VLI
  37740. */
  37741. 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[]>;
  37742. /**
  37743. * Creates a new animation, merges it with the existing animations and starts it
  37744. * @param name Name of the animation
  37745. * @param node Node which contains the scene that begins the animations
  37746. * @param targetProperty Specifies which property to animate
  37747. * @param framePerSecond The frames per second of the animation
  37748. * @param totalFrame The total number of frames
  37749. * @param from The frame at the beginning of the animation
  37750. * @param to The frame at the end of the animation
  37751. * @param loopMode Specifies the loop mode of the animation
  37752. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37753. * @param onAnimationEnd Callback to run once the animation is complete
  37754. * @returns Nullable animation
  37755. */
  37756. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37757. /**
  37758. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37759. * @param sourceAnimation defines the Animation containing keyframes to convert
  37760. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37761. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37762. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37763. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37764. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37765. */
  37766. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37767. /**
  37768. * Transition property of an host to the target Value
  37769. * @param property The property to transition
  37770. * @param targetValue The target Value of the property
  37771. * @param host The object where the property to animate belongs
  37772. * @param scene Scene used to run the animation
  37773. * @param frameRate Framerate (in frame/s) to use
  37774. * @param transition The transition type we want to use
  37775. * @param duration The duration of the animation, in milliseconds
  37776. * @param onAnimationEnd Callback trigger at the end of the animation
  37777. * @returns Nullable animation
  37778. */
  37779. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37780. /**
  37781. * Return the array of runtime animations currently using this animation
  37782. */
  37783. get runtimeAnimations(): RuntimeAnimation[];
  37784. /**
  37785. * Specifies if any of the runtime animations are currently running
  37786. */
  37787. get hasRunningRuntimeAnimations(): boolean;
  37788. /**
  37789. * Initializes the animation
  37790. * @param name Name of the animation
  37791. * @param targetProperty Property to animate
  37792. * @param framePerSecond The frames per second of the animation
  37793. * @param dataType The data type of the animation
  37794. * @param loopMode The loop mode of the animation
  37795. * @param enableBlending Specifies if blending should be enabled
  37796. */
  37797. constructor(
  37798. /**Name of the animation */
  37799. name: string,
  37800. /**Property to animate */
  37801. targetProperty: string,
  37802. /**The frames per second of the animation */
  37803. framePerSecond: number,
  37804. /**The data type of the animation */
  37805. dataType: number,
  37806. /**The loop mode of the animation */
  37807. loopMode?: number | undefined,
  37808. /**Specifies if blending should be enabled */
  37809. enableBlending?: boolean | undefined);
  37810. /**
  37811. * Converts the animation to a string
  37812. * @param fullDetails support for multiple levels of logging within scene loading
  37813. * @returns String form of the animation
  37814. */
  37815. toString(fullDetails?: boolean): string;
  37816. /**
  37817. * Add an event to this animation
  37818. * @param event Event to add
  37819. */
  37820. addEvent(event: AnimationEvent): void;
  37821. /**
  37822. * Remove all events found at the given frame
  37823. * @param frame The frame to remove events from
  37824. */
  37825. removeEvents(frame: number): void;
  37826. /**
  37827. * Retrieves all the events from the animation
  37828. * @returns Events from the animation
  37829. */
  37830. getEvents(): AnimationEvent[];
  37831. /**
  37832. * Creates an animation range
  37833. * @param name Name of the animation range
  37834. * @param from Starting frame of the animation range
  37835. * @param to Ending frame of the animation
  37836. */
  37837. createRange(name: string, from: number, to: number): void;
  37838. /**
  37839. * Deletes an animation range by name
  37840. * @param name Name of the animation range to delete
  37841. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37842. */
  37843. deleteRange(name: string, deleteFrames?: boolean): void;
  37844. /**
  37845. * Gets the animation range by name, or null if not defined
  37846. * @param name Name of the animation range
  37847. * @returns Nullable animation range
  37848. */
  37849. getRange(name: string): Nullable<AnimationRange>;
  37850. /**
  37851. * Gets the key frames from the animation
  37852. * @returns The key frames of the animation
  37853. */
  37854. getKeys(): Array<IAnimationKey>;
  37855. /**
  37856. * Gets the highest frame rate of the animation
  37857. * @returns Highest frame rate of the animation
  37858. */
  37859. getHighestFrame(): number;
  37860. /**
  37861. * Gets the easing function of the animation
  37862. * @returns Easing function of the animation
  37863. */
  37864. getEasingFunction(): IEasingFunction;
  37865. /**
  37866. * Sets the easing function of the animation
  37867. * @param easingFunction A custom mathematical formula for animation
  37868. */
  37869. setEasingFunction(easingFunction: EasingFunction): void;
  37870. /**
  37871. * Interpolates a scalar linearly
  37872. * @param startValue Start value of the animation curve
  37873. * @param endValue End value of the animation curve
  37874. * @param gradient Scalar amount to interpolate
  37875. * @returns Interpolated scalar value
  37876. */
  37877. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37878. /**
  37879. * Interpolates a scalar cubically
  37880. * @param startValue Start value of the animation curve
  37881. * @param outTangent End tangent of the animation
  37882. * @param endValue End value of the animation curve
  37883. * @param inTangent Start tangent of the animation curve
  37884. * @param gradient Scalar amount to interpolate
  37885. * @returns Interpolated scalar value
  37886. */
  37887. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37888. /**
  37889. * Interpolates a quaternion using a spherical linear interpolation
  37890. * @param startValue Start value of the animation curve
  37891. * @param endValue End value of the animation curve
  37892. * @param gradient Scalar amount to interpolate
  37893. * @returns Interpolated quaternion value
  37894. */
  37895. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37896. /**
  37897. * Interpolates a quaternion cubically
  37898. * @param startValue Start value of the animation curve
  37899. * @param outTangent End tangent of the animation curve
  37900. * @param endValue End value of the animation curve
  37901. * @param inTangent Start tangent of the animation curve
  37902. * @param gradient Scalar amount to interpolate
  37903. * @returns Interpolated quaternion value
  37904. */
  37905. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37906. /**
  37907. * Interpolates a Vector3 linearly
  37908. * @param startValue Start value of the animation curve
  37909. * @param endValue End value of the animation curve
  37910. * @param gradient Scalar amount to interpolate
  37911. * @returns Interpolated scalar value
  37912. */
  37913. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37914. /**
  37915. * Interpolates a Vector3 cubically
  37916. * @param startValue Start value of the animation curve
  37917. * @param outTangent End tangent of the animation
  37918. * @param endValue End value of the animation curve
  37919. * @param inTangent Start tangent of the animation curve
  37920. * @param gradient Scalar amount to interpolate
  37921. * @returns InterpolatedVector3 value
  37922. */
  37923. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37924. /**
  37925. * Interpolates a Vector2 linearly
  37926. * @param startValue Start value of the animation curve
  37927. * @param endValue End value of the animation curve
  37928. * @param gradient Scalar amount to interpolate
  37929. * @returns Interpolated Vector2 value
  37930. */
  37931. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37932. /**
  37933. * Interpolates a Vector2 cubically
  37934. * @param startValue Start value of the animation curve
  37935. * @param outTangent End tangent of the animation
  37936. * @param endValue End value of the animation curve
  37937. * @param inTangent Start tangent of the animation curve
  37938. * @param gradient Scalar amount to interpolate
  37939. * @returns Interpolated Vector2 value
  37940. */
  37941. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37942. /**
  37943. * Interpolates a size linearly
  37944. * @param startValue Start value of the animation curve
  37945. * @param endValue End value of the animation curve
  37946. * @param gradient Scalar amount to interpolate
  37947. * @returns Interpolated Size value
  37948. */
  37949. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37950. /**
  37951. * Interpolates a Color3 linearly
  37952. * @param startValue Start value of the animation curve
  37953. * @param endValue End value of the animation curve
  37954. * @param gradient Scalar amount to interpolate
  37955. * @returns Interpolated Color3 value
  37956. */
  37957. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37958. /**
  37959. * Interpolates a Color4 linearly
  37960. * @param startValue Start value of the animation curve
  37961. * @param endValue End value of the animation curve
  37962. * @param gradient Scalar amount to interpolate
  37963. * @returns Interpolated Color3 value
  37964. */
  37965. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37966. /**
  37967. * @hidden Internal use only
  37968. */
  37969. _getKeyValue(value: any): any;
  37970. /**
  37971. * @hidden Internal use only
  37972. */
  37973. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37974. /**
  37975. * Defines the function to use to interpolate matrices
  37976. * @param startValue defines the start matrix
  37977. * @param endValue defines the end matrix
  37978. * @param gradient defines the gradient between both matrices
  37979. * @param result defines an optional target matrix where to store the interpolation
  37980. * @returns the interpolated matrix
  37981. */
  37982. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37983. /**
  37984. * Makes a copy of the animation
  37985. * @returns Cloned animation
  37986. */
  37987. clone(): Animation;
  37988. /**
  37989. * Sets the key frames of the animation
  37990. * @param values The animation key frames to set
  37991. */
  37992. setKeys(values: Array<IAnimationKey>): void;
  37993. /**
  37994. * Serializes the animation to an object
  37995. * @returns Serialized object
  37996. */
  37997. serialize(): any;
  37998. /**
  37999. * Float animation type
  38000. */
  38001. static readonly ANIMATIONTYPE_FLOAT: number;
  38002. /**
  38003. * Vector3 animation type
  38004. */
  38005. static readonly ANIMATIONTYPE_VECTOR3: number;
  38006. /**
  38007. * Quaternion animation type
  38008. */
  38009. static readonly ANIMATIONTYPE_QUATERNION: number;
  38010. /**
  38011. * Matrix animation type
  38012. */
  38013. static readonly ANIMATIONTYPE_MATRIX: number;
  38014. /**
  38015. * Color3 animation type
  38016. */
  38017. static readonly ANIMATIONTYPE_COLOR3: number;
  38018. /**
  38019. * Color3 animation type
  38020. */
  38021. static readonly ANIMATIONTYPE_COLOR4: number;
  38022. /**
  38023. * Vector2 animation type
  38024. */
  38025. static readonly ANIMATIONTYPE_VECTOR2: number;
  38026. /**
  38027. * Size animation type
  38028. */
  38029. static readonly ANIMATIONTYPE_SIZE: number;
  38030. /**
  38031. * Relative Loop Mode
  38032. */
  38033. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38034. /**
  38035. * Cycle Loop Mode
  38036. */
  38037. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38038. /**
  38039. * Constant Loop Mode
  38040. */
  38041. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38042. /** @hidden */
  38043. static _UniversalLerp(left: any, right: any, amount: number): any;
  38044. /**
  38045. * Parses an animation object and creates an animation
  38046. * @param parsedAnimation Parsed animation object
  38047. * @returns Animation object
  38048. */
  38049. static Parse(parsedAnimation: any): Animation;
  38050. /**
  38051. * Appends the serialized animations from the source animations
  38052. * @param source Source containing the animations
  38053. * @param destination Target to store the animations
  38054. */
  38055. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38056. /**
  38057. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38058. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38059. * @param url defines the url to load from
  38060. * @returns a promise that will resolve to the new animation or an array of animations
  38061. */
  38062. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38063. /**
  38064. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38065. * @param snippetId defines the snippet to load
  38066. * @returns a promise that will resolve to the new animation or a new array of animations
  38067. */
  38068. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38069. }
  38070. }
  38071. declare module BABYLON {
  38072. /**
  38073. * Interface containing an array of animations
  38074. */
  38075. export interface IAnimatable {
  38076. /**
  38077. * Array of animations
  38078. */
  38079. animations: Nullable<Array<Animation>>;
  38080. }
  38081. }
  38082. declare module BABYLON {
  38083. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38084. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38085. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38086. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38087. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38088. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38089. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38090. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38091. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38092. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38093. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38094. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38095. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38096. /**
  38097. * Decorator used to define property that can be serialized as reference to a camera
  38098. * @param sourceName defines the name of the property to decorate
  38099. */
  38100. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38101. /**
  38102. * Class used to help serialization objects
  38103. */
  38104. export class SerializationHelper {
  38105. /** @hidden */
  38106. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38107. /** @hidden */
  38108. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38109. /** @hidden */
  38110. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38111. /** @hidden */
  38112. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38113. /**
  38114. * Appends the serialized animations from the source animations
  38115. * @param source Source containing the animations
  38116. * @param destination Target to store the animations
  38117. */
  38118. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38119. /**
  38120. * Static function used to serialized a specific entity
  38121. * @param entity defines the entity to serialize
  38122. * @param serializationObject defines the optional target object where serialization data will be stored
  38123. * @returns a JSON compatible object representing the serialization of the entity
  38124. */
  38125. static Serialize<T>(entity: T, serializationObject?: any): any;
  38126. /**
  38127. * Creates a new entity from a serialization data object
  38128. * @param creationFunction defines a function used to instanciated the new entity
  38129. * @param source defines the source serialization data
  38130. * @param scene defines the hosting scene
  38131. * @param rootUrl defines the root url for resources
  38132. * @returns a new entity
  38133. */
  38134. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38135. /**
  38136. * Clones an object
  38137. * @param creationFunction defines the function used to instanciate the new object
  38138. * @param source defines the source object
  38139. * @returns the cloned object
  38140. */
  38141. static Clone<T>(creationFunction: () => T, source: T): T;
  38142. /**
  38143. * Instanciates a new object based on a source one (some data will be shared between both object)
  38144. * @param creationFunction defines the function used to instanciate the new object
  38145. * @param source defines the source object
  38146. * @returns the new object
  38147. */
  38148. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. /**
  38153. * This is the base class of all the camera used in the application.
  38154. * @see https://doc.babylonjs.com/features/cameras
  38155. */
  38156. export class Camera extends Node {
  38157. /** @hidden */
  38158. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38159. /**
  38160. * This is the default projection mode used by the cameras.
  38161. * It helps recreating a feeling of perspective and better appreciate depth.
  38162. * This is the best way to simulate real life cameras.
  38163. */
  38164. static readonly PERSPECTIVE_CAMERA: number;
  38165. /**
  38166. * This helps creating camera with an orthographic mode.
  38167. * 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.
  38168. */
  38169. static readonly ORTHOGRAPHIC_CAMERA: number;
  38170. /**
  38171. * This is the default FOV mode for perspective cameras.
  38172. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38173. */
  38174. static readonly FOVMODE_VERTICAL_FIXED: number;
  38175. /**
  38176. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38177. */
  38178. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38179. /**
  38180. * This specifies there is no need for a camera rig.
  38181. * Basically only one eye is rendered corresponding to the camera.
  38182. */
  38183. static readonly RIG_MODE_NONE: number;
  38184. /**
  38185. * Simulates a camera Rig with one blue eye and one red eye.
  38186. * This can be use with 3d blue and red glasses.
  38187. */
  38188. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38189. /**
  38190. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38191. */
  38192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38193. /**
  38194. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38195. */
  38196. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38197. /**
  38198. * Defines that both eyes of the camera will be rendered over under each other.
  38199. */
  38200. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38201. /**
  38202. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38203. */
  38204. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38205. /**
  38206. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38207. */
  38208. static readonly RIG_MODE_VR: number;
  38209. /**
  38210. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38211. */
  38212. static readonly RIG_MODE_WEBVR: number;
  38213. /**
  38214. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38215. */
  38216. static readonly RIG_MODE_CUSTOM: number;
  38217. /**
  38218. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38219. */
  38220. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38221. /**
  38222. * Define the input manager associated with the camera.
  38223. */
  38224. inputs: CameraInputsManager<Camera>;
  38225. /** @hidden */
  38226. _position: Vector3;
  38227. /**
  38228. * Define the current local position of the camera in the scene
  38229. */
  38230. get position(): Vector3;
  38231. set position(newPosition: Vector3);
  38232. protected _upVector: Vector3;
  38233. /**
  38234. * The vector the camera should consider as up.
  38235. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38236. */
  38237. set upVector(vec: Vector3);
  38238. get upVector(): Vector3;
  38239. /**
  38240. * Define the current limit on the left side for an orthographic camera
  38241. * In scene unit
  38242. */
  38243. orthoLeft: Nullable<number>;
  38244. /**
  38245. * Define the current limit on the right side for an orthographic camera
  38246. * In scene unit
  38247. */
  38248. orthoRight: Nullable<number>;
  38249. /**
  38250. * Define the current limit on the bottom side for an orthographic camera
  38251. * In scene unit
  38252. */
  38253. orthoBottom: Nullable<number>;
  38254. /**
  38255. * Define the current limit on the top side for an orthographic camera
  38256. * In scene unit
  38257. */
  38258. orthoTop: Nullable<number>;
  38259. /**
  38260. * Field Of View is set in Radians. (default is 0.8)
  38261. */
  38262. fov: number;
  38263. /**
  38264. * Define the minimum distance the camera can see from.
  38265. * This is important to note that the depth buffer are not infinite and the closer it starts
  38266. * the more your scene might encounter depth fighting issue.
  38267. */
  38268. minZ: number;
  38269. /**
  38270. * Define the maximum distance the camera can see to.
  38271. * This is important to note that the depth buffer are not infinite and the further it end
  38272. * the more your scene might encounter depth fighting issue.
  38273. */
  38274. maxZ: number;
  38275. /**
  38276. * Define the default inertia of the camera.
  38277. * This helps giving a smooth feeling to the camera movement.
  38278. */
  38279. inertia: number;
  38280. /**
  38281. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38282. */
  38283. mode: number;
  38284. /**
  38285. * Define whether the camera is intermediate.
  38286. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38287. */
  38288. isIntermediate: boolean;
  38289. /**
  38290. * Define the viewport of the camera.
  38291. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38292. */
  38293. viewport: Viewport;
  38294. /**
  38295. * Restricts the camera to viewing objects with the same layerMask.
  38296. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38297. */
  38298. layerMask: number;
  38299. /**
  38300. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38301. */
  38302. fovMode: number;
  38303. /**
  38304. * Rig mode of the camera.
  38305. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38306. * This is normally controlled byt the camera themselves as internal use.
  38307. */
  38308. cameraRigMode: number;
  38309. /**
  38310. * Defines the distance between both "eyes" in case of a RIG
  38311. */
  38312. interaxialDistance: number;
  38313. /**
  38314. * Defines if stereoscopic rendering is done side by side or over under.
  38315. */
  38316. isStereoscopicSideBySide: boolean;
  38317. /**
  38318. * 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
  38319. * This is pretty helpful if you wish to make a camera render to a texture you could reuse somewhere
  38320. * else in the scene. (Eg. security camera)
  38321. *
  38322. * 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)
  38323. */
  38324. customRenderTargets: RenderTargetTexture[];
  38325. /**
  38326. * When set, the camera will render to this render target instead of the default canvas
  38327. *
  38328. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38329. */
  38330. outputRenderTarget: Nullable<RenderTargetTexture>;
  38331. /**
  38332. * Observable triggered when the camera view matrix has changed.
  38333. */
  38334. onViewMatrixChangedObservable: Observable<Camera>;
  38335. /**
  38336. * Observable triggered when the camera Projection matrix has changed.
  38337. */
  38338. onProjectionMatrixChangedObservable: Observable<Camera>;
  38339. /**
  38340. * Observable triggered when the inputs have been processed.
  38341. */
  38342. onAfterCheckInputsObservable: Observable<Camera>;
  38343. /**
  38344. * Observable triggered when reset has been called and applied to the camera.
  38345. */
  38346. onRestoreStateObservable: Observable<Camera>;
  38347. /**
  38348. * Is this camera a part of a rig system?
  38349. */
  38350. isRigCamera: boolean;
  38351. /**
  38352. * If isRigCamera set to true this will be set with the parent camera.
  38353. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38354. */
  38355. rigParent?: Camera;
  38356. /** @hidden */
  38357. _cameraRigParams: any;
  38358. /** @hidden */
  38359. _rigCameras: Camera[];
  38360. /** @hidden */
  38361. _rigPostProcess: Nullable<PostProcess>;
  38362. protected _webvrViewMatrix: Matrix;
  38363. /** @hidden */
  38364. _skipRendering: boolean;
  38365. /** @hidden */
  38366. _projectionMatrix: Matrix;
  38367. /** @hidden */
  38368. _postProcesses: Nullable<PostProcess>[];
  38369. /** @hidden */
  38370. _activeMeshes: SmartArray<AbstractMesh>;
  38371. protected _globalPosition: Vector3;
  38372. /** @hidden */
  38373. _computedViewMatrix: Matrix;
  38374. private _doNotComputeProjectionMatrix;
  38375. private _transformMatrix;
  38376. private _frustumPlanes;
  38377. private _refreshFrustumPlanes;
  38378. private _storedFov;
  38379. private _stateStored;
  38380. /**
  38381. * Instantiates a new camera object.
  38382. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38383. * @see https://doc.babylonjs.com/features/cameras
  38384. * @param name Defines the name of the camera in the scene
  38385. * @param position Defines the position of the camera
  38386. * @param scene Defines the scene the camera belongs too
  38387. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38388. */
  38389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38390. /**
  38391. * Store current camera state (fov, position, etc..)
  38392. * @returns the camera
  38393. */
  38394. storeState(): Camera;
  38395. /**
  38396. * Restores the camera state values if it has been stored. You must call storeState() first
  38397. */
  38398. protected _restoreStateValues(): boolean;
  38399. /**
  38400. * Restored camera state. You must call storeState() first.
  38401. * @returns true if restored and false otherwise
  38402. */
  38403. restoreState(): boolean;
  38404. /**
  38405. * Gets the class name of the camera.
  38406. * @returns the class name
  38407. */
  38408. getClassName(): string;
  38409. /** @hidden */
  38410. readonly _isCamera: boolean;
  38411. /**
  38412. * Gets a string representation of the camera useful for debug purpose.
  38413. * @param fullDetails Defines that a more verboe level of logging is required
  38414. * @returns the string representation
  38415. */
  38416. toString(fullDetails?: boolean): string;
  38417. /**
  38418. * Gets the current world space position of the camera.
  38419. */
  38420. get globalPosition(): Vector3;
  38421. /**
  38422. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38423. * @returns the active meshe list
  38424. */
  38425. getActiveMeshes(): SmartArray<AbstractMesh>;
  38426. /**
  38427. * Check whether a mesh is part of the current active mesh list of the camera
  38428. * @param mesh Defines the mesh to check
  38429. * @returns true if active, false otherwise
  38430. */
  38431. isActiveMesh(mesh: Mesh): boolean;
  38432. /**
  38433. * Is this camera ready to be used/rendered
  38434. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38435. * @return true if the camera is ready
  38436. */
  38437. isReady(completeCheck?: boolean): boolean;
  38438. /** @hidden */
  38439. _initCache(): void;
  38440. /** @hidden */
  38441. _updateCache(ignoreParentClass?: boolean): void;
  38442. /** @hidden */
  38443. _isSynchronized(): boolean;
  38444. /** @hidden */
  38445. _isSynchronizedViewMatrix(): boolean;
  38446. /** @hidden */
  38447. _isSynchronizedProjectionMatrix(): boolean;
  38448. /**
  38449. * Attach the input controls to a specific dom element to get the input from.
  38450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38451. */
  38452. attachControl(noPreventDefault?: boolean): void;
  38453. /**
  38454. * Attach the input controls to a specific dom element to get the input from.
  38455. * @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
  38456. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38457. * BACK COMPAT SIGNATURE ONLY.
  38458. */
  38459. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38460. /**
  38461. * Detach the current controls from the specified dom element.
  38462. */
  38463. detachControl(): void;
  38464. /**
  38465. * Detach the current controls from the specified dom element.
  38466. * @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
  38467. */
  38468. detachControl(ignored: any): void;
  38469. /**
  38470. * Update the camera state according to the different inputs gathered during the frame.
  38471. */
  38472. update(): void;
  38473. /** @hidden */
  38474. _checkInputs(): void;
  38475. /** @hidden */
  38476. get rigCameras(): Camera[];
  38477. /**
  38478. * Gets the post process used by the rig cameras
  38479. */
  38480. get rigPostProcess(): Nullable<PostProcess>;
  38481. /**
  38482. * Internal, gets the first post process.
  38483. * @returns the first post process to be run on this camera.
  38484. */
  38485. _getFirstPostProcess(): Nullable<PostProcess>;
  38486. private _cascadePostProcessesToRigCams;
  38487. /**
  38488. * Attach a post process to the camera.
  38489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38490. * @param postProcess The post process to attach to the camera
  38491. * @param insertAt The position of the post process in case several of them are in use in the scene
  38492. * @returns the position the post process has been inserted at
  38493. */
  38494. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38495. /**
  38496. * Detach a post process to the camera.
  38497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38498. * @param postProcess The post process to detach from the camera
  38499. */
  38500. detachPostProcess(postProcess: PostProcess): void;
  38501. /**
  38502. * Gets the current world matrix of the camera
  38503. */
  38504. getWorldMatrix(): Matrix;
  38505. /** @hidden */
  38506. _getViewMatrix(): Matrix;
  38507. /**
  38508. * Gets the current view matrix of the camera.
  38509. * @param force forces the camera to recompute the matrix without looking at the cached state
  38510. * @returns the view matrix
  38511. */
  38512. getViewMatrix(force?: boolean): Matrix;
  38513. /**
  38514. * Freeze the projection matrix.
  38515. * It will prevent the cache check of the camera projection compute and can speed up perf
  38516. * if no parameter of the camera are meant to change
  38517. * @param projection Defines manually a projection if necessary
  38518. */
  38519. freezeProjectionMatrix(projection?: Matrix): void;
  38520. /**
  38521. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38522. */
  38523. unfreezeProjectionMatrix(): void;
  38524. /**
  38525. * Gets the current projection matrix of the camera.
  38526. * @param force forces the camera to recompute the matrix without looking at the cached state
  38527. * @returns the projection matrix
  38528. */
  38529. getProjectionMatrix(force?: boolean): Matrix;
  38530. /**
  38531. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38532. * @returns a Matrix
  38533. */
  38534. getTransformationMatrix(): Matrix;
  38535. private _updateFrustumPlanes;
  38536. /**
  38537. * Checks if a cullable object (mesh...) is in the camera frustum
  38538. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38539. * @param target The object to check
  38540. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38541. * @returns true if the object is in frustum otherwise false
  38542. */
  38543. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38544. /**
  38545. * Checks if a cullable object (mesh...) is in the camera frustum
  38546. * Unlike isInFrustum this checks the full bounding box
  38547. * @param target The object to check
  38548. * @returns true if the object is in frustum otherwise false
  38549. */
  38550. isCompletelyInFrustum(target: ICullable): boolean;
  38551. /**
  38552. * Gets a ray in the forward direction from the camera.
  38553. * @param length Defines the length of the ray to create
  38554. * @param transform Defines the transform to apply to the ray, by default the world matrix is used to create a workd space ray
  38555. * @param origin Defines the start point of the ray which defaults to the camera position
  38556. * @returns the forward ray
  38557. */
  38558. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38559. /**
  38560. * Gets a ray in the forward direction from the camera.
  38561. * @param refRay the ray to (re)use when setting the values
  38562. * @param length Defines the length of the ray to create
  38563. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38564. * @param origin Defines the start point of the ray which defaults to the camera position
  38565. * @returns the forward ray
  38566. */
  38567. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38568. /**
  38569. * Releases resources associated with this node.
  38570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38572. */
  38573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38574. /** @hidden */
  38575. _isLeftCamera: boolean;
  38576. /**
  38577. * Gets the left camera of a rig setup in case of Rigged Camera
  38578. */
  38579. get isLeftCamera(): boolean;
  38580. /** @hidden */
  38581. _isRightCamera: boolean;
  38582. /**
  38583. * Gets the right camera of a rig setup in case of Rigged Camera
  38584. */
  38585. get isRightCamera(): boolean;
  38586. /**
  38587. * Gets the left camera of a rig setup in case of Rigged Camera
  38588. */
  38589. get leftCamera(): Nullable<FreeCamera>;
  38590. /**
  38591. * Gets the right camera of a rig setup in case of Rigged Camera
  38592. */
  38593. get rightCamera(): Nullable<FreeCamera>;
  38594. /**
  38595. * Gets the left camera target of a rig setup in case of Rigged Camera
  38596. * @returns the target position
  38597. */
  38598. getLeftTarget(): Nullable<Vector3>;
  38599. /**
  38600. * Gets the right camera target of a rig setup in case of Rigged Camera
  38601. * @returns the target position
  38602. */
  38603. getRightTarget(): Nullable<Vector3>;
  38604. /**
  38605. * @hidden
  38606. */
  38607. setCameraRigMode(mode: number, rigParams: any): void;
  38608. /** @hidden */
  38609. static _setStereoscopicRigMode(camera: Camera): void;
  38610. /** @hidden */
  38611. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38612. /** @hidden */
  38613. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38614. /** @hidden */
  38615. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38616. /** @hidden */
  38617. _getVRProjectionMatrix(): Matrix;
  38618. protected _updateCameraRotationMatrix(): void;
  38619. protected _updateWebVRCameraRotationMatrix(): void;
  38620. /**
  38621. * This function MUST be overwritten by the different WebVR cameras available.
  38622. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38623. * @hidden
  38624. */
  38625. _getWebVRProjectionMatrix(): Matrix;
  38626. /**
  38627. * This function MUST be overwritten by the different WebVR cameras available.
  38628. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38629. * @hidden
  38630. */
  38631. _getWebVRViewMatrix(): Matrix;
  38632. /** @hidden */
  38633. setCameraRigParameter(name: string, value: any): void;
  38634. /**
  38635. * needs to be overridden by children so sub has required properties to be copied
  38636. * @hidden
  38637. */
  38638. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38639. /**
  38640. * May need to be overridden by children
  38641. * @hidden
  38642. */
  38643. _updateRigCameras(): void;
  38644. /** @hidden */
  38645. _setupInputs(): void;
  38646. /**
  38647. * Serialiaze the camera setup to a json representation
  38648. * @returns the JSON representation
  38649. */
  38650. serialize(): any;
  38651. /**
  38652. * Clones the current camera.
  38653. * @param name The cloned camera name
  38654. * @returns the cloned camera
  38655. */
  38656. clone(name: string): Camera;
  38657. /**
  38658. * Gets the direction of the camera relative to a given local axis.
  38659. * @param localAxis Defines the reference axis to provide a relative direction.
  38660. * @return the direction
  38661. */
  38662. getDirection(localAxis: Vector3): Vector3;
  38663. /**
  38664. * Returns the current camera absolute rotation
  38665. */
  38666. get absoluteRotation(): Quaternion;
  38667. /**
  38668. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38669. * @param localAxis Defines the reference axis to provide a relative direction.
  38670. * @param result Defines the vector to store the result in
  38671. */
  38672. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38673. /**
  38674. * Gets a camera constructor for a given camera type
  38675. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38676. * @param name The name of the camera the result will be able to instantiate
  38677. * @param scene The scene the result will construct the camera in
  38678. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38679. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38680. * @returns a factory method to construct the camera
  38681. */
  38682. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38683. /**
  38684. * Compute the world matrix of the camera.
  38685. * @returns the camera world matrix
  38686. */
  38687. computeWorldMatrix(): Matrix;
  38688. /**
  38689. * Parse a JSON and creates the camera from the parsed information
  38690. * @param parsedCamera The JSON to parse
  38691. * @param scene The scene to instantiate the camera in
  38692. * @returns the newly constructed camera
  38693. */
  38694. static Parse(parsedCamera: any, scene: Scene): Camera;
  38695. }
  38696. }
  38697. declare module BABYLON {
  38698. /**
  38699. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38700. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38701. */
  38702. export class PostProcessManager {
  38703. private _scene;
  38704. private _indexBuffer;
  38705. private _vertexBuffers;
  38706. /**
  38707. * Creates a new instance PostProcess
  38708. * @param scene The scene that the post process is associated with.
  38709. */
  38710. constructor(scene: Scene);
  38711. private _prepareBuffers;
  38712. private _buildIndexBuffer;
  38713. /**
  38714. * Rebuilds the vertex buffers of the manager.
  38715. * @hidden
  38716. */
  38717. _rebuild(): void;
  38718. /**
  38719. * Prepares a frame to be run through a post process.
  38720. * @param sourceTexture The input texture to the post processes. (default: null)
  38721. * @param postProcesses An array of post processes to be run. (default: null)
  38722. * @returns True if the post processes were able to be run.
  38723. * @hidden
  38724. */
  38725. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38726. /**
  38727. * Manually render a set of post processes to a texture.
  38728. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38729. * @param postProcesses An array of post processes to be run.
  38730. * @param targetTexture The target texture to render to.
  38731. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38732. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38733. * @param lodLevel defines which lod of the texture to render to
  38734. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38735. */
  38736. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38737. /**
  38738. * Finalize the result of the output of the postprocesses.
  38739. * @param doNotPresent If true the result will not be displayed to the screen.
  38740. * @param targetTexture The target texture to render to.
  38741. * @param faceIndex The index of the face to bind the target texture to.
  38742. * @param postProcesses The array of post processes to render.
  38743. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38744. * @hidden
  38745. */
  38746. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38747. /**
  38748. * Disposes of the post process manager.
  38749. */
  38750. dispose(): void;
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * This Helps creating a texture that will be created from a camera in your scene.
  38756. * It is basically a dynamic texture that could be used to create special effects for instance.
  38757. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38758. */
  38759. export class RenderTargetTexture extends Texture {
  38760. /**
  38761. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38762. */
  38763. static readonly REFRESHRATE_RENDER_ONCE: number;
  38764. /**
  38765. * The texture will only be rendered rendered every frame and is recommended for dynamic contents.
  38766. */
  38767. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38768. /**
  38769. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38770. * the central point of your effect and can save a lot of performances.
  38771. */
  38772. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38773. /**
  38774. * Use this predicate to dynamically define the list of mesh you want to render.
  38775. * If set, the renderList property will be overwritten.
  38776. */
  38777. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38778. private _renderList;
  38779. /**
  38780. * Use this list to define the list of mesh you want to render.
  38781. */
  38782. get renderList(): Nullable<Array<AbstractMesh>>;
  38783. set renderList(value: Nullable<Array<AbstractMesh>>);
  38784. /**
  38785. * Use this function to overload the renderList array at rendering time.
  38786. * Return null to render with the current renderList, else return the list of meshes to use for rendering.
  38787. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38788. * the cube (if the RTT is a cube, else layerOrFace=0).
  38789. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38790. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38791. * hold dummy elements!
  38792. */
  38793. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38794. private _hookArray;
  38795. /**
  38796. * Define if particles should be rendered in your texture.
  38797. */
  38798. renderParticles: boolean;
  38799. /**
  38800. * Define if sprites should be rendered in your texture.
  38801. */
  38802. renderSprites: boolean;
  38803. /**
  38804. * Define the camera used to render the texture.
  38805. */
  38806. activeCamera: Nullable<Camera>;
  38807. /**
  38808. * Override the mesh isReady function with your own one.
  38809. */
  38810. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38811. /**
  38812. * Override the render function of the texture with your own one.
  38813. */
  38814. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38815. /**
  38816. * Define if camera post processes should be use while rendering the texture.
  38817. */
  38818. useCameraPostProcesses: boolean;
  38819. /**
  38820. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38821. */
  38822. ignoreCameraViewport: boolean;
  38823. private _postProcessManager;
  38824. /**
  38825. * Post-processes for this render target
  38826. */
  38827. get postProcesses(): PostProcess[];
  38828. private _postProcesses;
  38829. private _resizeObserver;
  38830. private get _prePassEnabled();
  38831. /**
  38832. * An event triggered when the texture is unbind.
  38833. */
  38834. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38835. /**
  38836. * An event triggered when the texture is unbind.
  38837. */
  38838. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38839. private _onAfterUnbindObserver;
  38840. /**
  38841. * Set a after unbind callback in the texture.
  38842. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38843. */
  38844. set onAfterUnbind(callback: () => void);
  38845. /**
  38846. * An event triggered before rendering the texture
  38847. */
  38848. onBeforeRenderObservable: Observable<number>;
  38849. private _onBeforeRenderObserver;
  38850. /**
  38851. * Set a before render callback in the texture.
  38852. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38853. */
  38854. set onBeforeRender(callback: (faceIndex: number) => void);
  38855. /**
  38856. * An event triggered after rendering the texture
  38857. */
  38858. onAfterRenderObservable: Observable<number>;
  38859. private _onAfterRenderObserver;
  38860. /**
  38861. * Set a after render callback in the texture.
  38862. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38863. */
  38864. set onAfterRender(callback: (faceIndex: number) => void);
  38865. /**
  38866. * An event triggered after the texture clear
  38867. */
  38868. onClearObservable: Observable<Engine>;
  38869. private _onClearObserver;
  38870. /**
  38871. * Set a clear callback in the texture.
  38872. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38873. */
  38874. set onClear(callback: (Engine: Engine) => void);
  38875. /**
  38876. * An event triggered when the texture is resized.
  38877. */
  38878. onResizeObservable: Observable<RenderTargetTexture>;
  38879. /**
  38880. * Define the clear color of the Render Target if it should be different from the scene.
  38881. */
  38882. clearColor: Color4;
  38883. protected _size: number | {
  38884. width: number;
  38885. height: number;
  38886. layers?: number;
  38887. };
  38888. protected _initialSizeParameter: number | {
  38889. width: number;
  38890. height: number;
  38891. } | {
  38892. ratio: number;
  38893. };
  38894. protected _sizeRatio: Nullable<number>;
  38895. /** @hidden */
  38896. _generateMipMaps: boolean;
  38897. protected _renderingManager: RenderingManager;
  38898. /** @hidden */
  38899. _waitingRenderList?: string[];
  38900. protected _doNotChangeAspectRatio: boolean;
  38901. protected _currentRefreshId: number;
  38902. protected _refreshRate: number;
  38903. protected _textureMatrix: Matrix;
  38904. protected _samples: number;
  38905. protected _renderTargetOptions: RenderTargetCreationOptions;
  38906. /**
  38907. * Gets render target creation options that were used.
  38908. */
  38909. get renderTargetOptions(): RenderTargetCreationOptions;
  38910. protected _onRatioRescale(): void;
  38911. /**
  38912. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38913. * It must define where the camera used to render the texture is set
  38914. */
  38915. boundingBoxPosition: Vector3;
  38916. private _boundingBoxSize;
  38917. /**
  38918. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38919. * When defined, the cubemap will switch to local mode
  38920. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38921. * @example https://www.babylonjs-playground.com/#RNASML
  38922. */
  38923. set boundingBoxSize(value: Vector3);
  38924. get boundingBoxSize(): Vector3;
  38925. /**
  38926. * In case the RTT has been created with a depth texture, get the associated
  38927. * depth texture.
  38928. * Otherwise, return null.
  38929. */
  38930. get depthStencilTexture(): Nullable<InternalTexture>;
  38931. /**
  38932. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post process
  38933. * or used a shadow, depth texture...
  38934. * @param name The friendly name of the texture
  38935. * @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)
  38936. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38937. * @param generateMipMaps True if mip maps need to be generated after render.
  38938. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38939. * @param type The type of the buffer in the RTT (int, half float, float...)
  38940. * @param isCube True if a cube texture needs to be created
  38941. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38942. * @param generateDepthBuffer True to generate a depth buffer
  38943. * @param generateStencilBuffer True to generate a stencil buffer
  38944. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38945. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38946. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38947. * @param samples sample count to use when creating the RTT
  38948. */
  38949. constructor(name: string, size: number | {
  38950. width: number;
  38951. height: number;
  38952. layers?: number;
  38953. } | {
  38954. ratio: number;
  38955. }, 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);
  38956. /**
  38957. * Creates a depth stencil texture.
  38958. * This is only available in WebGL 2 or with the depth texture extension available.
  38959. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38960. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38961. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38962. * @param samples sample count of the depth/stencil texture
  38963. */
  38964. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38965. private _processSizeParameter;
  38966. /**
  38967. * Define the number of samples to use in case of MSAA.
  38968. * It defaults to one meaning no MSAA has been enabled.
  38969. */
  38970. get samples(): number;
  38971. set samples(value: number);
  38972. /**
  38973. * Resets the refresh counter of the texture and start bak from scratch.
  38974. * Could be useful to regenerate the texture if it is setup to render only once.
  38975. */
  38976. resetRefreshCounter(): void;
  38977. /**
  38978. * Define the refresh rate of the texture or the rendering frequency.
  38979. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38980. */
  38981. get refreshRate(): number;
  38982. set refreshRate(value: number);
  38983. /**
  38984. * Adds a post process to the render target rendering passes.
  38985. * @param postProcess define the post process to add
  38986. */
  38987. addPostProcess(postProcess: PostProcess): void;
  38988. /**
  38989. * Clear all the post processes attached to the render target
  38990. * @param dispose define if the cleared post processes should also be disposed (false by default)
  38991. */
  38992. clearPostProcesses(dispose?: boolean): void;
  38993. /**
  38994. * Remove one of the post process from the list of attached post processes to the texture
  38995. * @param postProcess define the post process to remove from the list
  38996. */
  38997. removePostProcess(postProcess: PostProcess): void;
  38998. /** @hidden */
  38999. _shouldRender(): boolean;
  39000. /**
  39001. * Gets the actual render size of the texture.
  39002. * @returns the width of the render size
  39003. */
  39004. getRenderSize(): number;
  39005. /**
  39006. * Gets the actual render width of the texture.
  39007. * @returns the width of the render size
  39008. */
  39009. getRenderWidth(): number;
  39010. /**
  39011. * Gets the actual render height of the texture.
  39012. * @returns the height of the render size
  39013. */
  39014. getRenderHeight(): number;
  39015. /**
  39016. * Gets the actual number of layers of the texture.
  39017. * @returns the number of layers
  39018. */
  39019. getRenderLayers(): number;
  39020. /**
  39021. * Get if the texture can be rescaled or not.
  39022. */
  39023. get canRescale(): boolean;
  39024. /**
  39025. * Resize the texture using a ratio.
  39026. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39027. */
  39028. scale(ratio: number): void;
  39029. /**
  39030. * Get the texture reflection matrix used to rotate/transform the reflection.
  39031. * @returns the reflection matrix
  39032. */
  39033. getReflectionTextureMatrix(): Matrix;
  39034. /**
  39035. * Resize the texture to a new desired size.
  39036. * Be careful as it will recreate all the data in the new texture.
  39037. * @param size Define the new size. It can be:
  39038. * - a number for squared texture,
  39039. * - an object containing { width: number, height: number }
  39040. * - or an object containing a ratio { ratio: number }
  39041. */
  39042. resize(size: number | {
  39043. width: number;
  39044. height: number;
  39045. } | {
  39046. ratio: number;
  39047. }): void;
  39048. private _defaultRenderListPrepared;
  39049. /**
  39050. * Renders all the objects from the render list into the texture.
  39051. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39052. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39053. */
  39054. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39055. private _bestReflectionRenderTargetDimension;
  39056. private _prepareRenderingManager;
  39057. /**
  39058. * @hidden
  39059. * @param faceIndex face index to bind to if this is a cubetexture
  39060. * @param layer defines the index of the texture to bind in the array
  39061. */
  39062. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39063. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39064. /**
  39065. * @hidden
  39066. */
  39067. _prepareFrame(scene: Scene, faceIndex?: number, layer?: number, useCameraPostProcess?: boolean): void;
  39068. private renderToTarget;
  39069. /**
  39070. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  39071. * This allowed control for front to back rendering or reversely depending of the special needs.
  39072. *
  39073. * @param renderingGroupId The rendering group id corresponding to its index
  39074. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39075. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39076. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39077. */
  39078. 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;
  39079. /**
  39080. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39081. *
  39082. * @param renderingGroupId The rendering group id corresponding to its index
  39083. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39084. */
  39085. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39086. /**
  39087. * Clones the texture.
  39088. * @returns the cloned texture
  39089. */
  39090. clone(): RenderTargetTexture;
  39091. /**
  39092. * Serialize the texture to a JSON representation we can easily use in the respective Parse function.
  39093. * @returns The JSON representation of the texture
  39094. */
  39095. serialize(): any;
  39096. /**
  39097. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39098. */
  39099. disposeFramebufferObjects(): void;
  39100. /**
  39101. * Dispose the texture and release its associated resources.
  39102. */
  39103. dispose(): void;
  39104. /** @hidden */
  39105. _rebuild(): void;
  39106. /**
  39107. * Clear the info related to rendering groups preventing retention point in material dispose.
  39108. */
  39109. freeRenderingGroups(): void;
  39110. /**
  39111. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39112. * @returns the view count
  39113. */
  39114. getViewCount(): number;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /**
  39119. * Options to be used when creating an effect.
  39120. */
  39121. export interface IEffectCreationOptions {
  39122. /**
  39123. * Attributes that will be used in the shader.
  39124. */
  39125. attributes: string[];
  39126. /**
  39127. * Uniform variable names that will be set in the shader.
  39128. */
  39129. uniformsNames: string[];
  39130. /**
  39131. * Uniform buffer variable names that will be set in the shader.
  39132. */
  39133. uniformBuffersNames: string[];
  39134. /**
  39135. * Sampler texture variable names that will be set in the shader.
  39136. */
  39137. samplers: string[];
  39138. /**
  39139. * Define statements that will be set in the shader.
  39140. */
  39141. defines: any;
  39142. /**
  39143. * Possible fallbacks for this effect to improve performance when needed.
  39144. */
  39145. fallbacks: Nullable<IEffectFallbacks>;
  39146. /**
  39147. * Callback that will be called when the shader is compiled.
  39148. */
  39149. onCompiled: Nullable<(effect: Effect) => void>;
  39150. /**
  39151. * Callback that will be called if an error occurs during shader compilation.
  39152. */
  39153. onError: Nullable<(effect: Effect, errors: string) => void>;
  39154. /**
  39155. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39156. */
  39157. indexParameters?: any;
  39158. /**
  39159. * Max number of lights that can be used in the shader.
  39160. */
  39161. maxSimultaneousLights?: number;
  39162. /**
  39163. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39164. */
  39165. transformFeedbackVaryings?: Nullable<string[]>;
  39166. /**
  39167. * 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
  39168. */
  39169. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39170. /**
  39171. * Is this effect rendering to several color attachments ?
  39172. */
  39173. multiTarget?: boolean;
  39174. }
  39175. /**
  39176. * Effect containing vertex and fragment shader that can be executed on an object.
  39177. */
  39178. export class Effect implements IDisposable {
  39179. /**
  39180. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39181. */
  39182. static ShadersRepository: string;
  39183. /**
  39184. * Enable logging of the shader code when a compilation error occurs
  39185. */
  39186. static LogShaderCodeOnCompilationError: boolean;
  39187. /**
  39188. * Name of the effect.
  39189. */
  39190. name: any;
  39191. /**
  39192. * String container all the define statements that should be set on the shader.
  39193. */
  39194. defines: string;
  39195. /**
  39196. * Callback that will be called when the shader is compiled.
  39197. */
  39198. onCompiled: Nullable<(effect: Effect) => void>;
  39199. /**
  39200. * Callback that will be called if an error occurs during shader compilation.
  39201. */
  39202. onError: Nullable<(effect: Effect, errors: string) => void>;
  39203. /**
  39204. * Callback that will be called when effect is bound.
  39205. */
  39206. onBind: Nullable<(effect: Effect) => void>;
  39207. /**
  39208. * Unique ID of the effect.
  39209. */
  39210. uniqueId: number;
  39211. /**
  39212. * Observable that will be called when the shader is compiled.
  39213. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39214. */
  39215. onCompileObservable: Observable<Effect>;
  39216. /**
  39217. * Observable that will be called if an error occurs during shader compilation.
  39218. */
  39219. onErrorObservable: Observable<Effect>;
  39220. /** @hidden */
  39221. _onBindObservable: Nullable<Observable<Effect>>;
  39222. /**
  39223. * @hidden
  39224. * Specifies if the effect was previously ready
  39225. */
  39226. _wasPreviouslyReady: boolean;
  39227. /**
  39228. * Observable that will be called when effect is bound.
  39229. */
  39230. get onBindObservable(): Observable<Effect>;
  39231. /** @hidden */
  39232. _bonesComputationForcedToCPU: boolean;
  39233. /** @hidden */
  39234. _uniformBuffersNames: {
  39235. [key: string]: number;
  39236. };
  39237. /** @hidden */
  39238. _samplerList: string[];
  39239. /** @hidden */
  39240. _multiTarget: boolean;
  39241. private static _uniqueIdSeed;
  39242. private _engine;
  39243. private _uniformBuffersNamesList;
  39244. private _uniformsNames;
  39245. private _samplers;
  39246. private _isReady;
  39247. private _compilationError;
  39248. private _allFallbacksProcessed;
  39249. private _attributesNames;
  39250. private _attributes;
  39251. private _attributeLocationByName;
  39252. private _uniforms;
  39253. /**
  39254. * Key for the effect.
  39255. * @hidden
  39256. */
  39257. _key: string;
  39258. private _indexParameters;
  39259. private _fallbacks;
  39260. private _vertexSourceCodeOverride;
  39261. private _fragmentSourceCodeOverride;
  39262. private _transformFeedbackVaryings;
  39263. /**
  39264. * Compiled shader to webGL program.
  39265. * @hidden
  39266. */
  39267. _pipelineContext: Nullable<IPipelineContext>;
  39268. /** @hidden */
  39269. _vertexSourceCode: string;
  39270. /** @hidden */
  39271. _fragmentSourceCode: string;
  39272. /** @hidden */
  39273. private _rawVertexSourceCode;
  39274. /** @hidden */
  39275. private _rawFragmentSourceCode;
  39276. private static _baseCache;
  39277. private _processingContext;
  39278. /**
  39279. * Instantiates an effect.
  39280. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39281. * @param baseName Name of the effect.
  39282. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39283. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39284. * @param samplers List of sampler variables that will be passed to the shader.
  39285. * @param engine Engine to be used to render the effect
  39286. * @param defines Define statements to be added to the shader.
  39287. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39288. * @param onCompiled Callback that will be called when the shader is compiled.
  39289. * @param onError Callback that will be called if an error occurs during shader compilation.
  39290. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39291. * @param key Effect Key identifying uniquely compiled shader variants
  39292. */
  39293. 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);
  39294. private _useFinalCode;
  39295. /**
  39296. * Unique key for this effect
  39297. */
  39298. get key(): string;
  39299. /**
  39300. * If the effect has been compiled and prepared.
  39301. * @returns if the effect is compiled and prepared.
  39302. */
  39303. isReady(): boolean;
  39304. private _isReadyInternal;
  39305. /**
  39306. * The engine the effect was initialized with.
  39307. * @returns the engine.
  39308. */
  39309. getEngine(): Engine;
  39310. /**
  39311. * The pipeline context for this effect
  39312. * @returns the associated pipeline context
  39313. */
  39314. getPipelineContext(): Nullable<IPipelineContext>;
  39315. /**
  39316. * The set of names of attribute variables for the shader.
  39317. * @returns An array of attribute names.
  39318. */
  39319. getAttributesNames(): string[];
  39320. /**
  39321. * Returns the attribute at the given index.
  39322. * @param index The index of the attribute.
  39323. * @returns The location of the attribute.
  39324. */
  39325. getAttributeLocation(index: number): number;
  39326. /**
  39327. * Returns the attribute based on the name of the variable.
  39328. * @param name of the attribute to look up.
  39329. * @returns the attribute location.
  39330. */
  39331. getAttributeLocationByName(name: string): number;
  39332. /**
  39333. * The number of attributes.
  39334. * @returns the number of attributes.
  39335. */
  39336. getAttributesCount(): number;
  39337. /**
  39338. * Gets the index of a uniform variable.
  39339. * @param uniformName of the uniform to look up.
  39340. * @returns the index.
  39341. */
  39342. getUniformIndex(uniformName: string): number;
  39343. /**
  39344. * Returns the attribute based on the name of the variable.
  39345. * @param uniformName of the uniform to look up.
  39346. * @returns the location of the uniform.
  39347. */
  39348. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39349. /**
  39350. * Returns an array of sampler variable names
  39351. * @returns The array of sampler variable names.
  39352. */
  39353. getSamplers(): string[];
  39354. /**
  39355. * Returns an array of uniform variable names
  39356. * @returns The array of uniform variable names.
  39357. */
  39358. getUniformNames(): string[];
  39359. /**
  39360. * Returns an array of uniform buffer variable names
  39361. * @returns The array of uniform buffer variable names.
  39362. */
  39363. getUniformBuffersNames(): string[];
  39364. /**
  39365. * Returns the index parameters used to create the effect
  39366. * @returns The index parameters object
  39367. */
  39368. getIndexParameters(): any;
  39369. /**
  39370. * The error from the last compilation.
  39371. * @returns the error string.
  39372. */
  39373. getCompilationError(): string;
  39374. /**
  39375. * Gets a boolean indicating that all fallbacks were used during compilation
  39376. * @returns true if all fallbacks were used
  39377. */
  39378. allFallbacksProcessed(): boolean;
  39379. /**
  39380. * Adds a callback to the onCompiled observable and call the callback immediately if already ready.
  39381. * @param func The callback to be used.
  39382. */
  39383. executeWhenCompiled(func: (effect: Effect) => void): void;
  39384. private _checkIsReady;
  39385. private _loadShader;
  39386. /**
  39387. * Gets the vertex shader source code of this effect
  39388. */
  39389. get vertexSourceCode(): string;
  39390. /**
  39391. * Gets the fragment shader source code of this effect
  39392. */
  39393. get fragmentSourceCode(): string;
  39394. /**
  39395. * Gets the vertex shader source code before it has been processed by the preprocessor
  39396. */
  39397. get rawVertexSourceCode(): string;
  39398. /**
  39399. * Gets the fragment shader source code before it has been processed by the preprocessor
  39400. */
  39401. get rawFragmentSourceCode(): string;
  39402. /**
  39403. * Recompiles the webGL program
  39404. * @param vertexSourceCode The source code for the vertex shader.
  39405. * @param fragmentSourceCode The source code for the fragment shader.
  39406. * @param onCompiled Callback called when completed.
  39407. * @param onError Callback called on error.
  39408. * @hidden
  39409. */
  39410. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39411. /**
  39412. * Prepares the effect
  39413. * @hidden
  39414. */
  39415. _prepareEffect(): void;
  39416. private _getShaderCodeAndErrorLine;
  39417. private _processCompilationErrors;
  39418. /**
  39419. * Checks if the effect is supported. (Must be called after compilation)
  39420. */
  39421. get isSupported(): boolean;
  39422. /**
  39423. * Binds a texture to the engine to be used as output of the shader.
  39424. * @param channel Name of the output variable.
  39425. * @param texture Texture to bind.
  39426. * @hidden
  39427. */
  39428. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39429. /**
  39430. * Sets a texture on the engine to be used in the shader.
  39431. * @param channel Name of the sampler variable.
  39432. * @param texture Texture to set.
  39433. */
  39434. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39435. /**
  39436. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39437. * @param channel Name of the sampler variable.
  39438. * @param texture Texture to set.
  39439. */
  39440. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39441. /**
  39442. * Sets an array of textures on the engine to be used in the shader.
  39443. * @param channel Name of the variable.
  39444. * @param textures Textures to set.
  39445. */
  39446. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39447. /**
  39448. * 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)
  39449. * @param channel Name of the sampler variable.
  39450. * @param postProcess Post process to get the input texture from.
  39451. */
  39452. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39453. /**
  39454. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39455. * 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)
  39456. * @param channel Name of the sampler variable.
  39457. * @param postProcess Post process to get the output texture from.
  39458. */
  39459. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39460. /**
  39461. * Binds a buffer to a uniform.
  39462. * @param buffer Buffer to bind.
  39463. * @param name Name of the uniform variable to bind to.
  39464. */
  39465. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39466. /**
  39467. * Binds block to a uniform.
  39468. * @param blockName Name of the block to bind.
  39469. * @param index Index to bind.
  39470. */
  39471. bindUniformBlock(blockName: string, index: number): void;
  39472. /**
  39473. * Sets an integer value on a uniform variable.
  39474. * @param uniformName Name of the variable.
  39475. * @param value Value to be set.
  39476. * @returns this effect.
  39477. */
  39478. setInt(uniformName: string, value: number): Effect;
  39479. /**
  39480. * Sets an int2 value on a uniform variable.
  39481. * @param uniformName Name of the variable.
  39482. * @param x First int in int2.
  39483. * @param y Second int in int2.
  39484. * @returns this effect.
  39485. */
  39486. setInt2(uniformName: string, x: number, y: number): Effect;
  39487. /**
  39488. * Sets an int3 value on a uniform variable.
  39489. * @param uniformName Name of the variable.
  39490. * @param x First int in int3.
  39491. * @param y Second int in int3.
  39492. * @param z Third int in int3.
  39493. * @returns this effect.
  39494. */
  39495. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39496. /**
  39497. * Sets an int4 value on a uniform variable.
  39498. * @param uniformName Name of the variable.
  39499. * @param x First int in int4.
  39500. * @param y Second int in int4.
  39501. * @param z Third int in int4.
  39502. * @param w Fourth int in int4.
  39503. * @returns this effect.
  39504. */
  39505. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39506. /**
  39507. * Sets an int array on a uniform variable.
  39508. * @param uniformName Name of the variable.
  39509. * @param array array to be set.
  39510. * @returns this effect.
  39511. */
  39512. setIntArray(uniformName: string, array: Int32Array): Effect;
  39513. /**
  39514. * 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)
  39515. * @param uniformName Name of the variable.
  39516. * @param array array to be set.
  39517. * @returns this effect.
  39518. */
  39519. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39520. /**
  39521. * 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)
  39522. * @param uniformName Name of the variable.
  39523. * @param array array to be set.
  39524. * @returns this effect.
  39525. */
  39526. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39527. /**
  39528. * 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)
  39529. * @param uniformName Name of the variable.
  39530. * @param array array to be set.
  39531. * @returns this effect.
  39532. */
  39533. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39534. /**
  39535. * Sets an float array on a uniform variable.
  39536. * @param uniformName Name of the variable.
  39537. * @param array array to be set.
  39538. * @returns this effect.
  39539. */
  39540. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39541. /**
  39542. * 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)
  39543. * @param uniformName Name of the variable.
  39544. * @param array array to be set.
  39545. * @returns this effect.
  39546. */
  39547. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39548. /**
  39549. * 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)
  39550. * @param uniformName Name of the variable.
  39551. * @param array array to be set.
  39552. * @returns this effect.
  39553. */
  39554. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39555. /**
  39556. * 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)
  39557. * @param uniformName Name of the variable.
  39558. * @param array array to be set.
  39559. * @returns this effect.
  39560. */
  39561. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39562. /**
  39563. * Sets an array on a uniform variable.
  39564. * @param uniformName Name of the variable.
  39565. * @param array array to be set.
  39566. * @returns this effect.
  39567. */
  39568. setArray(uniformName: string, array: number[]): Effect;
  39569. /**
  39570. * 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)
  39571. * @param uniformName Name of the variable.
  39572. * @param array array to be set.
  39573. * @returns this effect.
  39574. */
  39575. setArray2(uniformName: string, array: number[]): Effect;
  39576. /**
  39577. * 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)
  39578. * @param uniformName Name of the variable.
  39579. * @param array array to be set.
  39580. * @returns this effect.
  39581. */
  39582. setArray3(uniformName: string, array: number[]): Effect;
  39583. /**
  39584. * 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)
  39585. * @param uniformName Name of the variable.
  39586. * @param array array to be set.
  39587. * @returns this effect.
  39588. */
  39589. setArray4(uniformName: string, array: number[]): Effect;
  39590. /**
  39591. * Sets matrices on a uniform variable.
  39592. * @param uniformName Name of the variable.
  39593. * @param matrices matrices to be set.
  39594. * @returns this effect.
  39595. */
  39596. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39597. /**
  39598. * Sets matrix on a uniform variable.
  39599. * @param uniformName Name of the variable.
  39600. * @param matrix matrix to be set.
  39601. * @returns this effect.
  39602. */
  39603. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39604. /**
  39605. * 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)
  39606. * @param uniformName Name of the variable.
  39607. * @param matrix matrix to be set.
  39608. * @returns this effect.
  39609. */
  39610. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39611. /**
  39612. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39613. * @param uniformName Name of the variable.
  39614. * @param matrix matrix to be set.
  39615. * @returns this effect.
  39616. */
  39617. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39618. /**
  39619. * Sets a float on a uniform variable.
  39620. * @param uniformName Name of the variable.
  39621. * @param value value to be set.
  39622. * @returns this effect.
  39623. */
  39624. setFloat(uniformName: string, value: number): Effect;
  39625. /**
  39626. * Sets a boolean on a uniform variable.
  39627. * @param uniformName Name of the variable.
  39628. * @param bool value to be set.
  39629. * @returns this effect.
  39630. */
  39631. setBool(uniformName: string, bool: boolean): Effect;
  39632. /**
  39633. * Sets a Vector2 on a uniform variable.
  39634. * @param uniformName Name of the variable.
  39635. * @param vector2 vector2 to be set.
  39636. * @returns this effect.
  39637. */
  39638. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39639. /**
  39640. * Sets a float2 on a uniform variable.
  39641. * @param uniformName Name of the variable.
  39642. * @param x First float in float2.
  39643. * @param y Second float in float2.
  39644. * @returns this effect.
  39645. */
  39646. setFloat2(uniformName: string, x: number, y: number): Effect;
  39647. /**
  39648. * Sets a Vector3 on a uniform variable.
  39649. * @param uniformName Name of the variable.
  39650. * @param vector3 Value to be set.
  39651. * @returns this effect.
  39652. */
  39653. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39654. /**
  39655. * Sets a float3 on a uniform variable.
  39656. * @param uniformName Name of the variable.
  39657. * @param x First float in float3.
  39658. * @param y Second float in float3.
  39659. * @param z Third float in float3.
  39660. * @returns this effect.
  39661. */
  39662. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39663. /**
  39664. * Sets a Vector4 on a uniform variable.
  39665. * @param uniformName Name of the variable.
  39666. * @param vector4 Value to be set.
  39667. * @returns this effect.
  39668. */
  39669. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39670. /**
  39671. * Sets a float4 on a uniform variable.
  39672. * @param uniformName Name of the variable.
  39673. * @param x First float in float4.
  39674. * @param y Second float in float4.
  39675. * @param z Third float in float4.
  39676. * @param w Fourth float in float4.
  39677. * @returns this effect.
  39678. */
  39679. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39680. /**
  39681. * Sets a Color3 on a uniform variable.
  39682. * @param uniformName Name of the variable.
  39683. * @param color3 Value to be set.
  39684. * @returns this effect.
  39685. */
  39686. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39687. /**
  39688. * Sets a Color4 on a uniform variable.
  39689. * @param uniformName Name of the variable.
  39690. * @param color3 Value to be set.
  39691. * @param alpha Alpha value to be set.
  39692. * @returns this effect.
  39693. */
  39694. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39695. /**
  39696. * Sets a Color4 on a uniform variable
  39697. * @param uniformName defines the name of the variable
  39698. * @param color4 defines the value to be set
  39699. * @returns this effect.
  39700. */
  39701. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39702. /**
  39703. * Release all associated resources.
  39704. **/
  39705. dispose(): void;
  39706. /**
  39707. * This function will add a new shader to the shader store
  39708. * @param name the name of the shader
  39709. * @param pixelShader optional pixel shader content
  39710. * @param vertexShader optional vertex shader content
  39711. */
  39712. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39713. /**
  39714. * Store of each shader (The can be looked up using effect.key)
  39715. */
  39716. static ShadersStore: {
  39717. [key: string]: string;
  39718. };
  39719. /**
  39720. * Store of each included file for a shader (The can be looked up using effect.key)
  39721. */
  39722. static IncludesShadersStore: {
  39723. [key: string]: string;
  39724. };
  39725. /**
  39726. * Resets the cache of effects.
  39727. */
  39728. static ResetCache(): void;
  39729. }
  39730. }
  39731. declare module BABYLON {
  39732. /**
  39733. * Interface used to describe the capabilities of the engine relatively to the current browser
  39734. */
  39735. export interface EngineCapabilities {
  39736. /** Maximum textures units per fragment shader */
  39737. maxTexturesImageUnits: number;
  39738. /** Maximum texture units per vertex shader */
  39739. maxVertexTextureImageUnits: number;
  39740. /** Maximum textures units in the entire pipeline */
  39741. maxCombinedTexturesImageUnits: number;
  39742. /** Maximum texture size */
  39743. maxTextureSize: number;
  39744. /** Maximum texture samples */
  39745. maxSamples?: number;
  39746. /** Maximum cube texture size */
  39747. maxCubemapTextureSize: number;
  39748. /** Maximum render texture size */
  39749. maxRenderTextureSize: number;
  39750. /** Maximum number of vertex attributes */
  39751. maxVertexAttribs: number;
  39752. /** Maximum number of varyings */
  39753. maxVaryingVectors: number;
  39754. /** Maximum number of uniforms per vertex shader */
  39755. maxVertexUniformVectors: number;
  39756. /** Maximum number of uniforms per fragment shader */
  39757. maxFragmentUniformVectors: number;
  39758. /** Defines if standard derivatives (dx/dy) are supported */
  39759. standardDerivatives: boolean;
  39760. /** Defines if s3tc texture compression is supported */
  39761. s3tc?: WEBGL_compressed_texture_s3tc;
  39762. /** Defines if pvrtc texture compression is supported */
  39763. pvrtc: any;
  39764. /** Defines if etc1 texture compression is supported */
  39765. etc1: any;
  39766. /** Defines if etc2 texture compression is supported */
  39767. etc2: any;
  39768. /** Defines if astc texture compression is supported */
  39769. astc: any;
  39770. /** Defines if bptc texture compression is supported */
  39771. bptc: any;
  39772. /** Defines if float textures are supported */
  39773. textureFloat: boolean;
  39774. /** Defines if vertex array objects are supported */
  39775. vertexArrayObject: boolean;
  39776. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39777. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39778. /** Gets the maximum level of anisotropy supported */
  39779. maxAnisotropy: number;
  39780. /** Defines if instancing is supported */
  39781. instancedArrays: boolean;
  39782. /** Defines if 32 bits indices are supported */
  39783. uintIndices: boolean;
  39784. /** Defines if high precision shaders are supported */
  39785. highPrecisionShaderSupported: boolean;
  39786. /** Defines if depth reading in the fragment shader is supported */
  39787. fragmentDepthSupported: boolean;
  39788. /** Defines if float texture linear filtering is supported*/
  39789. textureFloatLinearFiltering: boolean;
  39790. /** Defines if rendering to float textures is supported */
  39791. textureFloatRender: boolean;
  39792. /** Defines if half float textures are supported*/
  39793. textureHalfFloat: boolean;
  39794. /** Defines if half float texture linear filtering is supported*/
  39795. textureHalfFloatLinearFiltering: boolean;
  39796. /** Defines if rendering to half float textures is supported */
  39797. textureHalfFloatRender: boolean;
  39798. /** Defines if textureLOD shader command is supported */
  39799. textureLOD: boolean;
  39800. /** Defines if draw buffers extension is supported */
  39801. drawBuffersExtension: boolean;
  39802. /** Defines if depth textures are supported */
  39803. depthTextureExtension: boolean;
  39804. /** Defines if float color buffer are supported */
  39805. colorBufferFloat: boolean;
  39806. /** Gets disjoint timer query extension (null if not supported) */
  39807. timerQuery?: EXT_disjoint_timer_query;
  39808. /** Defines if timestamp can be used with timer query */
  39809. canUseTimestampForTimerQuery: boolean;
  39810. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39811. multiview?: any;
  39812. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39813. oculusMultiview?: any;
  39814. /** Function used to let the system compiles shaders in background */
  39815. parallelShaderCompile?: {
  39816. COMPLETION_STATUS_KHR: number;
  39817. };
  39818. /** Max number of texture samples for MSAA */
  39819. maxMSAASamples: number;
  39820. /** Defines if the blend min max extension is supported */
  39821. blendMinMax: boolean;
  39822. /** 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 */
  39823. canUseGLInstanceID: boolean;
  39824. /** Defines if gl_vertexID is available */
  39825. canUseGLVertexID: boolean;
  39826. }
  39827. }
  39828. declare module BABYLON {
  39829. /**
  39830. * @hidden
  39831. **/
  39832. export class DepthCullingState {
  39833. protected _isDepthTestDirty: boolean;
  39834. protected _isDepthMaskDirty: boolean;
  39835. protected _isDepthFuncDirty: boolean;
  39836. protected _isCullFaceDirty: boolean;
  39837. protected _isCullDirty: boolean;
  39838. protected _isZOffsetDirty: boolean;
  39839. protected _isFrontFaceDirty: boolean;
  39840. protected _depthTest: boolean;
  39841. protected _depthMask: boolean;
  39842. protected _depthFunc: Nullable<number>;
  39843. protected _cull: Nullable<boolean>;
  39844. protected _cullFace: Nullable<number>;
  39845. protected _zOffset: number;
  39846. protected _frontFace: Nullable<number>;
  39847. /**
  39848. * Initializes the state.
  39849. */
  39850. constructor(reset?: boolean);
  39851. get isDirty(): boolean;
  39852. get zOffset(): number;
  39853. set zOffset(value: number);
  39854. get cullFace(): Nullable<number>;
  39855. set cullFace(value: Nullable<number>);
  39856. get cull(): Nullable<boolean>;
  39857. set cull(value: Nullable<boolean>);
  39858. get depthFunc(): Nullable<number>;
  39859. set depthFunc(value: Nullable<number>);
  39860. get depthMask(): boolean;
  39861. set depthMask(value: boolean);
  39862. get depthTest(): boolean;
  39863. set depthTest(value: boolean);
  39864. get frontFace(): Nullable<number>;
  39865. set frontFace(value: Nullable<number>);
  39866. reset(): void;
  39867. apply(gl: WebGLRenderingContext): void;
  39868. }
  39869. }
  39870. declare module BABYLON {
  39871. /**
  39872. * @hidden
  39873. **/
  39874. export class StencilState {
  39875. /** 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 */
  39876. static readonly ALWAYS: number;
  39877. /** Passed to stencilOperation to specify that stencil value must be kept */
  39878. static readonly KEEP: number;
  39879. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39880. static readonly REPLACE: number;
  39881. protected _isStencilTestDirty: boolean;
  39882. protected _isStencilMaskDirty: boolean;
  39883. protected _isStencilFuncDirty: boolean;
  39884. protected _isStencilOpDirty: boolean;
  39885. protected _stencilTest: boolean;
  39886. protected _stencilMask: number;
  39887. protected _stencilFunc: number;
  39888. protected _stencilFuncRef: number;
  39889. protected _stencilFuncMask: number;
  39890. protected _stencilOpStencilFail: number;
  39891. protected _stencilOpDepthFail: number;
  39892. protected _stencilOpStencilDepthPass: number;
  39893. get isDirty(): boolean;
  39894. get stencilFunc(): number;
  39895. set stencilFunc(value: number);
  39896. get stencilFuncRef(): number;
  39897. set stencilFuncRef(value: number);
  39898. get stencilFuncMask(): number;
  39899. set stencilFuncMask(value: number);
  39900. get stencilOpStencilFail(): number;
  39901. set stencilOpStencilFail(value: number);
  39902. get stencilOpDepthFail(): number;
  39903. set stencilOpDepthFail(value: number);
  39904. get stencilOpStencilDepthPass(): number;
  39905. set stencilOpStencilDepthPass(value: number);
  39906. get stencilMask(): number;
  39907. set stencilMask(value: number);
  39908. get stencilTest(): boolean;
  39909. set stencilTest(value: boolean);
  39910. constructor(reset?: boolean);
  39911. reset(): void;
  39912. apply(gl: WebGLRenderingContext): void;
  39913. }
  39914. }
  39915. declare module BABYLON {
  39916. /**
  39917. * @hidden
  39918. **/
  39919. export class AlphaState {
  39920. _blendFunctionParameters: Nullable<number>[];
  39921. _blendEquationParameters: Nullable<number>[];
  39922. _blendConstants: Nullable<number>[];
  39923. _isBlendConstantsDirty: boolean;
  39924. private _alphaBlend;
  39925. private _isAlphaBlendDirty;
  39926. private _isBlendFunctionParametersDirty;
  39927. private _isBlendEquationParametersDirty;
  39928. /**
  39929. * Initializes the state.
  39930. */
  39931. constructor();
  39932. get isDirty(): boolean;
  39933. get alphaBlend(): boolean;
  39934. set alphaBlend(value: boolean);
  39935. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39936. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39937. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39938. reset(): void;
  39939. apply(gl: WebGLRenderingContext): void;
  39940. }
  39941. }
  39942. declare module BABYLON {
  39943. /** @hidden */
  39944. export class WebGLShaderProcessor implements IShaderProcessor {
  39945. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39946. }
  39947. }
  39948. declare module BABYLON {
  39949. /** @hidden */
  39950. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39951. attributeProcessor(attribute: string): string;
  39952. varyingProcessor(varying: string, isFragment: boolean): string;
  39953. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /**
  39958. * Interface for attribute information associated with buffer instantiation
  39959. */
  39960. export interface InstancingAttributeInfo {
  39961. /**
  39962. * Name of the GLSL attribute
  39963. * if attribute index is not specified, this is used to retrieve the index from the effect
  39964. */
  39965. attributeName: string;
  39966. /**
  39967. * Index/offset of the attribute in the vertex shader
  39968. * if not specified, this will be computes from the name.
  39969. */
  39970. index?: number;
  39971. /**
  39972. * size of the attribute, 1, 2, 3 or 4
  39973. */
  39974. attributeSize: number;
  39975. /**
  39976. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39977. */
  39978. offset: number;
  39979. /**
  39980. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39981. * default to 1
  39982. */
  39983. divisor?: number;
  39984. /**
  39985. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39986. * default is FLOAT
  39987. */
  39988. attributeType?: number;
  39989. /**
  39990. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39991. */
  39992. normalized?: boolean;
  39993. }
  39994. }
  39995. declare module BABYLON {
  39996. /** @hidden */
  39997. export interface EngineFeatures {
  39998. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39999. forceBitmapOverHTMLImageElement: boolean;
  40000. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  40001. supportRenderAndCopyToLodForFloatTextures: boolean;
  40002. /** Indicates that the engine support handling depth/stencil textures */
  40003. supportDepthStencilTexture: boolean;
  40004. /** Indicates that the engine support shadow samplers */
  40005. supportShadowSamplers: boolean;
  40006. /** 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 */
  40007. uniformBufferHardCheckMatrix: boolean;
  40008. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  40009. allowTexturePrefiltering: boolean;
  40010. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  40011. trackUbosInFrame: boolean;
  40012. /** Indicates that the Cascaded Shadow Map technic is supported */
  40013. supportCSM: boolean;
  40014. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  40015. basisNeedsPOT: boolean;
  40016. /** Indicates that the engine supports 3D textures */
  40017. support3DTextures: boolean;
  40018. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  40019. needTypeSuffixInShaderConstants: boolean;
  40020. /** Indicates that MSAA is supported */
  40021. supportMSAA: boolean;
  40022. /** Indicates that SSAO2 is supported */
  40023. supportSSAO2: boolean;
  40024. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  40025. supportExtendedTextureFormats: boolean;
  40026. /** Indicates that the switch/case construct is supported in shaders */
  40027. supportSwitchCaseInShader: boolean;
  40028. /** Indicates that synchronous texture reading is supported */
  40029. supportSyncTextureRead: boolean;
  40030. /** @hidden */
  40031. _collectUbosUpdatedInFrame: boolean;
  40032. }
  40033. }
  40034. declare module BABYLON {
  40035. /** @hidden */
  40036. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  40037. private _webGLTexture;
  40038. private _context;
  40039. get underlyingResource(): Nullable<WebGLTexture>;
  40040. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  40041. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  40042. set(hardwareTexture: WebGLTexture): void;
  40043. reset(): void;
  40044. release(): void;
  40045. }
  40046. }
  40047. declare module BABYLON {
  40048. interface ThinEngine {
  40049. /**
  40050. * Update a video texture
  40051. * @param texture defines the texture to update
  40052. * @param video defines the video element to use
  40053. * @param invertY defines if data must be stored with Y axis inverted
  40054. */
  40055. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40056. }
  40057. }
  40058. declare module BABYLON {
  40059. interface ThinEngine {
  40060. /**
  40061. * Creates a dynamic texture
  40062. * @param width defines the width of the texture
  40063. * @param height defines the height of the texture
  40064. * @param generateMipMaps defines if the engine should generate the mip levels
  40065. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40066. * @returns the dynamic texture inside an InternalTexture
  40067. */
  40068. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40069. /**
  40070. * Update the content of a dynamic texture
  40071. * @param texture defines the texture to update
  40072. * @param source defines the source containing the data
  40073. * @param invertY defines if data must be stored with Y axis inverted
  40074. * @param premulAlpha defines if alpha is stored as premultiplied
  40075. * @param format defines the format of the data
  40076. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40077. */
  40078. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40079. }
  40080. }
  40081. declare module BABYLON {
  40082. /**
  40083. * Settings for finer control over video usage
  40084. */
  40085. export interface VideoTextureSettings {
  40086. /**
  40087. * Applies `autoplay` to video, if specified
  40088. */
  40089. autoPlay?: boolean;
  40090. /**
  40091. * Applies `muted` to video, if specified
  40092. */
  40093. muted?: boolean;
  40094. /**
  40095. * Applies `loop` to video, if specified
  40096. */
  40097. loop?: boolean;
  40098. /**
  40099. * Automatically updates internal texture from video at every frame in the render loop
  40100. */
  40101. autoUpdateTexture: boolean;
  40102. /**
  40103. * Image src displayed during the video loading or until the user interacts with the video.
  40104. */
  40105. poster?: string;
  40106. }
  40107. /**
  40108. * If you want to display a video in your scene, this is the special texture for that.
  40109. * This special texture works similar to other textures, with the exception of a few parameters.
  40110. * @see https://doc.babylonjs.com/how_to/video_texture
  40111. */
  40112. export class VideoTexture extends Texture {
  40113. /**
  40114. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40115. */
  40116. readonly autoUpdateTexture: boolean;
  40117. /**
  40118. * The video instance used by the texture internally
  40119. */
  40120. readonly video: HTMLVideoElement;
  40121. private _onUserActionRequestedObservable;
  40122. /**
  40123. * Event triggered when a dom action is required by the user to play the video.
  40124. * This happens due to recent changes in browser policies preventing video to auto start.
  40125. */
  40126. get onUserActionRequestedObservable(): Observable<Texture>;
  40127. private _generateMipMaps;
  40128. private _stillImageCaptured;
  40129. private _displayingPosterTexture;
  40130. private _settings;
  40131. private _createInternalTextureOnEvent;
  40132. private _frameId;
  40133. private _currentSrc;
  40134. /**
  40135. * Creates a video texture.
  40136. * If you want to display a video in your scene, this is the special texture for that.
  40137. * This special texture works similar to other textures, with the exception of a few parameters.
  40138. * @see https://doc.babylonjs.com/how_to/video_texture
  40139. * @param name optional name, will detect from video source, if not defined
  40140. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40141. * @param scene is obviously the current scene.
  40142. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40143. * @param invertY is false by default but can be used to invert video on Y axis
  40144. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40145. * @param settings allows finer control over video usage
  40146. */
  40147. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40148. private _getName;
  40149. private _getVideo;
  40150. private _createInternalTexture;
  40151. private reset;
  40152. /**
  40153. * @hidden Internal method to initiate `update`.
  40154. */
  40155. _rebuild(): void;
  40156. /**
  40157. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40158. */
  40159. update(): void;
  40160. /**
  40161. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40162. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or otherwise.
  40163. */
  40164. updateTexture(isVisible: boolean): void;
  40165. protected _updateInternalTexture: () => void;
  40166. /**
  40167. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40168. * @param url New url.
  40169. */
  40170. updateURL(url: string): void;
  40171. /**
  40172. * Clones the texture.
  40173. * @returns the cloned texture
  40174. */
  40175. clone(): VideoTexture;
  40176. /**
  40177. * Dispose the texture and release its associated resources.
  40178. */
  40179. dispose(): void;
  40180. /**
  40181. * Creates a video texture straight from a stream.
  40182. * @param scene Define the scene the texture should be created in
  40183. * @param stream Define the stream the texture should be created from
  40184. * @returns The created video texture as a promise
  40185. */
  40186. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40187. /**
  40188. * Creates a video texture straight from your WebCam video feed.
  40189. * @param scene Define the scene the texture should be created in
  40190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40192. * @returns The created video texture as a promise
  40193. */
  40194. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40195. minWidth: number;
  40196. maxWidth: number;
  40197. minHeight: number;
  40198. maxHeight: number;
  40199. deviceId: string;
  40200. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40201. /**
  40202. * Creates a video texture straight from your WebCam video feed.
  40203. * @param scene Define the scene the texture should be created in
  40204. * @param onReady Define a callback to triggered once the texture will be ready
  40205. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40206. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40207. */
  40208. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40209. minWidth: number;
  40210. maxWidth: number;
  40211. minHeight: number;
  40212. maxHeight: number;
  40213. deviceId: string;
  40214. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40215. }
  40216. }
  40217. declare module BABYLON {
  40218. /**
  40219. * Defines the interface used by objects working like Scene
  40220. * @hidden
  40221. */
  40222. export interface ISceneLike {
  40223. _addPendingData(data: any): void;
  40224. _removePendingData(data: any): void;
  40225. offlineProvider: IOfflineProvider;
  40226. }
  40227. /**
  40228. * Information about the current host
  40229. */
  40230. export interface HostInformation {
  40231. /**
  40232. * Defines if the current host is a mobile
  40233. */
  40234. isMobile: boolean;
  40235. }
  40236. /** Interface defining initialization parameters for Engine class */
  40237. export interface EngineOptions extends WebGLContextAttributes {
  40238. /**
  40239. * Defines if the engine should no exceed a specified device ratio
  40240. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40241. */
  40242. limitDeviceRatio?: number;
  40243. /**
  40244. * Defines if webvr should be enabled automatically
  40245. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40246. */
  40247. autoEnableWebVR?: boolean;
  40248. /**
  40249. * Defines if webgl2 should be turned off even if supported
  40250. * @see https://doc.babylonjs.com/features/webgl2
  40251. */
  40252. disableWebGL2Support?: boolean;
  40253. /**
  40254. * Defines if webaudio should be initialized as well
  40255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40256. */
  40257. audioEngine?: boolean;
  40258. /**
  40259. * Defines if animations should run using a deterministic lock step
  40260. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40261. */
  40262. deterministicLockstep?: boolean;
  40263. /** Defines the maximum steps to use with deterministic lock step mode */
  40264. lockstepMaxSteps?: number;
  40265. /** Defines the seconds between each deterministic lock step */
  40266. timeStep?: number;
  40267. /**
  40268. * Defines that engine should ignore context lost events
  40269. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40270. */
  40271. doNotHandleContextLost?: boolean;
  40272. /**
  40273. * Defines that engine should ignore modifying touch action attribute and style
  40274. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40275. */
  40276. doNotHandleTouchAction?: boolean;
  40277. /**
  40278. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40279. */
  40280. useHighPrecisionFloats?: boolean;
  40281. /**
  40282. * Make the canvas XR Compatible for XR sessions
  40283. */
  40284. xrCompatible?: boolean;
  40285. /**
  40286. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40287. */
  40288. useHighPrecisionMatrix?: boolean;
  40289. /**
  40290. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40291. */
  40292. failIfMajorPerformanceCaveat?: boolean;
  40293. /**
  40294. * Defines whether to adapt to the device's viewport characteristics (default: false)
  40295. */
  40296. adaptToDeviceRatio?: boolean;
  40297. }
  40298. /**
  40299. * The base engine class (root of all engines)
  40300. */
  40301. export class ThinEngine {
  40302. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40303. static ExceptionList: ({
  40304. key: string;
  40305. capture: string;
  40306. captureConstraint: number;
  40307. targets: string[];
  40308. } | {
  40309. key: string;
  40310. capture: null;
  40311. captureConstraint: null;
  40312. targets: string[];
  40313. })[];
  40314. /** @hidden */
  40315. static _TextureLoaders: IInternalTextureLoader[];
  40316. /**
  40317. * Returns the current npm package of the sdk
  40318. */
  40319. static get NpmPackage(): string;
  40320. /**
  40321. * Returns the current version of the framework
  40322. */
  40323. static get Version(): string;
  40324. /**
  40325. * Returns a string describing the current engine
  40326. */
  40327. get description(): string;
  40328. /**
  40329. * Returns the name of the engine
  40330. */
  40331. get name(): string;
  40332. /**
  40333. * Returns the version of the engine
  40334. */
  40335. get version(): number;
  40336. /**
  40337. * Gets or sets the epsilon value used by collision engine
  40338. */
  40339. static CollisionsEpsilon: number;
  40340. /**
  40341. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40342. */
  40343. static get ShadersRepository(): string;
  40344. static set ShadersRepository(value: string);
  40345. /** @hidden */
  40346. _shaderProcessor: Nullable<IShaderProcessor>;
  40347. /**
  40348. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40349. */
  40350. forcePOTTextures: boolean;
  40351. /**
  40352. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40353. */
  40354. isFullscreen: boolean;
  40355. /**
  40356. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40357. */
  40358. cullBackFaces: boolean;
  40359. /**
  40360. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40361. */
  40362. renderEvenInBackground: boolean;
  40363. /**
  40364. * Gets or sets a boolean indicating that cache can be kept between frames
  40365. */
  40366. preventCacheWipeBetweenFrames: boolean;
  40367. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40368. validateShaderPrograms: boolean;
  40369. /**
  40370. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40371. * This can provide greater z depth for distant objects.
  40372. */
  40373. useReverseDepthBuffer: boolean;
  40374. /**
  40375. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40376. */
  40377. disableUniformBuffers: boolean;
  40378. private _frameId;
  40379. /**
  40380. * Gets the current frame id
  40381. */
  40382. get frameId(): number;
  40383. /** @hidden */
  40384. _uniformBuffers: UniformBuffer[];
  40385. /**
  40386. * Gets a boolean indicating that the engine supports uniform buffers
  40387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40388. */
  40389. get supportsUniformBuffers(): boolean;
  40390. /** @hidden */
  40391. _gl: WebGLRenderingContext;
  40392. /** @hidden */
  40393. _webGLVersion: number;
  40394. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40395. protected _windowIsBackground: boolean;
  40396. protected _creationOptions: EngineOptions;
  40397. protected _highPrecisionShadersAllowed: boolean;
  40398. /** @hidden */
  40399. get _shouldUseHighPrecisionShader(): boolean;
  40400. /**
  40401. * Gets a boolean indicating that only power of 2 textures are supported
  40402. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40403. */
  40404. get needPOTTextures(): boolean;
  40405. /** @hidden */
  40406. _badOS: boolean;
  40407. /** @hidden */
  40408. _badDesktopOS: boolean;
  40409. protected _hardwareScalingLevel: number;
  40410. /** @hidden */
  40411. _caps: EngineCapabilities;
  40412. /** @hidden */
  40413. _features: EngineFeatures;
  40414. protected _isStencilEnable: boolean;
  40415. private _glVersion;
  40416. private _glRenderer;
  40417. private _glVendor;
  40418. /** @hidden */
  40419. _videoTextureSupported: boolean;
  40420. protected _renderingQueueLaunched: boolean;
  40421. protected _activeRenderLoops: (() => void)[];
  40422. /**
  40423. * Observable signaled when a context lost event is raised
  40424. */
  40425. onContextLostObservable: Observable<ThinEngine>;
  40426. /**
  40427. * Observable signaled when a context restored event is raised
  40428. */
  40429. onContextRestoredObservable: Observable<ThinEngine>;
  40430. private _onContextLost;
  40431. private _onContextRestored;
  40432. protected _contextWasLost: boolean;
  40433. /** @hidden */
  40434. _doNotHandleContextLost: boolean;
  40435. /**
  40436. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40437. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40438. */
  40439. get doNotHandleContextLost(): boolean;
  40440. set doNotHandleContextLost(value: boolean);
  40441. /**
  40442. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40443. */
  40444. disableVertexArrayObjects: boolean;
  40445. /** @hidden */
  40446. protected _colorWrite: boolean;
  40447. /** @hidden */
  40448. protected _colorWriteChanged: boolean;
  40449. /** @hidden */
  40450. protected _depthCullingState: DepthCullingState;
  40451. /** @hidden */
  40452. protected _stencilState: StencilState;
  40453. /** @hidden */
  40454. _alphaState: AlphaState;
  40455. /** @hidden */
  40456. _alphaMode: number;
  40457. /** @hidden */
  40458. _alphaEquation: number;
  40459. /** @hidden */
  40460. _internalTexturesCache: InternalTexture[];
  40461. /** @hidden */
  40462. protected _activeChannel: number;
  40463. private _currentTextureChannel;
  40464. /** @hidden */
  40465. protected _boundTexturesCache: {
  40466. [key: string]: Nullable<InternalTexture>;
  40467. };
  40468. /** @hidden */
  40469. protected _currentEffect: Nullable<Effect>;
  40470. /** @hidden */
  40471. protected _currentProgram: Nullable<WebGLProgram>;
  40472. protected _compiledEffects: {
  40473. [key: string]: Effect;
  40474. };
  40475. private _vertexAttribArraysEnabled;
  40476. /** @hidden */
  40477. protected _cachedViewport: Nullable<IViewportLike>;
  40478. private _cachedVertexArrayObject;
  40479. /** @hidden */
  40480. protected _cachedVertexBuffers: any;
  40481. /** @hidden */
  40482. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40483. /** @hidden */
  40484. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40485. /** @hidden */
  40486. _currentRenderTarget: Nullable<InternalTexture>;
  40487. private _uintIndicesCurrentlySet;
  40488. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40489. /** @hidden */
  40490. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40491. /** @hidden */
  40492. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40493. private _currentBufferPointers;
  40494. private _currentInstanceLocations;
  40495. private _currentInstanceBuffers;
  40496. private _textureUnits;
  40497. /** @hidden */
  40498. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40499. /** @hidden */
  40500. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40501. /** @hidden */
  40502. _boundRenderFunction: any;
  40503. private _vaoRecordInProgress;
  40504. private _mustWipeVertexAttributes;
  40505. private _emptyTexture;
  40506. private _emptyCubeTexture;
  40507. private _emptyTexture3D;
  40508. private _emptyTexture2DArray;
  40509. /** @hidden */
  40510. _frameHandler: number;
  40511. private _nextFreeTextureSlots;
  40512. private _maxSimultaneousTextures;
  40513. private _activeRequests;
  40514. /** @hidden */
  40515. _transformTextureUrl: Nullable<(url: string) => string>;
  40516. /**
  40517. * Gets information about the current host
  40518. */
  40519. hostInformation: HostInformation;
  40520. protected get _supportsHardwareTextureRescaling(): boolean;
  40521. private _framebufferDimensionsObject;
  40522. /**
  40523. * sets the object from which width and height will be taken from when getting render width and height
  40524. * Will fallback to the gl object
  40525. * @param dimensions the framebuffer width and height that will be used.
  40526. */
  40527. set framebufferDimensionsObject(dimensions: Nullable<{
  40528. framebufferWidth: number;
  40529. framebufferHeight: number;
  40530. }>);
  40531. /**
  40532. * Gets the current viewport
  40533. */
  40534. get currentViewport(): Nullable<IViewportLike>;
  40535. /**
  40536. * Gets the default empty texture
  40537. */
  40538. get emptyTexture(): InternalTexture;
  40539. /**
  40540. * Gets the default empty 3D texture
  40541. */
  40542. get emptyTexture3D(): InternalTexture;
  40543. /**
  40544. * Gets the default empty 2D array texture
  40545. */
  40546. get emptyTexture2DArray(): InternalTexture;
  40547. /**
  40548. * Gets the default empty cube texture
  40549. */
  40550. get emptyCubeTexture(): InternalTexture;
  40551. /**
  40552. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40553. */
  40554. premultipliedAlpha: boolean;
  40555. /**
  40556. * Observable event triggered before each texture is initialized
  40557. */
  40558. onBeforeTextureInitObservable: Observable<Texture>;
  40559. /** @hidden */
  40560. protected _isWebGPU: boolean;
  40561. /**
  40562. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40563. */
  40564. get isWebGPU(): boolean;
  40565. /** @hidden */
  40566. protected _shaderPlatformName: string;
  40567. /**
  40568. * Gets the shader platfrom name used by the effects.
  40569. */
  40570. get shaderPlatformName(): string;
  40571. /**
  40572. * Creates a new engine
  40573. * @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
  40574. * @param antialias defines enable antialiasing (default: false)
  40575. * @param options defines further options to be sent to the getContext() function
  40576. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40577. */
  40578. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40579. /**
  40580. * @hidden
  40581. */
  40582. _debugPushGroup(groupName: string, targetObject?: number): void;
  40583. /**
  40584. * @hidden
  40585. */
  40586. _debugPopGroup(targetObject?: number): void;
  40587. /**
  40588. * @hidden
  40589. */
  40590. _debugInsertMarker(text: string, targetObject?: number): void;
  40591. /**
  40592. * Shared initialization across engines types.
  40593. * @param canvas The canvas associated with this instance of the engine.
  40594. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40595. * @param audioEngine Defines if an audio engine should be created by default
  40596. */
  40597. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40598. /**
  40599. * Gets a shader processor implementation fitting with the current engine type.
  40600. * @returns The shader processor implementation.
  40601. */
  40602. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40603. /** @hidden */
  40604. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40605. private _rebuildInternalTextures;
  40606. private _rebuildEffects;
  40607. /**
  40608. * Gets a boolean indicating if all created effects are ready
  40609. * @returns true if all effects are ready
  40610. */
  40611. areAllEffectsReady(): boolean;
  40612. protected _rebuildBuffers(): void;
  40613. protected _initGLContext(): void;
  40614. protected _initFeatures(): void;
  40615. /**
  40616. * Gets version of the current webGL context
  40617. * Keep it for back compat - use version instead
  40618. */
  40619. get webGLVersion(): number;
  40620. /**
  40621. * Gets a string identifying the name of the class
  40622. * @returns "Engine" string
  40623. */
  40624. getClassName(): string;
  40625. /**
  40626. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40627. */
  40628. get isStencilEnable(): boolean;
  40629. /** @hidden */
  40630. _prepareWorkingCanvas(): void;
  40631. /**
  40632. * Reset the texture cache to empty state
  40633. */
  40634. resetTextureCache(): void;
  40635. /**
  40636. * Gets an object containing information about the current webGL context
  40637. * @returns an object containing the vendor, the renderer and the version of the current webGL context
  40638. */
  40639. getGlInfo(): {
  40640. vendor: string;
  40641. renderer: string;
  40642. version: string;
  40643. };
  40644. /**
  40645. * Defines the hardware scaling level.
  40646. * By default the hardware scaling level is computed from the window device ratio.
  40647. * 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.
  40648. * @param level defines the level to use
  40649. */
  40650. setHardwareScalingLevel(level: number): void;
  40651. /**
  40652. * Gets the current hardware scaling level.
  40653. * By default the hardware scaling level is computed from the window device ratio.
  40654. * 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.
  40655. * @returns a number indicating the current hardware scaling level
  40656. */
  40657. getHardwareScalingLevel(): number;
  40658. /**
  40659. * Gets the list of loaded textures
  40660. * @returns an array containing all loaded textures
  40661. */
  40662. getLoadedTexturesCache(): InternalTexture[];
  40663. /**
  40664. * Gets the object containing all engine capabilities
  40665. * @returns the EngineCapabilities object
  40666. */
  40667. getCaps(): EngineCapabilities;
  40668. /**
  40669. * stop executing a render loop function and remove it from the execution array
  40670. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40671. */
  40672. stopRenderLoop(renderFunction?: () => void): void;
  40673. /** @hidden */
  40674. _renderLoop(): void;
  40675. /**
  40676. * Gets the HTML canvas attached with the current webGL context
  40677. * @returns a HTML canvas
  40678. */
  40679. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40680. /**
  40681. * Gets host window
  40682. * @returns the host window object
  40683. */
  40684. getHostWindow(): Nullable<Window>;
  40685. /**
  40686. * Gets the current render width
  40687. * @param useScreen defines if screen size must be used (or the current render target if any)
  40688. * @returns a number defining the current render width
  40689. */
  40690. getRenderWidth(useScreen?: boolean): number;
  40691. /**
  40692. * Gets the current render height
  40693. * @param useScreen defines if screen size must be used (or the current render target if any)
  40694. * @returns a number defining the current render height
  40695. */
  40696. getRenderHeight(useScreen?: boolean): number;
  40697. /**
  40698. * Can be used to override the current requestAnimationFrame requester.
  40699. * @hidden
  40700. */
  40701. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40702. /**
  40703. * Register and execute a render loop. The engine can have more than one render function
  40704. * @param renderFunction defines the function to continuously execute
  40705. */
  40706. runRenderLoop(renderFunction: () => void): void;
  40707. /**
  40708. * Clear the current render buffer or the current render target (if any is set up)
  40709. * @param color defines the color to use
  40710. * @param backBuffer defines if the back buffer must be cleared
  40711. * @param depth defines if the depth buffer must be cleared
  40712. * @param stencil defines if the stencil buffer must be cleared
  40713. */
  40714. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40715. protected _viewportCached: {
  40716. x: number;
  40717. y: number;
  40718. z: number;
  40719. w: number;
  40720. };
  40721. /** @hidden */
  40722. _viewport(x: number, y: number, width: number, height: number): void;
  40723. /**
  40724. * Set the WebGL's viewport
  40725. * @param viewport defines the viewport element to be used
  40726. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40727. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40728. */
  40729. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40730. /**
  40731. * Begin a new frame
  40732. */
  40733. beginFrame(): void;
  40734. /**
  40735. * Enf the current frame
  40736. */
  40737. endFrame(): void;
  40738. /**
  40739. * Resize the view according to the canvas' size
  40740. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40741. */
  40742. resize(forceSetSize?: boolean): void;
  40743. /**
  40744. * Force a specific size of the canvas
  40745. * @param width defines the new canvas' width
  40746. * @param height defines the new canvas' height
  40747. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40748. * @returns true if the size was changed
  40749. */
  40750. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40751. /**
  40752. * Binds the frame buffer to the specified texture.
  40753. * @param texture The texture to render to or null for the default canvas
  40754. * @param faceIndex The face of the texture to render to in case of cube texture
  40755. * @param requiredWidth The width of the target to render to
  40756. * @param requiredHeight The height of the target to render to
  40757. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40758. * @param lodLevel defines the lod level to bind to the frame buffer
  40759. * @param layer defines the 2d array index to bind to frame buffer to
  40760. */
  40761. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40762. /** @hidden */
  40763. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40764. /**
  40765. * Unbind the current render target texture from the webGL context
  40766. * @param texture defines the render target texture to unbind
  40767. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40768. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40769. */
  40770. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40771. /**
  40772. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40773. */
  40774. flushFramebuffer(): void;
  40775. /**
  40776. * Unbind the current render target and bind the default framebuffer
  40777. */
  40778. restoreDefaultFramebuffer(): void;
  40779. /** @hidden */
  40780. protected _resetVertexBufferBinding(): void;
  40781. /**
  40782. * Creates a vertex buffer
  40783. * @param data the data for the vertex buffer
  40784. * @returns the new WebGL static buffer
  40785. */
  40786. createVertexBuffer(data: DataArray): DataBuffer;
  40787. private _createVertexBuffer;
  40788. /**
  40789. * Creates a dynamic vertex buffer
  40790. * @param data the data for the dynamic vertex buffer
  40791. * @returns the new WebGL dynamic buffer
  40792. */
  40793. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40794. protected _resetIndexBufferBinding(): void;
  40795. /**
  40796. * Creates a new index buffer
  40797. * @param indices defines the content of the index buffer
  40798. * @param updatable defines if the index buffer must be updatable
  40799. * @returns a new webGL buffer
  40800. */
  40801. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40802. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40803. /**
  40804. * Bind a webGL buffer to the webGL context
  40805. * @param buffer defines the buffer to bind
  40806. */
  40807. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40808. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40809. private bindBuffer;
  40810. /**
  40811. * update the bound buffer with the given data
  40812. * @param data defines the data to update
  40813. */
  40814. updateArrayBuffer(data: Float32Array): void;
  40815. private _vertexAttribPointer;
  40816. /** @hidden */
  40817. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40818. private _bindVertexBuffersAttributes;
  40819. /**
  40820. * Records a vertex array object
  40821. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40822. * @param vertexBuffers defines the list of vertex buffers to store
  40823. * @param indexBuffer defines the index buffer to store
  40824. * @param effect defines the effect to store
  40825. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40826. * @returns the new vertex array object
  40827. */
  40828. recordVertexArrayObject(vertexBuffers: {
  40829. [key: string]: VertexBuffer;
  40830. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40831. [kind: string]: Nullable<VertexBuffer>;
  40832. }): WebGLVertexArrayObject;
  40833. /**
  40834. * Bind a specific vertex array object
  40835. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40836. * @param vertexArrayObject defines the vertex array object to bind
  40837. * @param indexBuffer defines the index buffer to bind
  40838. */
  40839. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40840. /**
  40841. * Bind webGl buffers directly to the webGL context
  40842. * @param vertexBuffer defines the vertex buffer to bind
  40843. * @param indexBuffer defines the index buffer to bind
  40844. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40845. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40846. * @param effect defines the effect associated with the vertex buffer
  40847. */
  40848. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40849. private _unbindVertexArrayObject;
  40850. /**
  40851. * Bind a list of vertex buffers to the webGL context
  40852. * @param vertexBuffers defines the list of vertex buffers to bind
  40853. * @param indexBuffer defines the index buffer to bind
  40854. * @param effect defines the effect associated with the vertex buffers
  40855. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  40856. */
  40857. bindBuffers(vertexBuffers: {
  40858. [key: string]: Nullable<VertexBuffer>;
  40859. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  40860. [kind: string]: Nullable<VertexBuffer>;
  40861. }): void;
  40862. /**
  40863. * Unbind all instance attributes
  40864. */
  40865. unbindInstanceAttributes(): void;
  40866. /**
  40867. * Release and free the memory of a vertex array object
  40868. * @param vao defines the vertex array object to delete
  40869. */
  40870. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40871. /** @hidden */
  40872. _releaseBuffer(buffer: DataBuffer): boolean;
  40873. protected _deleteBuffer(buffer: DataBuffer): void;
  40874. /**
  40875. * Update the content of a webGL buffer used with instantiation and bind it to the webGL context
  40876. * @param instancesBuffer defines the webGL buffer to update and bind
  40877. * @param data defines the data to store in the buffer
  40878. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40879. */
  40880. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40881. /**
  40882. * Bind the content of a webGL buffer used with instantiation
  40883. * @param instancesBuffer defines the webGL buffer to bind
  40884. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40885. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40886. */
  40887. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40888. /**
  40889. * Disable the instance attribute corresponding to the name in parameter
  40890. * @param name defines the name of the attribute to disable
  40891. */
  40892. disableInstanceAttributeByName(name: string): void;
  40893. /**
  40894. * Disable the instance attribute corresponding to the location in parameter
  40895. * @param attributeLocation defines the attribute location of the attribute to disable
  40896. */
  40897. disableInstanceAttribute(attributeLocation: number): void;
  40898. /**
  40899. * Disable the attribute corresponding to the location in parameter
  40900. * @param attributeLocation defines the attribute location of the attribute to disable
  40901. */
  40902. disableAttributeByIndex(attributeLocation: number): void;
  40903. /**
  40904. * Send a draw order
  40905. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40906. * @param indexStart defines the starting index
  40907. * @param indexCount defines the number of index to draw
  40908. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40909. */
  40910. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40911. /**
  40912. * Draw a list of points
  40913. * @param verticesStart defines the index of first vertex to draw
  40914. * @param verticesCount defines the count of vertices to draw
  40915. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40916. */
  40917. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40918. /**
  40919. * Draw a list of unindexed primitives
  40920. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40921. * @param verticesStart defines the index of first vertex to draw
  40922. * @param verticesCount defines the count of vertices to draw
  40923. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40924. */
  40925. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40926. /**
  40927. * Draw a list of indexed primitives
  40928. * @param fillMode defines the primitive to use
  40929. * @param indexStart defines the starting index
  40930. * @param indexCount defines the number of index to draw
  40931. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40932. */
  40933. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40934. /**
  40935. * Draw a list of unindexed primitives
  40936. * @param fillMode defines the primitive to use
  40937. * @param verticesStart defines the index of first vertex to draw
  40938. * @param verticesCount defines the count of vertices to draw
  40939. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  40940. */
  40941. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40942. private _drawMode;
  40943. /** @hidden */
  40944. protected _reportDrawCall(): void;
  40945. /** @hidden */
  40946. _releaseEffect(effect: Effect): void;
  40947. /** @hidden */
  40948. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40949. /**
  40950. * Create a new effect (used to store vertex/fragment shaders)
  40951. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40952. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40953. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40954. * @param samplers defines an array of string used to represent textures
  40955. * @param defines defines the string containing the defines to use to compile the shaders
  40956. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  40957. * @param onCompiled defines a function to call when the effect creation is successful
  40958. * @param onError defines a function to call when the effect creation has failed
  40959. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40960. * @returns the new Effect
  40961. */
  40962. 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;
  40963. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40964. private _compileShader;
  40965. private _compileRawShader;
  40966. /** @hidden */
  40967. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40968. /**
  40969. * Directly creates a webGL program
  40970. * @param pipelineContext defines the pipeline context to attach to
  40971. * @param vertexCode defines the vertex shader code to use
  40972. * @param fragmentCode defines the fragment shader code to use
  40973. * @param context defines the webGL context to use (if not set, the current one will be used)
  40974. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40975. * @returns the new webGL program
  40976. */
  40977. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40978. /**
  40979. * Creates a webGL program
  40980. * @param pipelineContext defines the pipeline context to attach to
  40981. * @param vertexCode defines the vertex shader code to use
  40982. * @param fragmentCode defines the fragment shader code to use
  40983. * @param defines defines the string containing the defines to use to compile the shaders
  40984. * @param context defines the webGL context to use (if not set, the current one will be used)
  40985. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40986. * @returns the new webGL program
  40987. */
  40988. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40989. /**
  40990. * Creates a new pipeline context
  40991. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40992. * @returns the new pipeline
  40993. */
  40994. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40995. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40996. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40997. /** @hidden */
  40998. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40999. /** @hidden */
  41000. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41001. /** @hidden */
  41002. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41003. /**
  41004. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41005. * @param pipelineContext defines the pipeline context to use
  41006. * @param uniformsNames defines the list of uniform names
  41007. * @returns an array of webGL uniform locations
  41008. */
  41009. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41010. /**
  41011. * Gets the list of active attributes for a given webGL program
  41012. * @param pipelineContext defines the pipeline context to use
  41013. * @param attributesNames defines the list of attribute names to get
  41014. * @returns an array of indices indicating the offset of each attribute
  41015. */
  41016. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41017. /**
  41018. * Activates an effect, making it the current one (ie. the one used for rendering)
  41019. * @param effect defines the effect to activate
  41020. */
  41021. enableEffect(effect: Nullable<Effect>): void;
  41022. /**
  41023. * Set the value of an uniform to a number (int)
  41024. * @param uniform defines the webGL uniform location where to store the value
  41025. * @param value defines the int number to store
  41026. * @returns true if the value was set
  41027. */
  41028. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41029. /**
  41030. * Set the value of an uniform to a int2
  41031. * @param uniform defines the webGL uniform location where to store the value
  41032. * @param x defines the 1st component of the value
  41033. * @param y defines the 2nd component of the value
  41034. * @returns true if the value was set
  41035. */
  41036. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41037. /**
  41038. * Set the value of an uniform to a int3
  41039. * @param uniform defines the webGL uniform location where to store the value
  41040. * @param x defines the 1st component of the value
  41041. * @param y defines the 2nd component of the value
  41042. * @param z defines the 3rd component of the value
  41043. * @returns true if the value was set
  41044. */
  41045. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41046. /**
  41047. * Set the value of an uniform to a int4
  41048. * @param uniform defines the webGL uniform location where to store the value
  41049. * @param x defines the 1st component of the value
  41050. * @param y defines the 2nd component of the value
  41051. * @param z defines the 3rd component of the value
  41052. * @param w defines the 4th component of the value
  41053. * @returns true if the value was set
  41054. */
  41055. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41056. /**
  41057. * Set the value of an uniform to an array of int32
  41058. * @param uniform defines the webGL uniform location where to store the value
  41059. * @param array defines the array of int32 to store
  41060. * @returns true if the value was set
  41061. */
  41062. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41063. /**
  41064. * Set the value of an uniform to an array of int32 (stored as vec2)
  41065. * @param uniform defines the webGL uniform location where to store the value
  41066. * @param array defines the array of int32 to store
  41067. * @returns true if the value was set
  41068. */
  41069. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41070. /**
  41071. * Set the value of an uniform to an array of int32 (stored as vec3)
  41072. * @param uniform defines the webGL uniform location where to store the value
  41073. * @param array defines the array of int32 to store
  41074. * @returns true if the value was set
  41075. */
  41076. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41077. /**
  41078. * Set the value of an uniform to an array of int32 (stored as vec4)
  41079. * @param uniform defines the webGL uniform location where to store the value
  41080. * @param array defines the array of int32 to store
  41081. * @returns true if the value was set
  41082. */
  41083. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41084. /**
  41085. * Set the value of an uniform to an array of number
  41086. * @param uniform defines the webGL uniform location where to store the value
  41087. * @param array defines the array of number to store
  41088. * @returns true if the value was set
  41089. */
  41090. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41091. /**
  41092. * Set the value of an uniform to an array of number (stored as vec2)
  41093. * @param uniform defines the webGL uniform location where to store the value
  41094. * @param array defines the array of number to store
  41095. * @returns true if the value was set
  41096. */
  41097. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41098. /**
  41099. * Set the value of an uniform to an array of number (stored as vec3)
  41100. * @param uniform defines the webGL uniform location where to store the value
  41101. * @param array defines the array of number to store
  41102. * @returns true if the value was set
  41103. */
  41104. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41105. /**
  41106. * Set the value of an uniform to an array of number (stored as vec4)
  41107. * @param uniform defines the webGL uniform location where to store the value
  41108. * @param array defines the array of number to store
  41109. * @returns true if the value was set
  41110. */
  41111. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41112. /**
  41113. * Set the value of an uniform to an array of float32 (stored as matrices)
  41114. * @param uniform defines the webGL uniform location where to store the value
  41115. * @param matrices defines the array of float32 to store
  41116. * @returns true if the value was set
  41117. */
  41118. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41119. /**
  41120. * Set the value of an uniform to a matrix (3x3)
  41121. * @param uniform defines the webGL uniform location where to store the value
  41122. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41123. * @returns true if the value was set
  41124. */
  41125. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41126. /**
  41127. * Set the value of an uniform to a matrix (2x2)
  41128. * @param uniform defines the webGL uniform location where to store the value
  41129. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41130. * @returns true if the value was set
  41131. */
  41132. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41133. /**
  41134. * Set the value of an uniform to a number (float)
  41135. * @param uniform defines the webGL uniform location where to store the value
  41136. * @param value defines the float number to store
  41137. * @returns true if the value was transferred
  41138. */
  41139. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41140. /**
  41141. * Set the value of an uniform to a vec2
  41142. * @param uniform defines the webGL uniform location where to store the value
  41143. * @param x defines the 1st component of the value
  41144. * @param y defines the 2nd component of the value
  41145. * @returns true if the value was set
  41146. */
  41147. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41148. /**
  41149. * Set the value of an uniform to a vec3
  41150. * @param uniform defines the webGL uniform location where to store the value
  41151. * @param x defines the 1st component of the value
  41152. * @param y defines the 2nd component of the value
  41153. * @param z defines the 3rd component of the value
  41154. * @returns true if the value was set
  41155. */
  41156. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41157. /**
  41158. * Set the value of an uniform to a vec4
  41159. * @param uniform defines the webGL uniform location where to store the value
  41160. * @param x defines the 1st component of the value
  41161. * @param y defines the 2nd component of the value
  41162. * @param z defines the 3rd component of the value
  41163. * @param w defines the 4th component of the value
  41164. * @returns true if the value was set
  41165. */
  41166. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41167. /**
  41168. * Apply all cached states (depth, culling, stencil and alpha)
  41169. */
  41170. applyStates(): void;
  41171. /**
  41172. * Enable or disable color writing
  41173. * @param enable defines the state to set
  41174. */
  41175. setColorWrite(enable: boolean): void;
  41176. /**
  41177. * Gets a boolean indicating if color writing is enabled
  41178. * @returns the current color writing state
  41179. */
  41180. getColorWrite(): boolean;
  41181. /**
  41182. * Gets the depth culling state manager
  41183. */
  41184. get depthCullingState(): DepthCullingState;
  41185. /**
  41186. * Gets the alpha state manager
  41187. */
  41188. get alphaState(): AlphaState;
  41189. /**
  41190. * Gets the stencil state manager
  41191. */
  41192. get stencilState(): StencilState;
  41193. /**
  41194. * Clears the list of texture accessible through engine.
  41195. * This can help preventing texture load conflict due to name collision.
  41196. */
  41197. clearInternalTexturesCache(): void;
  41198. /**
  41199. * Force the entire cache to be cleared
  41200. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41201. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41202. */
  41203. wipeCaches(bruteForce?: boolean): void;
  41204. /** @hidden */
  41205. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41206. min: number;
  41207. mag: number;
  41208. };
  41209. /** @hidden */
  41210. protected _createTexture(): WebGLTexture;
  41211. /** @hidden */
  41212. _createHardwareTexture(): HardwareTextureWrapper;
  41213. 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 | {
  41214. width: number;
  41215. height: number;
  41216. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41217. width: number;
  41218. height: number;
  41219. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  41220. width: number;
  41221. height: number;
  41222. }, 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;
  41223. /**
  41224. * Usually called from Texture.ts.
  41225. * Passed information to create a WebGLTexture
  41226. * @param url defines a value which contains one of the following:
  41227. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41228. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41229. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41230. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41231. * @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)
  41232. * @param scene needed for loading to the correct scene
  41233. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41234. * @param onLoad optional callback to be called upon successful completion
  41235. * @param onError optional callback to be called upon failure
  41236. * @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
  41237. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41238. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41239. * @param forcedExtension defines the extension to use to pick the right loader
  41240. * @param mimeType defines an optional mime type
  41241. * @param loaderOptions options to be passed to the loader
  41242. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41243. */
  41244. 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;
  41245. /**
  41246. * Loads an image as an HTMLImageElement.
  41247. * @param input url string, ArrayBuffer, or Blob to load
  41248. * @param onLoad callback called when the image successfully loads
  41249. * @param onError callback called when the image fails to load
  41250. * @param offlineProvider offline provider for caching
  41251. * @param mimeType optional mime type
  41252. * @returns the HTMLImageElement of the loaded image
  41253. * @hidden
  41254. */
  41255. 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>;
  41256. /**
  41257. * @hidden
  41258. */
  41259. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41260. private _unpackFlipYCached;
  41261. /**
  41262. * In case you are sharing the context with other applications, it might
  41263. * be interested to not cache the unpack flip y state to ensure a consistent
  41264. * value would be set.
  41265. */
  41266. enableUnpackFlipYCached: boolean;
  41267. /** @hidden */
  41268. _unpackFlipY(value: boolean): void;
  41269. /** @hidden */
  41270. _getUnpackAlignement(): number;
  41271. private _getTextureTarget;
  41272. /**
  41273. * Update the sampling mode of a given texture
  41274. * @param samplingMode defines the required sampling mode
  41275. * @param texture defines the texture to update
  41276. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41277. */
  41278. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41279. /**
  41280. * Update the dimensions of a texture
  41281. * @param texture texture to update
  41282. * @param width new width of the texture
  41283. * @param height new height of the texture
  41284. * @param depth new depth of the texture
  41285. */
  41286. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  41287. /**
  41288. * Update the sampling mode of a given texture
  41289. * @param texture defines the texture to update
  41290. * @param wrapU defines the texture wrap mode of the u coordinates
  41291. * @param wrapV defines the texture wrap mode of the v coordinates
  41292. * @param wrapR defines the texture wrap mode of the r coordinates
  41293. */
  41294. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41295. /** @hidden */
  41296. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41297. width: number;
  41298. height: number;
  41299. layers?: number;
  41300. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  41301. /** @hidden */
  41302. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41303. /** @hidden */
  41304. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41305. /**
  41306. * Update a portion of an internal texture
  41307. * @param texture defines the texture to update
  41308. * @param imageData defines the data to store into the texture
  41309. * @param xOffset defines the x coordinates of the update rectangle
  41310. * @param yOffset defines the y coordinates of the update rectangle
  41311. * @param width defines the width of the update rectangle
  41312. * @param height defines the height of the update rectangle
  41313. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41314. * @param lod defines the lod level to update (0 by default)
  41315. */
  41316. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41317. /** @hidden */
  41318. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41319. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41320. private _prepareWebGLTexture;
  41321. /** @hidden */
  41322. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41323. private _getDepthStencilBuffer;
  41324. /** @hidden */
  41325. _releaseFramebufferObjects(texture: InternalTexture): void;
  41326. /** @hidden */
  41327. _releaseTexture(texture: InternalTexture): void;
  41328. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41329. protected _setProgram(program: WebGLProgram): void;
  41330. protected _boundUniforms: {
  41331. [key: number]: WebGLUniformLocation;
  41332. };
  41333. /**
  41334. * Binds an effect to the webGL context
  41335. * @param effect defines the effect to bind
  41336. */
  41337. bindSamplers(effect: Effect): void;
  41338. private _activateCurrentTexture;
  41339. /** @hidden */
  41340. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41341. /** @hidden */
  41342. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  41343. /**
  41344. * Unbind all textures from the webGL context
  41345. */
  41346. unbindAllTextures(): void;
  41347. /**
  41348. * Sets a texture to the according uniform.
  41349. * @param channel The texture channel
  41350. * @param uniform The uniform to set
  41351. * @param texture The texture to apply
  41352. * @param name The name of the uniform in the effect
  41353. */
  41354. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  41355. private _bindSamplerUniformToChannel;
  41356. private _getTextureWrapMode;
  41357. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  41358. /**
  41359. * Sets an array of texture to the webGL context
  41360. * @param channel defines the channel where the texture array must be set
  41361. * @param uniform defines the associated uniform location
  41362. * @param textures defines the array of textures to bind
  41363. * @param name name of the channel
  41364. */
  41365. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  41366. /** @hidden */
  41367. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41368. private _setTextureParameterFloat;
  41369. private _setTextureParameterInteger;
  41370. /**
  41371. * Unbind all vertex attributes from the webGL context
  41372. */
  41373. unbindAllAttributes(): void;
  41374. /**
  41375. * 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
  41376. */
  41377. releaseEffects(): void;
  41378. /**
  41379. * Dispose and release all associated resources
  41380. */
  41381. dispose(): void;
  41382. /**
  41383. * Attach a new callback raised when context lost event is fired
  41384. * @param callback defines the callback to call
  41385. */
  41386. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41387. /**
  41388. * Attach a new callback raised when context restored event is fired
  41389. * @param callback defines the callback to call
  41390. */
  41391. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41392. /**
  41393. * Get the current error code of the webGL context
  41394. * @returns the error code
  41395. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41396. */
  41397. getError(): number;
  41398. private _canRenderToFloatFramebuffer;
  41399. private _canRenderToHalfFloatFramebuffer;
  41400. private _canRenderToFramebuffer;
  41401. /** @hidden */
  41402. _getWebGLTextureType(type: number): number;
  41403. /** @hidden */
  41404. _getInternalFormat(format: number): number;
  41405. /** @hidden */
  41406. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41407. /** @hidden */
  41408. _getRGBAMultiSampleBufferFormat(type: number): number;
  41409. /** @hidden */
  41410. _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;
  41411. /**
  41412. * Loads a file from a url
  41413. * @param url url to load
  41414. * @param onSuccess callback called when the file successfully loads
  41415. * @param onProgress callback called while file is loading (if the server supports this mode)
  41416. * @param offlineProvider defines the offline provider for caching
  41417. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41418. * @param onError callback called when the file fails to load
  41419. * @returns a file request object
  41420. * @hidden
  41421. */
  41422. 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;
  41423. /**
  41424. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41425. * @param x defines the x coordinate of the rectangle where pixels must be read
  41426. * @param y defines the y coordinate of the rectangle where pixels must be read
  41427. * @param width defines the width of the rectangle where pixels must be read
  41428. * @param height defines the height of the rectangle where pixels must be read
  41429. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41430. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41431. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41432. */
  41433. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41434. private static _IsSupported;
  41435. private static _HasMajorPerformanceCaveat;
  41436. /**
  41437. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41438. */
  41439. static get IsSupported(): boolean;
  41440. /**
  41441. * Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
  41442. * @returns true if the engine can be created
  41443. * @ignorenaming
  41444. */
  41445. static isSupported(): boolean;
  41446. /**
  41447. * 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)
  41448. */
  41449. static get HasMajorPerformanceCaveat(): boolean;
  41450. /**
  41451. * Find the next highest power of two.
  41452. * @param x Number to start search from.
  41453. * @return Next highest power of two.
  41454. */
  41455. static CeilingPOT(x: number): number;
  41456. /**
  41457. * Find the next lowest power of two.
  41458. * @param x Number to start search from.
  41459. * @return Next lowest power of two.
  41460. */
  41461. static FloorPOT(x: number): number;
  41462. /**
  41463. * Find the nearest power of two.
  41464. * @param x Number to start search from.
  41465. * @return Next nearest power of two.
  41466. */
  41467. static NearestPOT(x: number): number;
  41468. /**
  41469. * Get the closest exponent of two
  41470. * @param value defines the value to approximate
  41471. * @param max defines the maximum value to return
  41472. * @param mode defines how to define the closest value
  41473. * @returns closest exponent of two of the given value
  41474. */
  41475. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41476. /**
  41477. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41478. * @param func - the function to be called
  41479. * @param requester - the object that will request the next frame. Falls back to window.
  41480. * @returns frame number
  41481. */
  41482. static QueueNewFrame(func: () => void, requester?: any): number;
  41483. /**
  41484. * Gets host document
  41485. * @returns the host document object
  41486. */
  41487. getHostDocument(): Nullable<Document>;
  41488. }
  41489. }
  41490. declare module BABYLON {
  41491. /**
  41492. * Defines the source of the internal texture
  41493. */
  41494. export enum InternalTextureSource {
  41495. /**
  41496. * The source of the texture data is unknown
  41497. */
  41498. Unknown = 0,
  41499. /**
  41500. * Texture data comes from an URL
  41501. */
  41502. Url = 1,
  41503. /**
  41504. * Texture data is only used for temporary storage
  41505. */
  41506. Temp = 2,
  41507. /**
  41508. * Texture data comes from raw data (ArrayBuffer)
  41509. */
  41510. Raw = 3,
  41511. /**
  41512. * Texture content is dynamic (video or dynamic texture)
  41513. */
  41514. Dynamic = 4,
  41515. /**
  41516. * Texture content is generated by rendering to it
  41517. */
  41518. RenderTarget = 5,
  41519. /**
  41520. * Texture content is part of a multi render target process
  41521. */
  41522. MultiRenderTarget = 6,
  41523. /**
  41524. * Texture data comes from a cube data file
  41525. */
  41526. Cube = 7,
  41527. /**
  41528. * Texture data comes from a raw cube data
  41529. */
  41530. CubeRaw = 8,
  41531. /**
  41532. * Texture data come from a prefiltered cube data file
  41533. */
  41534. CubePrefiltered = 9,
  41535. /**
  41536. * Texture content is raw 3D data
  41537. */
  41538. Raw3D = 10,
  41539. /**
  41540. * Texture content is raw 2D array data
  41541. */
  41542. Raw2DArray = 11,
  41543. /**
  41544. * Texture content is a depth texture
  41545. */
  41546. Depth = 12,
  41547. /**
  41548. * Texture data comes from a raw cube data encoded with RGBD
  41549. */
  41550. CubeRawRGBD = 13
  41551. }
  41552. /**
  41553. * Class used to store data associated with WebGL texture data for the engine
  41554. * This class should not be used directly
  41555. */
  41556. export class InternalTexture {
  41557. /** @hidden */
  41558. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41559. /**
  41560. * Defines if the texture is ready
  41561. */
  41562. isReady: boolean;
  41563. /**
  41564. * Defines if the texture is a cube texture
  41565. */
  41566. isCube: boolean;
  41567. /**
  41568. * Defines if the texture contains 3D data
  41569. */
  41570. is3D: boolean;
  41571. /**
  41572. * Defines if the texture contains 2D array data
  41573. */
  41574. is2DArray: boolean;
  41575. /**
  41576. * Defines if the texture contains multiview data
  41577. */
  41578. isMultiview: boolean;
  41579. /**
  41580. * Gets the URL used to load this texture
  41581. */
  41582. url: string;
  41583. /** @hidden */
  41584. _originalUrl: string;
  41585. /**
  41586. * Gets the sampling mode of the texture
  41587. */
  41588. samplingMode: number;
  41589. /**
  41590. * Gets a boolean indicating if the texture needs mipmaps generation
  41591. */
  41592. generateMipMaps: boolean;
  41593. /**
  41594. * Gets the number of samples used by the texture (WebGL2+ only)
  41595. */
  41596. samples: number;
  41597. /**
  41598. * Gets the type of the texture (int, float...)
  41599. */
  41600. type: number;
  41601. /**
  41602. * Gets the format of the texture (RGB, RGBA...)
  41603. */
  41604. format: number;
  41605. /**
  41606. * Observable called when the texture is loaded
  41607. */
  41608. onLoadedObservable: Observable<InternalTexture>;
  41609. /**
  41610. * Gets the width of the texture
  41611. */
  41612. width: number;
  41613. /**
  41614. * Gets the height of the texture
  41615. */
  41616. height: number;
  41617. /**
  41618. * Gets the depth of the texture
  41619. */
  41620. depth: number;
  41621. /**
  41622. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41623. */
  41624. baseWidth: number;
  41625. /**
  41626. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41627. */
  41628. baseHeight: number;
  41629. /**
  41630. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41631. */
  41632. baseDepth: number;
  41633. /**
  41634. * Gets a boolean indicating if the texture is inverted on Y axis
  41635. */
  41636. invertY: boolean;
  41637. /** @hidden */
  41638. _invertVScale: boolean;
  41639. /** @hidden */
  41640. _associatedChannel: number;
  41641. /** @hidden */
  41642. _source: InternalTextureSource;
  41643. /** @hidden */
  41644. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41645. /** @hidden */
  41646. _bufferView: Nullable<ArrayBufferView>;
  41647. /** @hidden */
  41648. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41649. /** @hidden */
  41650. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41651. /** @hidden */
  41652. _size: number;
  41653. /** @hidden */
  41654. _extension: string;
  41655. /** @hidden */
  41656. _files: Nullable<string[]>;
  41657. /** @hidden */
  41658. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41659. /** @hidden */
  41660. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41661. /** @hidden */
  41662. _framebuffer: Nullable<WebGLFramebuffer>;
  41663. /** @hidden */
  41664. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41665. /** @hidden */
  41666. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41667. /** @hidden */
  41668. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41669. /** @hidden */
  41670. _attachments: Nullable<number[]>;
  41671. /** @hidden */
  41672. _textureArray: Nullable<InternalTexture[]>;
  41673. /** @hidden */
  41674. _cachedCoordinatesMode: Nullable<number>;
  41675. /** @hidden */
  41676. _cachedWrapU: Nullable<number>;
  41677. /** @hidden */
  41678. _cachedWrapV: Nullable<number>;
  41679. /** @hidden */
  41680. _cachedWrapR: Nullable<number>;
  41681. /** @hidden */
  41682. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41683. /** @hidden */
  41684. _isDisabled: boolean;
  41685. /** @hidden */
  41686. _compression: Nullable<string>;
  41687. /** @hidden */
  41688. _generateStencilBuffer: boolean;
  41689. /** @hidden */
  41690. _generateDepthBuffer: boolean;
  41691. /** @hidden */
  41692. _comparisonFunction: number;
  41693. /** @hidden */
  41694. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41695. /** @hidden */
  41696. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41697. /** @hidden */
  41698. _sphericalPolynomialComputed: boolean;
  41699. /** @hidden */
  41700. _lodGenerationScale: number;
  41701. /** @hidden */
  41702. _lodGenerationOffset: number;
  41703. /** @hidden */
  41704. _depthStencilTexture: Nullable<InternalTexture>;
  41705. /** @hidden */
  41706. _colorTextureArray: Nullable<WebGLTexture>;
  41707. /** @hidden */
  41708. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41709. /** @hidden */
  41710. _lodTextureHigh: Nullable<BaseTexture>;
  41711. /** @hidden */
  41712. _lodTextureMid: Nullable<BaseTexture>;
  41713. /** @hidden */
  41714. _lodTextureLow: Nullable<BaseTexture>;
  41715. /** @hidden */
  41716. _isRGBD: boolean;
  41717. /** @hidden */
  41718. _linearSpecularLOD: boolean;
  41719. /** @hidden */
  41720. _irradianceTexture: Nullable<BaseTexture>;
  41721. /** @hidden */
  41722. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41723. /** @hidden */
  41724. _references: number;
  41725. /** @hidden */
  41726. _gammaSpace: Nullable<boolean>;
  41727. private _engine;
  41728. private _uniqueId;
  41729. private static _Counter;
  41730. /** Gets the unique id of the internal texture */
  41731. get uniqueId(): number;
  41732. /**
  41733. * Gets the Engine the texture belongs to.
  41734. * @returns The babylon engine
  41735. */
  41736. getEngine(): ThinEngine;
  41737. /**
  41738. * Gets the data source type of the texture
  41739. */
  41740. get source(): InternalTextureSource;
  41741. /**
  41742. * Creates a new InternalTexture
  41743. * @param engine defines the engine to use
  41744. * @param source defines the type of data that will be used
  41745. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41746. */
  41747. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41748. /**
  41749. * Increments the number of references (ie. the number of Texture that point to it)
  41750. */
  41751. incrementReferences(): void;
  41752. /**
  41753. * Change the size of the texture (not the size of the content)
  41754. * @param width defines the new width
  41755. * @param height defines the new height
  41756. * @param depth defines the new depth (1 by default)
  41757. */
  41758. updateSize(width: int, height: int, depth?: int): void;
  41759. /** @hidden */
  41760. _rebuild(): void;
  41761. /** @hidden */
  41762. _swapAndDie(target: InternalTexture): void;
  41763. /**
  41764. * Dispose the current allocated resources
  41765. */
  41766. dispose(): void;
  41767. }
  41768. }
  41769. declare module BABYLON {
  41770. /**
  41771. * Interface used to present a loading screen while loading a scene
  41772. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41773. */
  41774. export interface ILoadingScreen {
  41775. /**
  41776. * Function called to display the loading screen
  41777. */
  41778. displayLoadingUI: () => void;
  41779. /**
  41780. * Function called to hide the loading screen
  41781. */
  41782. hideLoadingUI: () => void;
  41783. /**
  41784. * Gets or sets the color to use for the background
  41785. */
  41786. loadingUIBackgroundColor: string;
  41787. /**
  41788. * Gets or sets the text to display while loading
  41789. */
  41790. loadingUIText: string;
  41791. }
  41792. /**
  41793. * Class used for the default loading screen
  41794. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41795. */
  41796. export class DefaultLoadingScreen implements ILoadingScreen {
  41797. private _renderingCanvas;
  41798. private _loadingText;
  41799. private _loadingDivBackgroundColor;
  41800. private _loadingDiv;
  41801. private _loadingTextDiv;
  41802. /** Gets or sets the logo url to use for the default loading screen */
  41803. static DefaultLogoUrl: string;
  41804. /** Gets or sets the spinner url to use for the default loading screen */
  41805. static DefaultSpinnerUrl: string;
  41806. /**
  41807. * Creates a new default loading screen
  41808. * @param _renderingCanvas defines the canvas used to render the scene
  41809. * @param _loadingText defines the default text to display
  41810. * @param _loadingDivBackgroundColor defines the default background color
  41811. */
  41812. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41813. /**
  41814. * Function called to display the loading screen
  41815. */
  41816. displayLoadingUI(): void;
  41817. /**
  41818. * Function called to hide the loading screen
  41819. */
  41820. hideLoadingUI(): void;
  41821. /**
  41822. * Gets or sets the text to display while loading
  41823. */
  41824. set loadingUIText(text: string);
  41825. get loadingUIText(): string;
  41826. /**
  41827. * Gets or sets the color to use for the background
  41828. */
  41829. get loadingUIBackgroundColor(): string;
  41830. set loadingUIBackgroundColor(color: string);
  41831. private _resizeLoadingUI;
  41832. }
  41833. }
  41834. declare module BABYLON {
  41835. /**
  41836. * Interface for any object that can request an animation frame
  41837. */
  41838. export interface ICustomAnimationFrameRequester {
  41839. /**
  41840. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41841. */
  41842. renderFunction?: Function;
  41843. /**
  41844. * Called to request the next frame to render to
  41845. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41846. */
  41847. requestAnimationFrame: Function;
  41848. /**
  41849. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41850. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41851. */
  41852. requestID?: number;
  41853. }
  41854. }
  41855. declare module BABYLON {
  41856. /**
  41857. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41858. */
  41859. export class PerformanceMonitor {
  41860. private _enabled;
  41861. private _rollingFrameTime;
  41862. private _lastFrameTimeMs;
  41863. /**
  41864. * constructor
  41865. * @param frameSampleSize The number of samples required to saturate the sliding window
  41866. */
  41867. constructor(frameSampleSize?: number);
  41868. /**
  41869. * Samples current frame
  41870. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41871. */
  41872. sampleFrame(timeMs?: number): void;
  41873. /**
  41874. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41875. */
  41876. get averageFrameTime(): number;
  41877. /**
  41878. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41879. */
  41880. get averageFrameTimeVariance(): number;
  41881. /**
  41882. * Returns the frame time of the most recent frame
  41883. */
  41884. get instantaneousFrameTime(): number;
  41885. /**
  41886. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41887. */
  41888. get averageFPS(): number;
  41889. /**
  41890. * Returns the average framerate in frames per second using the most recent frame time
  41891. */
  41892. get instantaneousFPS(): number;
  41893. /**
  41894. * Returns true if enough samples have been taken to completely fill the sliding window
  41895. */
  41896. get isSaturated(): boolean;
  41897. /**
  41898. * Enables contributions to the sliding window sample set
  41899. */
  41900. enable(): void;
  41901. /**
  41902. * Disables contributions to the sliding window sample set
  41903. * Samples will not be interpolated over the disabled period
  41904. */
  41905. disable(): void;
  41906. /**
  41907. * Returns true if sampling is enabled
  41908. */
  41909. get isEnabled(): boolean;
  41910. /**
  41911. * Resets performance monitor
  41912. */
  41913. reset(): void;
  41914. }
  41915. /**
  41916. * RollingAverage
  41917. *
  41918. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41919. */
  41920. export class RollingAverage {
  41921. /**
  41922. * Current average
  41923. */
  41924. average: number;
  41925. /**
  41926. * Current variance
  41927. */
  41928. variance: number;
  41929. protected _samples: Array<number>;
  41930. protected _sampleCount: number;
  41931. protected _pos: number;
  41932. protected _m2: number;
  41933. /**
  41934. * constructor
  41935. * @param length The number of samples required to saturate the sliding window
  41936. */
  41937. constructor(length: number);
  41938. /**
  41939. * Adds a sample to the sample set
  41940. * @param v The sample value
  41941. */
  41942. add(v: number): void;
  41943. /**
  41944. * Returns previously added values or null if outside of history or outside the sliding window domain
  41945. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41946. * @return Value previously recorded with add() or null if outside of range
  41947. */
  41948. history(i: number): number;
  41949. /**
  41950. * Returns true if enough samples have been taken to completely fill the sliding window
  41951. * @return true if sample-set saturated
  41952. */
  41953. isSaturated(): boolean;
  41954. /**
  41955. * Resets the rolling average (equivalent to 0 samples taken so far)
  41956. */
  41957. reset(): void;
  41958. /**
  41959. * Wraps a value around the sample range boundaries
  41960. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41961. * @return Wrapped position in sample range
  41962. */
  41963. protected _wrapPosition(i: number): number;
  41964. }
  41965. }
  41966. declare module BABYLON {
  41967. /**
  41968. * This class is used to track a performance counter which is number based.
  41969. * The user has access to many properties which give statistics of different nature.
  41970. *
  41971. * The implementer can track two kinds of Performance Counter: time and count.
  41972. * 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.
  41973. * 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.
  41974. */
  41975. export class PerfCounter {
  41976. /**
  41977. * Gets or sets a global boolean to turn on and off all the counters
  41978. */
  41979. static Enabled: boolean;
  41980. /**
  41981. * Returns the smallest value ever
  41982. */
  41983. get min(): number;
  41984. /**
  41985. * Returns the biggest value ever
  41986. */
  41987. get max(): number;
  41988. /**
  41989. * Returns the average value since the performance counter is running
  41990. */
  41991. get average(): number;
  41992. /**
  41993. * Returns the average value of the last second the counter was monitored
  41994. */
  41995. get lastSecAverage(): number;
  41996. /**
  41997. * Returns the current value
  41998. */
  41999. get current(): number;
  42000. /**
  42001. * Gets the accumulated total
  42002. */
  42003. get total(): number;
  42004. /**
  42005. * Gets the total value count
  42006. */
  42007. get count(): number;
  42008. /**
  42009. * Creates a new counter
  42010. */
  42011. constructor();
  42012. /**
  42013. * Call this method to start monitoring a new frame.
  42014. * 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.
  42015. */
  42016. fetchNewFrame(): void;
  42017. /**
  42018. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42019. * @param newCount the count value to add to the monitored count
  42020. * @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.
  42021. */
  42022. addCount(newCount: number, fetchResult: boolean): void;
  42023. /**
  42024. * Start monitoring this performance counter
  42025. */
  42026. beginMonitoring(): void;
  42027. /**
  42028. * Compute the time lapsed since the previous beginMonitoring() call.
  42029. * @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
  42030. */
  42031. endMonitoring(newFrame?: boolean): void;
  42032. private _fetchResult;
  42033. private _startMonitoringTime;
  42034. private _min;
  42035. private _max;
  42036. private _average;
  42037. private _current;
  42038. private _totalValueCount;
  42039. private _totalAccumulated;
  42040. private _lastSecAverage;
  42041. private _lastSecAccumulated;
  42042. private _lastSecTime;
  42043. private _lastSecValueCount;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. interface ThinEngine {
  42048. /** @hidden */
  42049. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  42050. /** @hidden */
  42051. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  42052. }
  42053. }
  42054. declare module BABYLON {
  42055. /**
  42056. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42058. */
  42059. export class Analyser {
  42060. /**
  42061. * Gets or sets the smoothing
  42062. * @ignorenaming
  42063. */
  42064. SMOOTHING: number;
  42065. /**
  42066. * Gets or sets the FFT table size
  42067. * @ignorenaming
  42068. */
  42069. FFT_SIZE: number;
  42070. /**
  42071. * Gets or sets the bar graph amplitude
  42072. * @ignorenaming
  42073. */
  42074. BARGRAPHAMPLITUDE: number;
  42075. /**
  42076. * Gets or sets the position of the debug canvas
  42077. * @ignorenaming
  42078. */
  42079. DEBUGCANVASPOS: {
  42080. x: number;
  42081. y: number;
  42082. };
  42083. /**
  42084. * Gets or sets the debug canvas size
  42085. * @ignorenaming
  42086. */
  42087. DEBUGCANVASSIZE: {
  42088. width: number;
  42089. height: number;
  42090. };
  42091. private _byteFreqs;
  42092. private _byteTime;
  42093. private _floatFreqs;
  42094. private _webAudioAnalyser;
  42095. private _debugCanvas;
  42096. private _debugCanvasContext;
  42097. private _scene;
  42098. private _registerFunc;
  42099. private _audioEngine;
  42100. /**
  42101. * Creates a new analyser
  42102. * @param scene defines hosting scene
  42103. */
  42104. constructor(scene: Scene);
  42105. /**
  42106. * Get the number of data values you will have to play with for the visualization
  42107. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42108. * @returns a number
  42109. */
  42110. getFrequencyBinCount(): number;
  42111. /**
  42112. * Gets the current frequency data as a byte array
  42113. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42114. * @returns a Uint8Array
  42115. */
  42116. getByteFrequencyData(): Uint8Array;
  42117. /**
  42118. * Gets the current waveform as a byte array
  42119. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42120. * @returns a Uint8Array
  42121. */
  42122. getByteTimeDomainData(): Uint8Array;
  42123. /**
  42124. * Gets the current frequency data as a float array
  42125. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42126. * @returns a Float32Array
  42127. */
  42128. getFloatFrequencyData(): Float32Array;
  42129. /**
  42130. * Renders the debug canvas
  42131. */
  42132. drawDebugCanvas(): void;
  42133. /**
  42134. * Stops rendering the debug canvas and removes it
  42135. */
  42136. stopDebugCanvas(): void;
  42137. /**
  42138. * Connects two audio nodes
  42139. * @param inputAudioNode defines first node to connect
  42140. * @param outputAudioNode defines second node to connect
  42141. */
  42142. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42143. /**
  42144. * Releases all associated resources
  42145. */
  42146. dispose(): void;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /**
  42151. * This represents an audio engine and it is responsible
  42152. * to play, synchronize and analyse sounds throughout the application.
  42153. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42154. */
  42155. export interface IAudioEngine extends IDisposable {
  42156. /**
  42157. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42158. */
  42159. readonly canUseWebAudio: boolean;
  42160. /**
  42161. * Gets the current AudioContext if available.
  42162. */
  42163. readonly audioContext: Nullable<AudioContext>;
  42164. /**
  42165. * The master gain node defines the global audio volume of your audio engine.
  42166. */
  42167. readonly masterGain: GainNode;
  42168. /**
  42169. * Gets whether or not mp3 are supported by your browser.
  42170. */
  42171. readonly isMP3supported: boolean;
  42172. /**
  42173. * Gets whether or not ogg are supported by your browser.
  42174. */
  42175. readonly isOGGsupported: boolean;
  42176. /**
  42177. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42178. * @ignoreNaming
  42179. */
  42180. WarnedWebAudioUnsupported: boolean;
  42181. /**
  42182. * Defines if the audio engine relies on a custom unlocked button.
  42183. * In this case, the embedded button will not be displayed.
  42184. */
  42185. useCustomUnlockedButton: boolean;
  42186. /**
  42187. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42188. */
  42189. readonly unlocked: boolean;
  42190. /**
  42191. * Event raised when audio has been unlocked on the browser.
  42192. */
  42193. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42194. /**
  42195. * Event raised when audio has been locked on the browser.
  42196. */
  42197. onAudioLockedObservable: Observable<IAudioEngine>;
  42198. /**
  42199. * Flags the audio engine in Locked state.
  42200. * This happens due to new browser policies preventing audio to autoplay.
  42201. */
  42202. lock(): void;
  42203. /**
  42204. * Unlocks the audio engine once a user action has been done on the dom.
  42205. * This is helpful to resume play once browser policies have been satisfied.
  42206. */
  42207. unlock(): void;
  42208. /**
  42209. * Gets the global volume sets on the master gain.
  42210. * @returns the global volume if set or -1 otherwise
  42211. */
  42212. getGlobalVolume(): number;
  42213. /**
  42214. * Sets the global volume of your experience (sets on the master gain).
  42215. * @param newVolume Defines the new global volume of the application
  42216. */
  42217. setGlobalVolume(newVolume: number): void;
  42218. /**
  42219. * Connect the audio engine to an audio analyser allowing some amazing
  42220. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  42221. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42222. * @param analyser The analyser to connect to the engine
  42223. */
  42224. connectToAnalyser(analyser: Analyser): void;
  42225. }
  42226. }
  42227. declare module BABYLON {
  42228. /**
  42229. * Defines the interface used by display changed events
  42230. */
  42231. export interface IDisplayChangedEventArgs {
  42232. /** Gets the vrDisplay object (if any) */
  42233. vrDisplay: Nullable<any>;
  42234. /** Gets a boolean indicating if webVR is supported */
  42235. vrSupported: boolean;
  42236. }
  42237. /**
  42238. * Defines the interface used by objects containing a viewport (like a camera)
  42239. */
  42240. interface IViewportOwnerLike {
  42241. /**
  42242. * Gets or sets the viewport
  42243. */
  42244. viewport: IViewportLike;
  42245. }
  42246. /**
  42247. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42248. */
  42249. export class Engine extends ThinEngine {
  42250. /** Defines that alpha blending is disabled */
  42251. static readonly ALPHA_DISABLE: number;
  42252. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42253. static readonly ALPHA_ADD: number;
  42254. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42255. static readonly ALPHA_COMBINE: number;
  42256. /** Defines that alpha blending to DEST - SRC * DEST */
  42257. static readonly ALPHA_SUBTRACT: number;
  42258. /** Defines that alpha blending to SRC * DEST */
  42259. static readonly ALPHA_MULTIPLY: number;
  42260. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42261. static readonly ALPHA_MAXIMIZED: number;
  42262. /** Defines that alpha blending to SRC + DEST */
  42263. static readonly ALPHA_ONEONE: number;
  42264. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42265. static readonly ALPHA_PREMULTIPLIED: number;
  42266. /**
  42267. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42268. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42269. */
  42270. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42271. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42272. static readonly ALPHA_INTERPOLATE: number;
  42273. /**
  42274. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42275. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42276. */
  42277. static readonly ALPHA_SCREENMODE: number;
  42278. /** Defines that the resource is not delayed*/
  42279. static readonly DELAYLOADSTATE_NONE: number;
  42280. /** Defines that the resource was successfully delay loaded */
  42281. static readonly DELAYLOADSTATE_LOADED: number;
  42282. /** Defines that the resource is currently delay loading */
  42283. static readonly DELAYLOADSTATE_LOADING: number;
  42284. /** Defines that the resource is delayed and has not started loading */
  42285. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42286. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42287. static readonly NEVER: number;
  42288. /** 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 */
  42289. static readonly ALWAYS: number;
  42290. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42291. static readonly LESS: number;
  42292. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42293. static readonly EQUAL: number;
  42294. /** 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 */
  42295. static readonly LEQUAL: number;
  42296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42297. static readonly GREATER: number;
  42298. /** 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 */
  42299. static readonly GEQUAL: number;
  42300. /** 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 */
  42301. static readonly NOTEQUAL: number;
  42302. /** Passed to stencilOperation to specify that stencil value must be kept */
  42303. static readonly KEEP: number;
  42304. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42305. static readonly REPLACE: number;
  42306. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42307. static readonly INCR: number;
  42308. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42309. static readonly DECR: number;
  42310. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42311. static readonly INVERT: number;
  42312. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42313. static readonly INCR_WRAP: number;
  42314. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42315. static readonly DECR_WRAP: number;
  42316. /** Texture is not repeating outside of 0..1 UVs */
  42317. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42318. /** Texture is repeating outside of 0..1 UVs */
  42319. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42320. /** Texture is repeating and mirrored */
  42321. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42322. /** ALPHA */
  42323. static readonly TEXTUREFORMAT_ALPHA: number;
  42324. /** LUMINANCE */
  42325. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42326. /** LUMINANCE_ALPHA */
  42327. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42328. /** RGB */
  42329. static readonly TEXTUREFORMAT_RGB: number;
  42330. /** RGBA */
  42331. static readonly TEXTUREFORMAT_RGBA: number;
  42332. /** RED */
  42333. static readonly TEXTUREFORMAT_RED: number;
  42334. /** RED (2nd reference) */
  42335. static readonly TEXTUREFORMAT_R: number;
  42336. /** RG */
  42337. static readonly TEXTUREFORMAT_RG: number;
  42338. /** RED_INTEGER */
  42339. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42340. /** RED_INTEGER (2nd reference) */
  42341. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42342. /** RG_INTEGER */
  42343. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42344. /** RGB_INTEGER */
  42345. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42346. /** RGBA_INTEGER */
  42347. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42348. /** UNSIGNED_BYTE */
  42349. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42350. /** UNSIGNED_BYTE (2nd reference) */
  42351. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42352. /** FLOAT */
  42353. static readonly TEXTURETYPE_FLOAT: number;
  42354. /** HALF_FLOAT */
  42355. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42356. /** BYTE */
  42357. static readonly TEXTURETYPE_BYTE: number;
  42358. /** SHORT */
  42359. static readonly TEXTURETYPE_SHORT: number;
  42360. /** UNSIGNED_SHORT */
  42361. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42362. /** INT */
  42363. static readonly TEXTURETYPE_INT: number;
  42364. /** UNSIGNED_INT */
  42365. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42366. /** UNSIGNED_SHORT_4_4_4_4 */
  42367. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42368. /** UNSIGNED_SHORT_5_5_5_1 */
  42369. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42370. /** UNSIGNED_SHORT_5_6_5 */
  42371. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42372. /** UNSIGNED_INT_2_10_10_10_REV */
  42373. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42374. /** UNSIGNED_INT_24_8 */
  42375. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42376. /** UNSIGNED_INT_10F_11F_11F_REV */
  42377. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42378. /** UNSIGNED_INT_5_9_9_9_REV */
  42379. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42380. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42381. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42382. /** nearest is mag = nearest and min = nearest and mip = none */
  42383. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42384. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42385. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42386. /** Trilinear is mag = linear and min = linear and mip = linear */
  42387. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42388. /** nearest is mag = nearest and min = nearest and mip = linear */
  42389. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42390. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42391. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42392. /** Trilinear is mag = linear and min = linear and mip = linear */
  42393. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42394. /** mag = nearest and min = nearest and mip = nearest */
  42395. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42396. /** mag = nearest and min = linear and mip = nearest */
  42397. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42398. /** mag = nearest and min = linear and mip = linear */
  42399. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42400. /** mag = nearest and min = linear and mip = none */
  42401. static readonly TEXTURE_NEAREST_LINEAR: number;
  42402. /** mag = nearest and min = nearest and mip = none */
  42403. static readonly TEXTURE_NEAREST_NEAREST: number;
  42404. /** mag = linear and min = nearest and mip = nearest */
  42405. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42406. /** mag = linear and min = nearest and mip = linear */
  42407. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42408. /** mag = linear and min = linear and mip = none */
  42409. static readonly TEXTURE_LINEAR_LINEAR: number;
  42410. /** mag = linear and min = nearest and mip = none */
  42411. static readonly TEXTURE_LINEAR_NEAREST: number;
  42412. /** Explicit coordinates mode */
  42413. static readonly TEXTURE_EXPLICIT_MODE: number;
  42414. /** Spherical coordinates mode */
  42415. static readonly TEXTURE_SPHERICAL_MODE: number;
  42416. /** Planar coordinates mode */
  42417. static readonly TEXTURE_PLANAR_MODE: number;
  42418. /** Cubic coordinates mode */
  42419. static readonly TEXTURE_CUBIC_MODE: number;
  42420. /** Projection coordinates mode */
  42421. static readonly TEXTURE_PROJECTION_MODE: number;
  42422. /** Skybox coordinates mode */
  42423. static readonly TEXTURE_SKYBOX_MODE: number;
  42424. /** Inverse Cubic coordinates mode */
  42425. static readonly TEXTURE_INVCUBIC_MODE: number;
  42426. /** Equirectangular coordinates mode */
  42427. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42428. /** Equirectangular Fixed coordinates mode */
  42429. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42430. /** Equirectangular Fixed Mirrored coordinates mode */
  42431. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42432. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42433. static readonly SCALEMODE_FLOOR: number;
  42434. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42435. static readonly SCALEMODE_NEAREST: number;
  42436. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42437. static readonly SCALEMODE_CEILING: number;
  42438. /**
  42439. * Returns the current npm package of the sdk
  42440. */
  42441. static get NpmPackage(): string;
  42442. /**
  42443. * Returns the current version of the framework
  42444. */
  42445. static get Version(): string;
  42446. /** Gets the list of created engines */
  42447. static get Instances(): Engine[];
  42448. /**
  42449. * Gets the latest created engine
  42450. */
  42451. static get LastCreatedEngine(): Nullable<Engine>;
  42452. /**
  42453. * Gets the latest created scene
  42454. */
  42455. static get LastCreatedScene(): Nullable<Scene>;
  42456. /**
  42457. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42458. * @param flag defines which part of the materials must be marked as dirty
  42459. * @param predicate defines a predicate used to filter which materials should be affected
  42460. */
  42461. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42462. /**
  42463. * Method called to create the default loading screen.
  42464. * This can be overridden in your own app.
  42465. * @param canvas The rendering canvas element
  42466. * @returns The loading screen
  42467. */
  42468. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42469. /**
  42470. * Method called to create the default rescale post process on each engine.
  42471. */
  42472. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42473. /**
  42474. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42475. **/
  42476. enableOfflineSupport: boolean;
  42477. /**
  42478. * 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)
  42479. **/
  42480. disableManifestCheck: boolean;
  42481. /**
  42482. * Gets the list of created scenes
  42483. */
  42484. scenes: Scene[];
  42485. /**
  42486. * Event raised when a new scene is created
  42487. */
  42488. onNewSceneAddedObservable: Observable<Scene>;
  42489. /**
  42490. * Gets the list of created postprocesses
  42491. */
  42492. postProcesses: PostProcess[];
  42493. /**
  42494. * Gets a boolean indicating if the pointer is currently locked
  42495. */
  42496. isPointerLock: boolean;
  42497. /**
  42498. * Observable event triggered each time the rendering canvas is resized
  42499. */
  42500. onResizeObservable: Observable<Engine>;
  42501. /**
  42502. * Observable event triggered each time the canvas loses focus
  42503. */
  42504. onCanvasBlurObservable: Observable<Engine>;
  42505. /**
  42506. * Observable event triggered each time the canvas gains focus
  42507. */
  42508. onCanvasFocusObservable: Observable<Engine>;
  42509. /**
  42510. * Observable event triggered each time the canvas receives pointerout event
  42511. */
  42512. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42513. /**
  42514. * Observable raised when the engine begins a new frame
  42515. */
  42516. onBeginFrameObservable: Observable<Engine>;
  42517. /**
  42518. * If set, will be used to request the next animation frame for the render loop
  42519. */
  42520. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42521. /**
  42522. * Observable raised when the engine ends the current frame
  42523. */
  42524. onEndFrameObservable: Observable<Engine>;
  42525. /**
  42526. * Observable raised when the engine is about to compile a shader
  42527. */
  42528. onBeforeShaderCompilationObservable: Observable<Engine>;
  42529. /**
  42530. * Observable raised when the engine has just compiled a shader
  42531. */
  42532. onAfterShaderCompilationObservable: Observable<Engine>;
  42533. /**
  42534. * Gets the audio engine
  42535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42536. * @ignorenaming
  42537. */
  42538. static audioEngine: IAudioEngine;
  42539. /**
  42540. * Default AudioEngine factory responsible of creating the Audio Engine.
  42541. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42542. */
  42543. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42544. /**
  42545. * Default offline support factory responsible of creating a tool used to store data locally.
  42546. * By default, this will create a Database object if the workload has been embedded.
  42547. */
  42548. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42549. private _loadingScreen;
  42550. private _pointerLockRequested;
  42551. private _rescalePostProcess;
  42552. protected _deterministicLockstep: boolean;
  42553. protected _lockstepMaxSteps: number;
  42554. protected _timeStep: number;
  42555. protected get _supportsHardwareTextureRescaling(): boolean;
  42556. private _fps;
  42557. private _deltaTime;
  42558. /** @hidden */
  42559. _drawCalls: PerfCounter;
  42560. /** 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 */
  42561. canvasTabIndex: number;
  42562. /**
  42563. * Turn this value on if you want to pause FPS computation when in background
  42564. */
  42565. disablePerformanceMonitorInBackground: boolean;
  42566. private _performanceMonitor;
  42567. /**
  42568. * Gets the performance monitor attached to this engine
  42569. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42570. */
  42571. get performanceMonitor(): PerformanceMonitor;
  42572. private _onFocus;
  42573. private _onBlur;
  42574. private _onCanvasPointerOut;
  42575. private _onCanvasBlur;
  42576. private _onCanvasFocus;
  42577. private _onFullscreenChange;
  42578. private _onPointerLockChange;
  42579. /**
  42580. * Gets the HTML element used to attach event listeners
  42581. * @returns a HTML element
  42582. */
  42583. getInputElement(): Nullable<HTMLElement>;
  42584. /**
  42585. * Creates a new engine
  42586. * @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
  42587. * @param antialias defines enable antialiasing (default: false)
  42588. * @param options defines further options to be sent to the getContext() function
  42589. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42590. */
  42591. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42592. /**
  42593. * Shared initialization across engines types.
  42594. * @param canvas The canvas associated with this instance of the engine.
  42595. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42596. * @param audioEngine Defines if an audio engine should be created by default
  42597. */
  42598. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42599. /**
  42600. * Gets current aspect ratio
  42601. * @param viewportOwner defines the camera to use to get the aspect ratio
  42602. * @param useScreen defines if screen size must be used (or the current render target if any)
  42603. * @returns a number defining the aspect ratio
  42604. */
  42605. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42606. /**
  42607. * Gets current screen aspect ratio
  42608. * @returns a number defining the aspect ratio
  42609. */
  42610. getScreenAspectRatio(): number;
  42611. /**
  42612. * Gets the client rect of the HTML canvas attached with the current webGL context
  42613. * @returns a client rectangle
  42614. */
  42615. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42616. /**
  42617. * Gets the client rect of the HTML element used for events
  42618. * @returns a client rectangle
  42619. */
  42620. getInputElementClientRect(): Nullable<ClientRect>;
  42621. /**
  42622. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42623. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42624. * @returns true if engine is in deterministic lock step mode
  42625. */
  42626. isDeterministicLockStep(): boolean;
  42627. /**
  42628. * Gets the max steps when engine is running in deterministic lock step
  42629. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42630. * @returns the max steps
  42631. */
  42632. getLockstepMaxSteps(): number;
  42633. /**
  42634. * Returns the time in ms between steps when using deterministic lock step.
  42635. * @returns time step in (ms)
  42636. */
  42637. getTimeStep(): number;
  42638. /**
  42639. * Force the mipmap generation for the given render target texture
  42640. * @param texture defines the render target texture to use
  42641. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42642. */
  42643. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42644. /** States */
  42645. /**
  42646. * Set various states to the webGL context
  42647. * @param culling defines backface culling state
  42648. * @param zOffset defines the value to apply to zOffset (0 by default)
  42649. * @param force defines if states must be applied even if cache is up to date
  42650. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42651. */
  42652. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42653. /**
  42654. * Set the z offset to apply to current rendering
  42655. * @param value defines the offset to apply
  42656. */
  42657. setZOffset(value: number): void;
  42658. /**
  42659. * Gets the current value of the zOffset
  42660. * @returns the current zOffset state
  42661. */
  42662. getZOffset(): number;
  42663. /**
  42664. * Gets a boolean indicating if depth testing is enabled
  42665. * @returns the current state
  42666. */
  42667. getDepthBuffer(): boolean;
  42668. /**
  42669. * Enable or disable depth buffering
  42670. * @param enable defines the state to set
  42671. */
  42672. setDepthBuffer(enable: boolean): void;
  42673. /**
  42674. * Gets a boolean indicating if depth writing is enabled
  42675. * @returns the current depth writing state
  42676. */
  42677. getDepthWrite(): boolean;
  42678. /**
  42679. * Enable or disable depth writing
  42680. * @param enable defines the state to set
  42681. */
  42682. setDepthWrite(enable: boolean): void;
  42683. /**
  42684. * Gets a boolean indicating if stencil buffer is enabled
  42685. * @returns the current stencil buffer state
  42686. */
  42687. getStencilBuffer(): boolean;
  42688. /**
  42689. * Enable or disable the stencil buffer
  42690. * @param enable defines if the stencil buffer must be enabled or disabled
  42691. */
  42692. setStencilBuffer(enable: boolean): void;
  42693. /**
  42694. * Gets the current stencil mask
  42695. * @returns a number defining the new stencil mask to use
  42696. */
  42697. getStencilMask(): number;
  42698. /**
  42699. * Sets the current stencil mask
  42700. * @param mask defines the new stencil mask to use
  42701. */
  42702. setStencilMask(mask: number): void;
  42703. /**
  42704. * Gets the current stencil function
  42705. * @returns a number defining the stencil function to use
  42706. */
  42707. getStencilFunction(): number;
  42708. /**
  42709. * Gets the current stencil reference value
  42710. * @returns a number defining the stencil reference value to use
  42711. */
  42712. getStencilFunctionReference(): number;
  42713. /**
  42714. * Gets the current stencil mask
  42715. * @returns a number defining the stencil mask to use
  42716. */
  42717. getStencilFunctionMask(): number;
  42718. /**
  42719. * Sets the current stencil function
  42720. * @param stencilFunc defines the new stencil function to use
  42721. */
  42722. setStencilFunction(stencilFunc: number): void;
  42723. /**
  42724. * Sets the current stencil reference
  42725. * @param reference defines the new stencil reference to use
  42726. */
  42727. setStencilFunctionReference(reference: number): void;
  42728. /**
  42729. * Sets the current stencil mask
  42730. * @param mask defines the new stencil mask to use
  42731. */
  42732. setStencilFunctionMask(mask: number): void;
  42733. /**
  42734. * Gets the current stencil operation when stencil fails
  42735. * @returns a number defining stencil operation to use when stencil fails
  42736. */
  42737. getStencilOperationFail(): number;
  42738. /**
  42739. * Gets the current stencil operation when depth fails
  42740. * @returns a number defining stencil operation to use when depth fails
  42741. */
  42742. getStencilOperationDepthFail(): number;
  42743. /**
  42744. * Gets the current stencil operation when stencil passes
  42745. * @returns a number defining stencil operation to use when stencil passes
  42746. */
  42747. getStencilOperationPass(): number;
  42748. /**
  42749. * Sets the stencil operation to use when stencil fails
  42750. * @param operation defines the stencil operation to use when stencil fails
  42751. */
  42752. setStencilOperationFail(operation: number): void;
  42753. /**
  42754. * Sets the stencil operation to use when depth fails
  42755. * @param operation defines the stencil operation to use when depth fails
  42756. */
  42757. setStencilOperationDepthFail(operation: number): void;
  42758. /**
  42759. * Sets the stencil operation to use when stencil passes
  42760. * @param operation defines the stencil operation to use when stencil passes
  42761. */
  42762. setStencilOperationPass(operation: number): void;
  42763. /**
  42764. * Sets a boolean indicating if the dithering state is enabled or disabled
  42765. * @param value defines the dithering state
  42766. */
  42767. setDitheringState(value: boolean): void;
  42768. /**
  42769. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42770. * @param value defines the rasterizer state
  42771. */
  42772. setRasterizerState(value: boolean): void;
  42773. /**
  42774. * Gets the current depth function
  42775. * @returns a number defining the depth function
  42776. */
  42777. getDepthFunction(): Nullable<number>;
  42778. /**
  42779. * Sets the current depth function
  42780. * @param depthFunc defines the function to use
  42781. */
  42782. setDepthFunction(depthFunc: number): void;
  42783. /**
  42784. * Sets the current depth function to GREATER
  42785. */
  42786. setDepthFunctionToGreater(): void;
  42787. /**
  42788. * Sets the current depth function to GEQUAL
  42789. */
  42790. setDepthFunctionToGreaterOrEqual(): void;
  42791. /**
  42792. * Sets the current depth function to LESS
  42793. */
  42794. setDepthFunctionToLess(): void;
  42795. /**
  42796. * Sets the current depth function to LEQUAL
  42797. */
  42798. setDepthFunctionToLessOrEqual(): void;
  42799. private _cachedStencilBuffer;
  42800. private _cachedStencilFunction;
  42801. private _cachedStencilMask;
  42802. private _cachedStencilOperationPass;
  42803. private _cachedStencilOperationFail;
  42804. private _cachedStencilOperationDepthFail;
  42805. private _cachedStencilReference;
  42806. /**
  42807. * Caches the the state of the stencil buffer
  42808. */
  42809. cacheStencilState(): void;
  42810. /**
  42811. * Restores the state of the stencil buffer
  42812. */
  42813. restoreStencilState(): void;
  42814. /**
  42815. * Directly set the WebGL Viewport
  42816. * @param x defines the x coordinate of the viewport (in screen space)
  42817. * @param y defines the y coordinate of the viewport (in screen space)
  42818. * @param width defines the width of the viewport (in screen space)
  42819. * @param height defines the height of the viewport (in screen space)
  42820. * @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
  42821. */
  42822. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42823. /**
  42824. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42825. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42826. * @param y defines the y-coordinate of the corner of the clear rectangle
  42827. * @param width defines the width of the clear rectangle
  42828. * @param height defines the height of the clear rectangle
  42829. * @param clearColor defines the clear color
  42830. */
  42831. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42832. /**
  42833. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42834. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42835. * @param y defines the y-coordinate of the corner of the clear rectangle
  42836. * @param width defines the width of the clear rectangle
  42837. * @param height defines the height of the clear rectangle
  42838. */
  42839. enableScissor(x: number, y: number, width: number, height: number): void;
  42840. /**
  42841. * Disable previously set scissor test rectangle
  42842. */
  42843. disableScissor(): void;
  42844. protected _reportDrawCall(): void;
  42845. /**
  42846. * Initializes a webVR display and starts listening to display change events
  42847. * The onVRDisplayChangedObservable will be notified upon these changes
  42848. * @returns The onVRDisplayChangedObservable
  42849. */
  42850. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42851. /** @hidden */
  42852. _prepareVRComponent(): void;
  42853. /** @hidden */
  42854. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42855. /** @hidden */
  42856. _submitVRFrame(): void;
  42857. /**
  42858. * Call this function to leave webVR mode
  42859. * Will do nothing if webVR is not supported or if there is no webVR device
  42860. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42861. */
  42862. disableVR(): void;
  42863. /**
  42864. * Gets a boolean indicating that the system is in VR mode and is presenting
  42865. * @returns true if VR mode is engaged
  42866. */
  42867. isVRPresenting(): boolean;
  42868. /** @hidden */
  42869. _requestVRFrame(): void;
  42870. /** @hidden */
  42871. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42872. /**
  42873. * Gets the source code of the vertex shader associated with a specific webGL program
  42874. * @param program defines the program to use
  42875. * @returns a string containing the source code of the vertex shader associated with the program
  42876. */
  42877. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42878. /**
  42879. * Gets the source code of the fragment shader associated with a specific webGL program
  42880. * @param program defines the program to use
  42881. * @returns a string containing the source code of the fragment shader associated with the program
  42882. */
  42883. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42884. /**
  42885. * Sets a depth stencil texture from a render target to the according uniform.
  42886. * @param channel The texture channel
  42887. * @param uniform The uniform to set
  42888. * @param texture The render target texture containing the depth stencil texture to apply
  42889. * @param name The texture name
  42890. */
  42891. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42892. /**
  42893. * Sets a texture to the webGL context from a postprocess
  42894. * @param channel defines the channel to use
  42895. * @param postProcess defines the source postprocess
  42896. * @param name name of the channel
  42897. */
  42898. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42899. /**
  42900. * Binds the output of the passed in post process to the texture channel specified
  42901. * @param channel The channel the texture should be bound to
  42902. * @param postProcess The post process which's output should be bound
  42903. * @param name name of the channel
  42904. */
  42905. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42906. protected _rebuildBuffers(): void;
  42907. /** @hidden */
  42908. _renderFrame(): void;
  42909. _renderLoop(): void;
  42910. /** @hidden */
  42911. _renderViews(): boolean;
  42912. /**
  42913. * Toggle full screen mode
  42914. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42915. */
  42916. switchFullscreen(requestPointerLock: boolean): void;
  42917. /**
  42918. * Enters full screen mode
  42919. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42920. */
  42921. enterFullscreen(requestPointerLock: boolean): void;
  42922. /**
  42923. * Exits full screen mode
  42924. */
  42925. exitFullscreen(): void;
  42926. /**
  42927. * Enters Pointerlock mode
  42928. */
  42929. enterPointerlock(): void;
  42930. /**
  42931. * Exits Pointerlock mode
  42932. */
  42933. exitPointerlock(): void;
  42934. /**
  42935. * Begin a new frame
  42936. */
  42937. beginFrame(): void;
  42938. /**
  42939. * End the current frame
  42940. */
  42941. endFrame(): void;
  42942. /**
  42943. * Resize the view according to the canvas' size
  42944. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42945. */
  42946. resize(forceSetSize?: boolean): void;
  42947. /**
  42948. * Force a specific size of the canvas
  42949. * @param width defines the new canvas' width
  42950. * @param height defines the new canvas' height
  42951. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42952. * @returns true if the size was changed
  42953. */
  42954. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42955. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42956. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42957. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42958. _releaseTexture(texture: InternalTexture): void;
  42959. /**
  42960. * @hidden
  42961. * Rescales a texture
  42962. * @param source input texture
  42963. * @param destination destination texture
  42964. * @param scene scene to use to render the resize
  42965. * @param internalFormat format to use when resizing
  42966. * @param onComplete callback to be called when resize has completed
  42967. */
  42968. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42969. /**
  42970. * Gets the current framerate
  42971. * @returns a number representing the framerate
  42972. */
  42973. getFps(): number;
  42974. /**
  42975. * Gets the time spent between current and previous frame
  42976. * @returns a number representing the delta time in ms
  42977. */
  42978. getDeltaTime(): number;
  42979. private _measureFps;
  42980. /** @hidden */
  42981. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42982. /**
  42983. * Updates the sample count of a render target texture
  42984. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42985. * @param texture defines the texture to update
  42986. * @param samples defines the sample count to set
  42987. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42988. */
  42989. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42990. /**
  42991. * Updates a depth texture Comparison Mode and Function.
  42992. * If the comparison Function is equal to 0, the mode will be set to none.
  42993. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42994. * @param texture The texture to set the comparison function for
  42995. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42996. */
  42997. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42998. /**
  42999. * Creates a webGL buffer to use with instantiation
  43000. * @param capacity defines the size of the buffer
  43001. * @returns the webGL buffer
  43002. */
  43003. createInstancesBuffer(capacity: number): DataBuffer;
  43004. /**
  43005. * Delete a webGL buffer used with instantiation
  43006. * @param buffer defines the webGL buffer to delete
  43007. */
  43008. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43009. private _clientWaitAsync;
  43010. /** @hidden */
  43011. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  43012. dispose(): void;
  43013. private _disableTouchAction;
  43014. /**
  43015. * Display the loading screen
  43016. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43017. */
  43018. displayLoadingUI(): void;
  43019. /**
  43020. * Hide the loading screen
  43021. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43022. */
  43023. hideLoadingUI(): void;
  43024. /**
  43025. * Gets the current loading screen object
  43026. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43027. */
  43028. get loadingScreen(): ILoadingScreen;
  43029. /**
  43030. * Sets the current loading screen object
  43031. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43032. */
  43033. set loadingScreen(loadingScreen: ILoadingScreen);
  43034. /**
  43035. * Sets the current loading screen text
  43036. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43037. */
  43038. set loadingUIText(text: string);
  43039. /**
  43040. * Sets the current loading screen background color
  43041. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43042. */
  43043. set loadingUIBackgroundColor(color: string);
  43044. /** Pointerlock and fullscreen */
  43045. /**
  43046. * Ask the browser to promote the current element to pointerlock mode
  43047. * @param element defines the DOM element to promote
  43048. */
  43049. static _RequestPointerlock(element: HTMLElement): void;
  43050. /**
  43051. * Asks the browser to exit pointerlock mode
  43052. */
  43053. static _ExitPointerlock(): void;
  43054. /**
  43055. * Ask the browser to promote the current element to fullscreen rendering mode
  43056. * @param element defines the DOM element to promote
  43057. */
  43058. static _RequestFullscreen(element: HTMLElement): void;
  43059. /**
  43060. * Asks the browser to exit fullscreen mode
  43061. */
  43062. static _ExitFullscreen(): void;
  43063. }
  43064. }
  43065. declare module BABYLON {
  43066. /**
  43067. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43068. * during the life time of the application.
  43069. */
  43070. export class EngineStore {
  43071. /** Gets the list of created engines */
  43072. static Instances: Engine[];
  43073. /** @hidden */
  43074. static _LastCreatedScene: Nullable<Scene>;
  43075. /**
  43076. * Gets the latest created engine
  43077. */
  43078. static get LastCreatedEngine(): Nullable<Engine>;
  43079. /**
  43080. * Gets the latest created scene
  43081. */
  43082. static get LastCreatedScene(): Nullable<Scene>;
  43083. /**
  43084. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43085. * @ignorenaming
  43086. */
  43087. static UseFallbackTexture: boolean;
  43088. /**
  43089. * Texture content used if a texture cannot loaded
  43090. * @ignorenaming
  43091. */
  43092. static FallbackTexture: string;
  43093. }
  43094. }
  43095. declare module BABYLON {
  43096. /**
  43097. * Helper class that provides a small promise polyfill
  43098. */
  43099. export class PromisePolyfill {
  43100. /**
  43101. * Static function used to check if the polyfill is required
  43102. * If this is the case then the function will inject the polyfill to window.Promise
  43103. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43104. */
  43105. static Apply(force?: boolean): void;
  43106. }
  43107. }
  43108. declare module BABYLON {
  43109. /**
  43110. * Interface for screenshot methods with describe argument called `size` as object with options
  43111. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43112. */
  43113. export interface IScreenshotSize {
  43114. /**
  43115. * number in pixels for canvas height
  43116. */
  43117. height?: number;
  43118. /**
  43119. * multiplier allowing render at a higher or lower resolution
  43120. * If value is defined then height and width will be ignored and taken from camera
  43121. */
  43122. precision?: number;
  43123. /**
  43124. * number in pixels for canvas width
  43125. */
  43126. width?: number;
  43127. }
  43128. }
  43129. declare module BABYLON {
  43130. interface IColor4Like {
  43131. r: float;
  43132. g: float;
  43133. b: float;
  43134. a: float;
  43135. }
  43136. /**
  43137. * Class containing a set of static utilities functions
  43138. */
  43139. export class Tools {
  43140. /**
  43141. * Gets or sets the base URL to use to load assets
  43142. */
  43143. static get BaseUrl(): string;
  43144. static set BaseUrl(value: string);
  43145. /**
  43146. * Enable/Disable Custom HTTP Request Headers globally.
  43147. * default = false
  43148. * @see CustomRequestHeaders
  43149. */
  43150. static UseCustomRequestHeaders: boolean;
  43151. /**
  43152. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43153. * i.e. when loading files, where the server/service expects an Authorization header
  43154. */
  43155. static CustomRequestHeaders: {
  43156. [key: string]: string;
  43157. };
  43158. /**
  43159. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43160. */
  43161. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43162. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43163. /**
  43164. * Default behaviour for cors in the application.
  43165. * It can be a string if the expected behavior is identical in the entire app.
  43166. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43167. */
  43168. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43169. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43170. /**
  43171. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43172. * @ignorenaming
  43173. */
  43174. static get UseFallbackTexture(): boolean;
  43175. static set UseFallbackTexture(value: boolean);
  43176. /**
  43177. * Use this object to register external classes like custom textures or material
  43178. * to allow the loaders to instantiate them
  43179. */
  43180. static get RegisteredExternalClasses(): {
  43181. [key: string]: Object;
  43182. };
  43183. static set RegisteredExternalClasses(classes: {
  43184. [key: string]: Object;
  43185. });
  43186. /**
  43187. * Texture content used if a texture cannot loaded
  43188. * @ignorenaming
  43189. */
  43190. static get fallbackTexture(): string;
  43191. static set fallbackTexture(value: string);
  43192. /**
  43193. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43194. * @param u defines the coordinate on X axis
  43195. * @param v defines the coordinate on Y axis
  43196. * @param width defines the width of the source data
  43197. * @param height defines the height of the source data
  43198. * @param pixels defines the source byte array
  43199. * @param color defines the output color
  43200. */
  43201. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43202. /**
  43203. * Interpolates between a and b via alpha
  43204. * @param a The lower value (returned when alpha = 0)
  43205. * @param b The upper value (returned when alpha = 1)
  43206. * @param alpha The interpolation-factor
  43207. * @return The mixed value
  43208. */
  43209. static Mix(a: number, b: number, alpha: number): number;
  43210. /**
  43211. * Tries to instantiate a new object from a given class name
  43212. * @param className defines the class name to instantiate
  43213. * @returns the new object or null if the system was not able to do the instantiation
  43214. */
  43215. static Instantiate(className: string): any;
  43216. /**
  43217. * Provides a slice function that will work even on IE
  43218. * @param data defines the array to slice
  43219. * @param start defines the start of the data (optional)
  43220. * @param end defines the end of the data (optional)
  43221. * @returns the new sliced array
  43222. */
  43223. static Slice<T>(data: T, start?: number, end?: number): T;
  43224. /**
  43225. * Provides a slice function that will work even on IE
  43226. * The difference between this and Slice is that this will force-convert to array
  43227. * @param data defines the array to slice
  43228. * @param start defines the start of the data (optional)
  43229. * @param end defines the end of the data (optional)
  43230. * @returns the new sliced array
  43231. */
  43232. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43233. /**
  43234. * Polyfill for setImmediate
  43235. * @param action defines the action to execute after the current execution block
  43236. */
  43237. static SetImmediate(action: () => void): void;
  43238. /**
  43239. * Function indicating if a number is an exponent of 2
  43240. * @param value defines the value to test
  43241. * @returns true if the value is an exponent of 2
  43242. */
  43243. static IsExponentOfTwo(value: number): boolean;
  43244. private static _tmpFloatArray;
  43245. /**
  43246. * Returns the nearest 32-bit single precision float representation of a Number
  43247. * @param value A Number. If the parameter is of a different type, it will get converted
  43248. * to a number or to NaN if it cannot be converted
  43249. * @returns number
  43250. */
  43251. static FloatRound(value: number): number;
  43252. /**
  43253. * Extracts the filename from a path
  43254. * @param path defines the path to use
  43255. * @returns the filename
  43256. */
  43257. static GetFilename(path: string): string;
  43258. /**
  43259. * Extracts the "folder" part of a path (everything before the filename).
  43260. * @param uri The URI to extract the info from
  43261. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43262. * @returns The "folder" part of the path
  43263. */
  43264. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43265. /**
  43266. * Extracts text content from a DOM element hierarchy
  43267. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43268. */
  43269. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43270. /**
  43271. * Convert an angle in radians to degrees
  43272. * @param angle defines the angle to convert
  43273. * @returns the angle in degrees
  43274. */
  43275. static ToDegrees(angle: number): number;
  43276. /**
  43277. * Convert an angle in degrees to radians
  43278. * @param angle defines the angle to convert
  43279. * @returns the angle in radians
  43280. */
  43281. static ToRadians(angle: number): number;
  43282. /**
  43283. * Returns an array if obj is not an array
  43284. * @param obj defines the object to evaluate as an array
  43285. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43286. * @returns either obj directly if obj is an array or a new array containing obj
  43287. */
  43288. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43289. /**
  43290. * Gets the pointer prefix to use
  43291. * @param engine defines the engine we are finding the prefix for
  43292. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43293. */
  43294. static GetPointerPrefix(engine: Engine): string;
  43295. /**
  43296. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43297. * @param url define the url we are trying
  43298. * @param element define the dom element where to configure the cors policy
  43299. */
  43300. static SetCorsBehavior(url: string | string[], element: {
  43301. crossOrigin: string | null;
  43302. }): void;
  43303. /**
  43304. * Removes unwanted characters from an url
  43305. * @param url defines the url to clean
  43306. * @returns the cleaned url
  43307. */
  43308. static CleanUrl(url: string): string;
  43309. /**
  43310. * Gets or sets a function used to pre-process url before using them to load assets
  43311. */
  43312. static get PreprocessUrl(): (url: string) => string;
  43313. static set PreprocessUrl(processor: (url: string) => string);
  43314. /**
  43315. * Loads an image as an HTMLImageElement.
  43316. * @param input url string, ArrayBuffer, or Blob to load
  43317. * @param onLoad callback called when the image successfully loads
  43318. * @param onError callback called when the image fails to load
  43319. * @param offlineProvider offline provider for caching
  43320. * @param mimeType optional mime type
  43321. * @returns the HTMLImageElement of the loaded image
  43322. */
  43323. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43324. /**
  43325. * Loads a file from a url
  43326. * @param url url string, ArrayBuffer, or Blob to load
  43327. * @param onSuccess callback called when the file successfully loads
  43328. * @param onProgress callback called while file is loading (if the server supports this mode)
  43329. * @param offlineProvider defines the offline provider for caching
  43330. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43331. * @param onError callback called when the file fails to load
  43332. * @returns a file request object
  43333. */
  43334. 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;
  43335. /**
  43336. * Loads a file from a url
  43337. * @param url the file url to load
  43338. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43339. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43340. */
  43341. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43342. /**
  43343. * Load a script (identified by an url). When the url returns, the
  43344. * content of this file is added into a new script element, attached to the DOM (body element)
  43345. * @param scriptUrl defines the url of the script to laod
  43346. * @param onSuccess defines the callback called when the script is loaded
  43347. * @param onError defines the callback to call if an error occurs
  43348. * @param scriptId defines the id of the script element
  43349. */
  43350. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43351. /**
  43352. * Load an asynchronous script (identified by an url). When the url returns, the
  43353. * content of this file is added into a new script element, attached to the DOM (body element)
  43354. * @param scriptUrl defines the url of the script to laod
  43355. * @param scriptId defines the id of the script element
  43356. * @returns a promise request object
  43357. */
  43358. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43359. /**
  43360. * Loads a file from a blob
  43361. * @param fileToLoad defines the blob to use
  43362. * @param callback defines the callback to call when data is loaded
  43363. * @param progressCallback defines the callback to call during loading process
  43364. * @returns a file request object
  43365. */
  43366. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43367. /**
  43368. * Reads a file from a File object
  43369. * @param file defines the file to load
  43370. * @param onSuccess defines the callback to call when data is loaded
  43371. * @param onProgress defines the callback to call during loading process
  43372. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43373. * @param onError defines the callback to call when an error occurs
  43374. * @returns a file request object
  43375. */
  43376. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43377. /**
  43378. * Creates a data url from a given string content
  43379. * @param content defines the content to convert
  43380. * @returns the new data url link
  43381. */
  43382. static FileAsURL(content: string): string;
  43383. /**
  43384. * Format the given number to a specific decimal format
  43385. * @param value defines the number to format
  43386. * @param decimals defines the number of decimals to use
  43387. * @returns the formatted string
  43388. */
  43389. static Format(value: number, decimals?: number): string;
  43390. /**
  43391. * Tries to copy an object by duplicating every property
  43392. * @param source defines the source object
  43393. * @param destination defines the target object
  43394. * @param doNotCopyList defines a list of properties to avoid
  43395. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43396. */
  43397. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43398. /**
  43399. * Gets a boolean indicating if the given object has no own property
  43400. * @param obj defines the object to test
  43401. * @returns true if object has no own property
  43402. */
  43403. static IsEmpty(obj: any): boolean;
  43404. /**
  43405. * Function used to register events at window level
  43406. * @param windowElement defines the Window object to use
  43407. * @param events defines the events to register
  43408. */
  43409. static RegisterTopRootEvents(windowElement: Window, events: {
  43410. name: string;
  43411. handler: Nullable<(e: FocusEvent) => any>;
  43412. }[]): void;
  43413. /**
  43414. * Function used to unregister events from window level
  43415. * @param windowElement defines the Window object to use
  43416. * @param events defines the events to unregister
  43417. */
  43418. static UnregisterTopRootEvents(windowElement: Window, events: {
  43419. name: string;
  43420. handler: Nullable<(e: FocusEvent) => any>;
  43421. }[]): void;
  43422. /**
  43423. * @ignore
  43424. */
  43425. static _ScreenshotCanvas: HTMLCanvasElement;
  43426. /**
  43427. * Dumps the current bound framebuffer
  43428. * @param width defines the rendering width
  43429. * @param height defines the rendering height
  43430. * @param engine defines the hosting engine
  43431. * @param successCallback defines the callback triggered once the data are available
  43432. * @param mimeType defines the mime type of the result
  43433. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43434. * @return a void promise
  43435. */
  43436. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43437. /**
  43438. * Dumps an array buffer
  43439. * @param width defines the rendering width
  43440. * @param height defines the rendering height
  43441. * @param data the data array
  43442. * @param successCallback defines the callback triggered once the data are available
  43443. * @param mimeType defines the mime type of the result
  43444. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43445. * @param invertY true to invert the picture in the Y dimension
  43446. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43447. */
  43448. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43449. /**
  43450. * Dumps an array buffer
  43451. * @param width defines the rendering width
  43452. * @param height defines the rendering height
  43453. * @param data the data array
  43454. * @param successCallback defines the callback triggered once the data are available
  43455. * @param mimeType defines the mime type of the result
  43456. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43457. * @param invertY true to invert the picture in the Y dimension
  43458. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43459. * @return a promise that resolve to the final data
  43460. */
  43461. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43462. /**
  43463. * Converts the canvas data to blob.
  43464. * This acts as a polyfill for browsers not supporting the to blob function.
  43465. * @param canvas Defines the canvas to extract the data from
  43466. * @param successCallback Defines the callback triggered once the data are available
  43467. * @param mimeType Defines the mime type of the result
  43468. */
  43469. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43470. /**
  43471. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43472. * @param successCallback defines the callback triggered once the data are available
  43473. * @param mimeType defines the mime type of the result
  43474. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43475. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43476. */
  43477. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43478. /**
  43479. * Downloads a blob in the browser
  43480. * @param blob defines the blob to download
  43481. * @param fileName defines the name of the downloaded file
  43482. */
  43483. static Download(blob: Blob, fileName: string): void;
  43484. /**
  43485. * Will return the right value of the noPreventDefault variable
  43486. * Needed to keep backwards compatibility to the old API.
  43487. *
  43488. * @param args arguments passed to the attachControl function
  43489. * @returns the correct value for noPreventDefault
  43490. */
  43491. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43492. /**
  43493. * Captures a screenshot of the current rendering
  43494. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43495. * @param engine defines the rendering engine
  43496. * @param camera defines the source camera
  43497. * @param size This parameter can be set to a single number or to an object with the
  43498. * following (optional) properties: precision, width, height. If a single number is passed,
  43499. * it will be used for both width and height. If an object is passed, the screenshot size
  43500. * will be derived from the parameters. The precision property is a multiplier allowing
  43501. * rendering at a higher or lower resolution
  43502. * @param successCallback defines the callback receives a single parameter which contains the
  43503. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43504. * src parameter of an <img> to display it
  43505. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43506. * Check your browser for supported MIME types
  43507. */
  43508. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43509. /**
  43510. * Captures a screenshot of the current rendering
  43511. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43512. * @param engine defines the rendering engine
  43513. * @param camera defines the source camera
  43514. * @param size This parameter can be set to a single number or to an object with the
  43515. * following (optional) properties: precision, width, height. If a single number is passed,
  43516. * it will be used for both width and height. If an object is passed, the screenshot size
  43517. * will be derived from the parameters. The precision property is a multiplier allowing
  43518. * rendering at a higher or lower resolution
  43519. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43520. * Check your browser for supported MIME types
  43521. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43522. * to the src parameter of an <img> to display it
  43523. */
  43524. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43525. /**
  43526. * Generates an image screenshot from the specified camera.
  43527. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43528. * @param engine The engine to use for rendering
  43529. * @param camera The camera to use for rendering
  43530. * @param size This parameter can be set to a single number or to an object with the
  43531. * following (optional) properties: precision, width, height. If a single number is passed,
  43532. * it will be used for both width and height. If an object is passed, the screenshot size
  43533. * will be derived from the parameters. The precision property is a multiplier allowing
  43534. * rendering at a higher or lower resolution
  43535. * @param successCallback The callback receives a single parameter which contains the
  43536. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43537. * src parameter of an <img> to display it
  43538. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43539. * Check your browser for supported MIME types
  43540. * @param samples Texture samples (default: 1)
  43541. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43542. * @param fileName A name for for the downloaded file.
  43543. */
  43544. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43545. /**
  43546. * Generates an image screenshot from the specified camera.
  43547. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43548. * @param engine The engine to use for rendering
  43549. * @param camera The camera to use for rendering
  43550. * @param size This parameter can be set to a single number or to an object with the
  43551. * following (optional) properties: precision, width, height. If a single number is passed,
  43552. * it will be used for both width and height. If an object is passed, the screenshot size
  43553. * will be derived from the parameters. The precision property is a multiplier allowing
  43554. * rendering at a higher or lower resolution
  43555. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43556. * Check your browser for supported MIME types
  43557. * @param samples Texture samples (default: 1)
  43558. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43559. * @param fileName A name for for the downloaded file.
  43560. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43561. * to the src parameter of an <img> to display it
  43562. */
  43563. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43564. /**
  43565. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43566. * Be aware Math.random() could cause collisions, but:
  43567. * "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"
  43568. * @returns a pseudo random id
  43569. */
  43570. static RandomId(): string;
  43571. /**
  43572. * Test if the given uri is a base64 string
  43573. * @param uri The uri to test
  43574. * @return True if the uri is a base64 string or false otherwise
  43575. */
  43576. static IsBase64(uri: string): boolean;
  43577. /**
  43578. * Decode the given base64 uri.
  43579. * @param uri The uri to decode
  43580. * @return The decoded base64 data.
  43581. */
  43582. static DecodeBase64(uri: string): ArrayBuffer;
  43583. /**
  43584. * Gets the absolute url.
  43585. * @param url the input url
  43586. * @return the absolute url
  43587. */
  43588. static GetAbsoluteUrl(url: string): string;
  43589. /**
  43590. * No log
  43591. */
  43592. static readonly NoneLogLevel: number;
  43593. /**
  43594. * Only message logs
  43595. */
  43596. static readonly MessageLogLevel: number;
  43597. /**
  43598. * Only warning logs
  43599. */
  43600. static readonly WarningLogLevel: number;
  43601. /**
  43602. * Only error logs
  43603. */
  43604. static readonly ErrorLogLevel: number;
  43605. /**
  43606. * All logs
  43607. */
  43608. static readonly AllLogLevel: number;
  43609. /**
  43610. * Gets a value indicating the number of loading errors
  43611. * @ignorenaming
  43612. */
  43613. static get errorsCount(): number;
  43614. /**
  43615. * Callback called when a new log is added
  43616. */
  43617. static OnNewCacheEntry: (entry: string) => void;
  43618. /**
  43619. * Log a message to the console
  43620. * @param message defines the message to log
  43621. */
  43622. static Log(message: string): void;
  43623. /**
  43624. * Write a warning message to the console
  43625. * @param message defines the message to log
  43626. */
  43627. static Warn(message: string): void;
  43628. /**
  43629. * Write an error message to the console
  43630. * @param message defines the message to log
  43631. */
  43632. static Error(message: string): void;
  43633. /**
  43634. * Gets current log cache (list of logs)
  43635. */
  43636. static get LogCache(): string;
  43637. /**
  43638. * Clears the log cache
  43639. */
  43640. static ClearLogCache(): void;
  43641. /**
  43642. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43643. */
  43644. static set LogLevels(level: number);
  43645. /**
  43646. * Checks if the window object exists
  43647. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43648. */
  43649. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43650. /**
  43651. * No performance log
  43652. */
  43653. static readonly PerformanceNoneLogLevel: number;
  43654. /**
  43655. * Use user marks to log performance
  43656. */
  43657. static readonly PerformanceUserMarkLogLevel: number;
  43658. /**
  43659. * Log performance to the console
  43660. */
  43661. static readonly PerformanceConsoleLogLevel: number;
  43662. private static _performance;
  43663. /**
  43664. * Sets the current performance log level
  43665. */
  43666. static set PerformanceLogLevel(level: number);
  43667. private static _StartPerformanceCounterDisabled;
  43668. private static _EndPerformanceCounterDisabled;
  43669. private static _StartUserMark;
  43670. private static _EndUserMark;
  43671. private static _StartPerformanceConsole;
  43672. private static _EndPerformanceConsole;
  43673. /**
  43674. * Starts a performance counter
  43675. */
  43676. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43677. /**
  43678. * Ends a specific performance counter
  43679. */
  43680. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43681. /**
  43682. * Gets either window.performance.now() if supported or Date.now() else
  43683. */
  43684. static get Now(): number;
  43685. /**
  43686. * This method will return the name of the class used to create the instance of the given object.
  43687. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43688. * @param object the object to get the class name from
  43689. * @param isType defines if the object is actually a type
  43690. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43691. */
  43692. static GetClassName(object: any, isType?: boolean): string;
  43693. /**
  43694. * Gets the first element of an array satisfying a given predicate
  43695. * @param array defines the array to browse
  43696. * @param predicate defines the predicate to use
  43697. * @returns null if not found or the element
  43698. */
  43699. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43700. /**
  43701. * This method will return the name of the full name of the class, including its owning module (if any).
  43702. * 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).
  43703. * @param object the object to get the class name from
  43704. * @param isType defines if the object is actually a type
  43705. * @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.
  43706. * @ignorenaming
  43707. */
  43708. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43709. /**
  43710. * Returns a promise that resolves after the given amount of time.
  43711. * @param delay Number of milliseconds to delay
  43712. * @returns Promise that resolves after the given amount of time
  43713. */
  43714. static DelayAsync(delay: number): Promise<void>;
  43715. /**
  43716. * Utility function to detect if the current user agent is Safari
  43717. * @returns whether or not the current user agent is safari
  43718. */
  43719. static IsSafari(): boolean;
  43720. }
  43721. /**
  43722. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43723. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43724. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43725. * @param name The name of the class, case should be preserved
  43726. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43727. */
  43728. export function className(name: string, module?: string): (target: Object) => void;
  43729. /**
  43730. * An implementation of a loop for asynchronous functions.
  43731. */
  43732. export class AsyncLoop {
  43733. /**
  43734. * Defines the number of iterations for the loop
  43735. */
  43736. iterations: number;
  43737. /**
  43738. * Defines the current index of the loop.
  43739. */
  43740. index: number;
  43741. private _done;
  43742. private _fn;
  43743. private _successCallback;
  43744. /**
  43745. * Constructor.
  43746. * @param iterations the number of iterations.
  43747. * @param func the function to run each iteration
  43748. * @param successCallback the callback that will be called upon successful execution
  43749. * @param offset starting offset.
  43750. */
  43751. constructor(
  43752. /**
  43753. * Defines the number of iterations for the loop
  43754. */
  43755. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43756. /**
  43757. * Execute the next iteration. Must be called after the last iteration was finished.
  43758. */
  43759. executeNext(): void;
  43760. /**
  43761. * Break the loop and run the success callback.
  43762. */
  43763. breakLoop(): void;
  43764. /**
  43765. * Create and run an async loop.
  43766. * @param iterations the number of iterations.
  43767. * @param fn the function to run each iteration
  43768. * @param successCallback the callback that will be called upon successful execution
  43769. * @param offset starting offset.
  43770. * @returns the created async loop object
  43771. */
  43772. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43773. /**
  43774. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43775. * @param iterations total number of iterations
  43776. * @param syncedIterations number of synchronous iterations in each async iteration.
  43777. * @param fn the function to call each iteration.
  43778. * @param callback a success call back that will be called when iterating stops.
  43779. * @param breakFunction a break condition (optional)
  43780. * @param timeout timeout settings for the setTimeout function. default - 0.
  43781. * @returns the created async loop object
  43782. */
  43783. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43784. }
  43785. }
  43786. declare module BABYLON {
  43787. /**
  43788. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43789. * The underlying implementation relies on an associative array to ensure the best performances.
  43790. * The value can be anything including 'null' but except 'undefined'
  43791. */
  43792. export class StringDictionary<T> {
  43793. /**
  43794. * This will clear this dictionary and copy the content from the 'source' one.
  43795. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43796. * @param source the dictionary to take the content from and copy to this dictionary
  43797. */
  43798. copyFrom(source: StringDictionary<T>): void;
  43799. /**
  43800. * Get a value based from its key
  43801. * @param key the given key to get the matching value from
  43802. * @return the value if found, otherwise undefined is returned
  43803. */
  43804. get(key: string): T | undefined;
  43805. /**
  43806. * Get a value from its key or add it if it doesn't exist.
  43807. * This method will ensure you that a given key/data will be present in the dictionary.
  43808. * @param key the given key to get the matching value from
  43809. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43810. * The factory will only be invoked if there's no data for the given key.
  43811. * @return the value corresponding to the key.
  43812. */
  43813. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43814. /**
  43815. * Get a value from its key if present in the dictionary otherwise add it
  43816. * @param key the key to get the value from
  43817. * @param val if there's no such key/value pair in the dictionary add it with this value
  43818. * @return the value corresponding to the key
  43819. */
  43820. getOrAdd(key: string, val: T): T;
  43821. /**
  43822. * Check if there's a given key in the dictionary
  43823. * @param key the key to check for
  43824. * @return true if the key is present, false otherwise
  43825. */
  43826. contains(key: string): boolean;
  43827. /**
  43828. * Add a new key and its corresponding value
  43829. * @param key the key to add
  43830. * @param value the value corresponding to the key
  43831. * @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
  43832. */
  43833. add(key: string, value: T): boolean;
  43834. /**
  43835. * Update a specific value associated to a key
  43836. * @param key defines the key to use
  43837. * @param value defines the value to store
  43838. * @returns true if the value was updated (or false if the key was not found)
  43839. */
  43840. set(key: string, value: T): boolean;
  43841. /**
  43842. * Get the element of the given key and remove it from the dictionary
  43843. * @param key defines the key to search
  43844. * @returns the value associated with the key or null if not found
  43845. */
  43846. getAndRemove(key: string): Nullable<T>;
  43847. /**
  43848. * Remove a key/value from the dictionary.
  43849. * @param key the key to remove
  43850. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43851. */
  43852. remove(key: string): boolean;
  43853. /**
  43854. * Clear the whole content of the dictionary
  43855. */
  43856. clear(): void;
  43857. /**
  43858. * Gets the current count
  43859. */
  43860. get count(): number;
  43861. /**
  43862. * Execute a callback on each key/val of the dictionary.
  43863. * Note that you can remove any element in this dictionary in the callback implementation
  43864. * @param callback the callback to execute on a given key/value pair
  43865. */
  43866. forEach(callback: (key: string, val: T) => void): void;
  43867. /**
  43868. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43869. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43870. * Note that you can remove any element in this dictionary in the callback implementation
  43871. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43872. * @returns the first item
  43873. */
  43874. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43875. private _count;
  43876. private _data;
  43877. }
  43878. }
  43879. declare module BABYLON {
  43880. /** @hidden */
  43881. export interface ICollisionCoordinator {
  43882. createCollider(): Collider;
  43883. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43884. init(scene: Scene): void;
  43885. }
  43886. /** @hidden */
  43887. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43888. private _scene;
  43889. private _scaledPosition;
  43890. private _scaledVelocity;
  43891. private _finalPosition;
  43892. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43893. createCollider(): Collider;
  43894. init(scene: Scene): void;
  43895. private _collideWithWorld;
  43896. }
  43897. }
  43898. declare module BABYLON {
  43899. /**
  43900. * Class used to manage all inputs for the scene.
  43901. */
  43902. export class InputManager {
  43903. /** The distance in pixel that you have to move to prevent some events */
  43904. static DragMovementThreshold: number;
  43905. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43906. static LongPressDelay: number;
  43907. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43908. static DoubleClickDelay: number;
  43909. /** If you need to check double click without raising a single click at first click, enable this flag */
  43910. static ExclusiveDoubleClickMode: boolean;
  43911. /** 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. */
  43912. private _alreadyAttached;
  43913. private _alreadyAttachedTo;
  43914. private _wheelEventName;
  43915. private _onPointerMove;
  43916. private _onPointerDown;
  43917. private _onPointerUp;
  43918. private _initClickEvent;
  43919. private _initActionManager;
  43920. private _delayedSimpleClick;
  43921. private _delayedSimpleClickTimeout;
  43922. private _previousDelayedSimpleClickTimeout;
  43923. private _meshPickProceed;
  43924. private _previousButtonPressed;
  43925. private _currentPickResult;
  43926. private _previousPickResult;
  43927. private _totalPointersPressed;
  43928. private _doubleClickOccured;
  43929. private _pointerOverMesh;
  43930. private _pickedDownMesh;
  43931. private _pickedUpMesh;
  43932. private _pointerX;
  43933. private _pointerY;
  43934. private _unTranslatedPointerX;
  43935. private _unTranslatedPointerY;
  43936. private _startingPointerPosition;
  43937. private _previousStartingPointerPosition;
  43938. private _startingPointerTime;
  43939. private _previousStartingPointerTime;
  43940. private _pointerCaptures;
  43941. private _meshUnderPointerId;
  43942. private _onKeyDown;
  43943. private _onKeyUp;
  43944. private _keyboardIsAttached;
  43945. private _onCanvasFocusObserver;
  43946. private _onCanvasBlurObserver;
  43947. private _scene;
  43948. /**
  43949. * Creates a new InputManager
  43950. * @param scene defines the hosting scene
  43951. */
  43952. constructor(scene: Scene);
  43953. /**
  43954. * Gets the mesh that is currently under the pointer
  43955. */
  43956. get meshUnderPointer(): Nullable<AbstractMesh>;
  43957. /**
  43958. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43959. * @param pointerId the pointer id to use
  43960. * @returns The mesh under this pointer id or null if not found
  43961. */
  43962. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43963. /**
  43964. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43965. */
  43966. get unTranslatedPointer(): Vector2;
  43967. /**
  43968. * Gets or sets the current on-screen X position of the pointer
  43969. */
  43970. get pointerX(): number;
  43971. set pointerX(value: number);
  43972. /**
  43973. * Gets or sets the current on-screen Y position of the pointer
  43974. */
  43975. get pointerY(): number;
  43976. set pointerY(value: number);
  43977. private _updatePointerPosition;
  43978. private _processPointerMove;
  43979. private _setRayOnPointerInfo;
  43980. private _checkPrePointerObservable;
  43981. /**
  43982. * Use this method to simulate a pointer move on a mesh
  43983. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43984. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43985. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43986. */
  43987. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43988. /**
  43989. * Use this method to simulate a pointer down on a mesh
  43990. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43991. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43992. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43993. */
  43994. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43995. private _processPointerDown;
  43996. /** @hidden */
  43997. _isPointerSwiping(): boolean;
  43998. /**
  43999. * Use this method to simulate a pointer up on a mesh
  44000. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44001. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44002. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44003. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44004. */
  44005. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44006. private _processPointerUp;
  44007. /**
  44008. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44009. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44010. * @returns true if the pointer was captured
  44011. */
  44012. isPointerCaptured(pointerId?: number): boolean;
  44013. /**
  44014. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44015. * @param attachUp defines if you want to attach events to pointerup
  44016. * @param attachDown defines if you want to attach events to pointerdown
  44017. * @param attachMove defines if you want to attach events to pointermove
  44018. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44019. */
  44020. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44021. /**
  44022. * Detaches all event handlers
  44023. */
  44024. detachControl(): void;
  44025. /**
  44026. * Force the value of meshUnderPointer
  44027. * @param mesh defines the mesh to use
  44028. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44029. */
  44030. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44031. /**
  44032. * Gets the mesh under the pointer
  44033. * @returns a Mesh or null if no mesh is under the pointer
  44034. */
  44035. getPointerOverMesh(): Nullable<AbstractMesh>;
  44036. }
  44037. }
  44038. declare module BABYLON {
  44039. /**
  44040. * This class defines the direct association between an animation and a target
  44041. */
  44042. export class TargetedAnimation {
  44043. /**
  44044. * Animation to perform
  44045. */
  44046. animation: Animation;
  44047. /**
  44048. * Target to animate
  44049. */
  44050. target: any;
  44051. /**
  44052. * Returns the string "TargetedAnimation"
  44053. * @returns "TargetedAnimation"
  44054. */
  44055. getClassName(): string;
  44056. /**
  44057. * Serialize the object
  44058. * @returns the JSON object representing the current entity
  44059. */
  44060. serialize(): any;
  44061. }
  44062. /**
  44063. * Use this class to create coordinated animations on multiple targets
  44064. */
  44065. export class AnimationGroup implements IDisposable {
  44066. /** The name of the animation group */
  44067. name: string;
  44068. private _scene;
  44069. private _targetedAnimations;
  44070. private _animatables;
  44071. private _from;
  44072. private _to;
  44073. private _isStarted;
  44074. private _isPaused;
  44075. private _speedRatio;
  44076. private _loopAnimation;
  44077. private _isAdditive;
  44078. /**
  44079. * Gets or sets the unique id of the node
  44080. */
  44081. uniqueId: number;
  44082. /**
  44083. * This observable will notify when one animation have ended
  44084. */
  44085. onAnimationEndObservable: Observable<TargetedAnimation>;
  44086. /**
  44087. * Observer raised when one animation loops
  44088. */
  44089. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44090. /**
  44091. * Observer raised when all animations have looped
  44092. */
  44093. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44094. /**
  44095. * This observable will notify when all animations have ended.
  44096. */
  44097. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44098. /**
  44099. * This observable will notify when all animations have paused.
  44100. */
  44101. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44102. /**
  44103. * This observable will notify when all animations are playing.
  44104. */
  44105. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44106. /**
  44107. * Gets the first frame
  44108. */
  44109. get from(): number;
  44110. /**
  44111. * Gets the last frame
  44112. */
  44113. get to(): number;
  44114. /**
  44115. * Define if the animations are started
  44116. */
  44117. get isStarted(): boolean;
  44118. /**
  44119. * Gets a value indicating that the current group is playing
  44120. */
  44121. get isPlaying(): boolean;
  44122. /**
  44123. * Gets or sets the speed ratio to use for all animations
  44124. */
  44125. get speedRatio(): number;
  44126. /**
  44127. * Gets or sets the speed ratio to use for all animations
  44128. */
  44129. set speedRatio(value: number);
  44130. /**
  44131. * Gets or sets if all animations should loop or not
  44132. */
  44133. get loopAnimation(): boolean;
  44134. set loopAnimation(value: boolean);
  44135. /**
  44136. * Gets or sets if all animations should be evaluated additively
  44137. */
  44138. get isAdditive(): boolean;
  44139. set isAdditive(value: boolean);
  44140. /**
  44141. * Gets the targeted animations for this animation group
  44142. */
  44143. get targetedAnimations(): Array<TargetedAnimation>;
  44144. /**
  44145. * returning the list of animatables controlled by this animation group.
  44146. */
  44147. get animatables(): Array<Animatable>;
  44148. /**
  44149. * Gets the list of target animations
  44150. */
  44151. get children(): TargetedAnimation[];
  44152. /**
  44153. * Instantiates a new Animation Group.
  44154. * This helps managing several animations at once.
  44155. * @see https://doc.babylonjs.com/how_to/group
  44156. * @param name Defines the name of the group
  44157. * @param scene Defines the scene the group belongs to
  44158. */
  44159. constructor(
  44160. /** The name of the animation group */
  44161. name: string, scene?: Nullable<Scene>);
  44162. /**
  44163. * Add an animation (with its target) in the group
  44164. * @param animation defines the animation we want to add
  44165. * @param target defines the target of the animation
  44166. * @returns the TargetedAnimation object
  44167. */
  44168. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44169. /**
  44170. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44171. * It can add constant keys at begin or end
  44172. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44173. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44174. * @returns the animation group
  44175. */
  44176. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44177. private _animationLoopCount;
  44178. private _animationLoopFlags;
  44179. private _processLoop;
  44180. /**
  44181. * Start all animations on given targets
  44182. * @param loop defines if animations must loop
  44183. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44184. * @param from defines the from key (optional)
  44185. * @param to defines the to key (optional)
  44186. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44187. * @returns the current animation group
  44188. */
  44189. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44190. /**
  44191. * Pause all animations
  44192. * @returns the animation group
  44193. */
  44194. pause(): AnimationGroup;
  44195. /**
  44196. * Play all animations to initial state
  44197. * This function will start() the animations if they were not started or will restart() them if they were paused
  44198. * @param loop defines if animations must loop
  44199. * @returns the animation group
  44200. */
  44201. play(loop?: boolean): AnimationGroup;
  44202. /**
  44203. * Reset all animations to initial state
  44204. * @returns the animation group
  44205. */
  44206. reset(): AnimationGroup;
  44207. /**
  44208. * Restart animations from key 0
  44209. * @returns the animation group
  44210. */
  44211. restart(): AnimationGroup;
  44212. /**
  44213. * Stop all animations
  44214. * @returns the animation group
  44215. */
  44216. stop(): AnimationGroup;
  44217. /**
  44218. * Set animation weight for all animatables
  44219. * @param weight defines the weight to use
  44220. * @return the animationGroup
  44221. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44222. */
  44223. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44224. /**
  44225. * Synchronize and normalize all animatables with a source animatable
  44226. * @param root defines the root animatable to synchronize with
  44227. * @return the animationGroup
  44228. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44229. */
  44230. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44231. /**
  44232. * Goes to a specific frame in this animation group
  44233. * @param frame the frame number to go to
  44234. * @return the animationGroup
  44235. */
  44236. goToFrame(frame: number): AnimationGroup;
  44237. /**
  44238. * Dispose all associated resources
  44239. */
  44240. dispose(): void;
  44241. private _checkAnimationGroupEnded;
  44242. /**
  44243. * Clone the current animation group and returns a copy
  44244. * @param newName defines the name of the new group
  44245. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44246. * @returns the new animation group
  44247. */
  44248. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44249. /**
  44250. * Serializes the animationGroup to an object
  44251. * @returns Serialized object
  44252. */
  44253. serialize(): any;
  44254. /**
  44255. * Returns a new AnimationGroup object parsed from the source provided.
  44256. * @param parsedAnimationGroup defines the source
  44257. * @param scene defines the scene that will receive the animationGroup
  44258. * @returns a new AnimationGroup
  44259. */
  44260. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44261. /**
  44262. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44263. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44264. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44265. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44266. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44267. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44268. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44269. */
  44270. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44271. /**
  44272. * Returns the string "AnimationGroup"
  44273. * @returns "AnimationGroup"
  44274. */
  44275. getClassName(): string;
  44276. /**
  44277. * Creates a detailed string about the object
  44278. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44279. * @returns a string representing the object
  44280. */
  44281. toString(fullDetails?: boolean): string;
  44282. }
  44283. }
  44284. declare module BABYLON {
  44285. /**
  44286. * @hidden
  44287. **/
  44288. export class _TimeToken {
  44289. _startTimeQuery: Nullable<WebGLQuery>;
  44290. _endTimeQuery: Nullable<WebGLQuery>;
  44291. _timeElapsedQuery: Nullable<WebGLQuery>;
  44292. _timeElapsedQueryEnded: boolean;
  44293. }
  44294. }
  44295. declare module BABYLON {
  44296. /** @hidden */
  44297. export enum ExtensionName {
  44298. DepthClamping = "depth-clamping",
  44299. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44300. Depth32FloatStencil8 = "depth32float-stencil8",
  44301. PipelineStatisticsQuery = "pipeline-statistics-query",
  44302. TextureCompressionBC = "texture-compression-bc",
  44303. TimestampQuery = "timestamp-query"
  44304. }
  44305. /** @hidden */
  44306. export enum AddressMode {
  44307. ClampToEdge = "clamp-to-edge",
  44308. Repeat = "repeat",
  44309. MirrorRepeat = "mirror-repeat"
  44310. }
  44311. /** @hidden */
  44312. export enum BindingType {
  44313. UniformBuffer = "uniform-buffer",
  44314. StorageBuffer = "storage-buffer",
  44315. ReadonlyStorageBuffer = "readonly-storage-buffer",
  44316. Sampler = "sampler",
  44317. ComparisonSampler = "comparison-sampler",
  44318. SampledTexture = "sampled-texture",
  44319. ReadonlyStorageTexture = "readonly-storage-texture",
  44320. WriteonlyStorageTexture = "writeonly-storage-texture"
  44321. }
  44322. /** @hidden */
  44323. export enum BlendFactor {
  44324. Zero = "zero",
  44325. One = "one",
  44326. SrcColor = "src-color",
  44327. OneMinusSrcColor = "one-minus-src-color",
  44328. SrcAlpha = "src-alpha",
  44329. OneMinusSrcAlpha = "one-minus-src-alpha",
  44330. DstColor = "dst-color",
  44331. OneMinusDstColor = "one-minus-dst-color",
  44332. DstAlpha = "dst-alpha",
  44333. OneMinusDstAlpha = "one-minus-dst-alpha",
  44334. SrcAlphaSaturated = "src-alpha-saturated",
  44335. BlendColor = "blend-color",
  44336. OneMinusBlendColor = "one-minus-blend-color"
  44337. }
  44338. /** @hidden */
  44339. export enum BlendOperation {
  44340. Add = "add",
  44341. Subtract = "subtract",
  44342. ReverseSubtract = "reverse-subtract",
  44343. Min = "min",
  44344. Max = "max"
  44345. }
  44346. /** @hidden */
  44347. export enum CompareFunction {
  44348. Never = "never",
  44349. Less = "less",
  44350. Equal = "equal",
  44351. LessEqual = "less-equal",
  44352. Greater = "greater",
  44353. NotEqual = "not-equal",
  44354. GreaterEqual = "greater-equal",
  44355. Always = "always"
  44356. }
  44357. /** @hidden */
  44358. export enum CullMode {
  44359. None = "none",
  44360. Front = "front",
  44361. Back = "back"
  44362. }
  44363. /** @hidden */
  44364. export enum FilterMode {
  44365. Nearest = "nearest",
  44366. Linear = "linear"
  44367. }
  44368. /** @hidden */
  44369. export enum FrontFace {
  44370. CCW = "ccw",
  44371. CW = "cw"
  44372. }
  44373. /** @hidden */
  44374. export enum IndexFormat {
  44375. Uint16 = "uint16",
  44376. Uint32 = "uint32"
  44377. }
  44378. /** @hidden */
  44379. export enum InputStepMode {
  44380. Vertex = "vertex",
  44381. Instance = "instance"
  44382. }
  44383. /** @hidden */
  44384. export enum LoadOp {
  44385. Load = "load"
  44386. }
  44387. /** @hidden */
  44388. export enum PrimitiveTopology {
  44389. PointList = "point-list",
  44390. LineList = "line-list",
  44391. LineStrip = "line-strip",
  44392. TriangleList = "triangle-list",
  44393. TriangleStrip = "triangle-strip"
  44394. }
  44395. /** @hidden */
  44396. export enum StencilOperation {
  44397. Keep = "keep",
  44398. Zero = "zero",
  44399. Replace = "replace",
  44400. Invert = "invert",
  44401. IncrementClamp = "increment-clamp",
  44402. DecrementClamp = "decrement-clamp",
  44403. IncrementWrap = "increment-wrap",
  44404. DecrementWrap = "decrement-wrap"
  44405. }
  44406. /** @hidden */
  44407. export enum StoreOp {
  44408. Store = "store",
  44409. Clear = "clear"
  44410. }
  44411. /** @hidden */
  44412. export enum TextureDimension {
  44413. E1d = "1d",
  44414. E2d = "2d",
  44415. E3d = "3d"
  44416. }
  44417. /** @hidden */
  44418. export enum TextureFormat {
  44419. R8Unorm = "r8unorm",
  44420. R8Snorm = "r8snorm",
  44421. R8Uint = "r8uint",
  44422. R8Sint = "r8sint",
  44423. R16Uint = "r16uint",
  44424. R16Sint = "r16sint",
  44425. R16Float = "r16float",
  44426. RG8Unorm = "rg8unorm",
  44427. RG8Snorm = "rg8snorm",
  44428. RG8Uint = "rg8uint",
  44429. RG8Sint = "rg8sint",
  44430. R32Uint = "r32uint",
  44431. R32Sint = "r32sint",
  44432. R32Float = "r32float",
  44433. RG16Uint = "rg16uint",
  44434. RG16Sint = "rg16sint",
  44435. RG16Float = "rg16float",
  44436. RGBA8Unorm = "rgba8unorm",
  44437. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44438. RGBA8Snorm = "rgba8snorm",
  44439. RGBA8Uint = "rgba8uint",
  44440. RGBA8Sint = "rgba8sint",
  44441. BGRA8Unorm = "bgra8unorm",
  44442. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44443. RGB9E5UFloat = "rgb9e5ufloat",
  44444. RGB10A2Unorm = "rgb10a2unorm",
  44445. RG11B10UFloat = "rg11b10ufloat",
  44446. RG32Uint = "rg32uint",
  44447. RG32Sint = "rg32sint",
  44448. RG32Float = "rg32float",
  44449. RGBA16Uint = "rgba16uint",
  44450. RGBA16Sint = "rgba16sint",
  44451. RGBA16Float = "rgba16float",
  44452. RGBA32Uint = "rgba32uint",
  44453. RGBA32Sint = "rgba32sint",
  44454. RGBA32Float = "rgba32float",
  44455. Stencil8 = "stencil8",
  44456. Depth16Unorm = "depth16unorm",
  44457. Depth24Plus = "depth24plus",
  44458. Depth24PlusStencil8 = "depth24plus-stencil8",
  44459. Depth32Float = "depth32float",
  44460. BC1RGBAUNorm = "bc1-rgba-unorm",
  44461. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44462. BC2RGBAUnorm = "bc2-rgba-unorm",
  44463. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44464. BC3RGBAUnorm = "bc3-rgba-unorm",
  44465. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44466. BC4RUnorm = "bc4-r-unorm",
  44467. BC4RSnorm = "bc4-r-snorm",
  44468. BC5RGUnorm = "bc5-rg-unorm",
  44469. BC5RGSnorm = "bc5-rg-snorm",
  44470. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44471. BC6HRGBFloat = "bc6h-rgb-float",
  44472. BC7RGBAUnorm = "bc7-rgba-unorm",
  44473. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44474. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44475. Depth32FloatStencil8 = "depth32float-stencil8"
  44476. }
  44477. /** @hidden */
  44478. export enum TextureComponentType {
  44479. Float = "float",
  44480. Sint = "sint",
  44481. Uint = "uint",
  44482. DepthComparison = "depth-comparison"
  44483. }
  44484. /** @hidden */
  44485. export enum TextureViewDimension {
  44486. E1d = "1d",
  44487. E2d = "2d",
  44488. E2dArray = "2d-array",
  44489. Cube = "cube",
  44490. CubeArray = "cube-array",
  44491. E3d = "3d"
  44492. }
  44493. /** @hidden */
  44494. export enum VertexFormat {
  44495. Uchar2 = "uchar2",
  44496. Uchar4 = "uchar4",
  44497. Char2 = "char2",
  44498. Char4 = "char4",
  44499. Uchar2Norm = "uchar2norm",
  44500. Uchar4Norm = "uchar4norm",
  44501. Char2Norm = "char2norm",
  44502. Char4Norm = "char4norm",
  44503. Ushort2 = "ushort2",
  44504. Ushort4 = "ushort4",
  44505. Short2 = "short2",
  44506. Short4 = "short4",
  44507. Ushort2Norm = "ushort2norm",
  44508. Ushort4Norm = "ushort4norm",
  44509. Short2Norm = "short2norm",
  44510. Short4Norm = "short4norm",
  44511. Half2 = "half2",
  44512. Half4 = "half4",
  44513. Float = "float",
  44514. Float2 = "float2",
  44515. Float3 = "float3",
  44516. Float4 = "float4",
  44517. Uint = "uint",
  44518. Uint2 = "uint2",
  44519. Uint3 = "uint3",
  44520. Uint4 = "uint4",
  44521. Int = "int",
  44522. Int2 = "int2",
  44523. Int3 = "int3",
  44524. Int4 = "int4"
  44525. }
  44526. /** @hidden */
  44527. export enum TextureAspect {
  44528. All = "all",
  44529. StencilOnly = "stencil-only",
  44530. DepthOnly = "depth-only"
  44531. }
  44532. /** @hidden */
  44533. export enum CompilationMessageType {
  44534. Error = "error",
  44535. Warning = "warning",
  44536. Info = "info"
  44537. }
  44538. /** @hidden */
  44539. export enum QueryType {
  44540. Occlusion = "occlusion"
  44541. }
  44542. /** @hidden */
  44543. export enum BufferUsage {
  44544. MapRead = 1,
  44545. MapWrite = 2,
  44546. CopySrc = 4,
  44547. CopyDst = 8,
  44548. Index = 16,
  44549. Vertex = 32,
  44550. Uniform = 64,
  44551. Storage = 128,
  44552. Indirect = 256,
  44553. QueryResolve = 512
  44554. }
  44555. /** @hidden */
  44556. export enum ColorWrite {
  44557. Red = 1,
  44558. Green = 2,
  44559. Blue = 4,
  44560. Alpha = 8,
  44561. All = 15
  44562. }
  44563. /** @hidden */
  44564. export enum ShaderStage {
  44565. Vertex = 1,
  44566. Fragment = 2,
  44567. Compute = 4
  44568. }
  44569. /** @hidden */
  44570. export enum TextureUsage {
  44571. CopySrc = 1,
  44572. CopyDst = 2,
  44573. Sampled = 4,
  44574. Storage = 8,
  44575. OutputAttachment = 16
  44576. }
  44577. /** @hidden */
  44578. export enum MapMode {
  44579. Read = 1,
  44580. Write = 2
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /** @hidden */
  44585. export interface WebGPUBindingInfo {
  44586. setIndex: number;
  44587. bindingIndex: number;
  44588. }
  44589. /** @hidden */
  44590. export interface WebGPUTextureSamplerBindingDescription {
  44591. sampler: WebGPUBindingInfo;
  44592. isTextureArray: boolean;
  44593. textures: Array<WebGPUBindingInfo>;
  44594. }
  44595. /** @hidden
  44596. * If the binding is a UBO, isSampler=isTexture=false
  44597. */
  44598. export interface WebGPUBindingDescription {
  44599. name: string;
  44600. usedInVertex: boolean;
  44601. usedInFragment: boolean;
  44602. isSampler: boolean;
  44603. isComparisonSampler?: boolean;
  44604. isTexture: boolean;
  44605. componentType?: GPUTextureComponentType;
  44606. textureDimension?: GPUTextureViewDimension;
  44607. }
  44608. /**
  44609. * @hidden
  44610. */
  44611. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44612. uboNextBindingIndex: number;
  44613. freeSetIndex: number;
  44614. freeBindingIndex: number;
  44615. availableVaryings: {
  44616. [key: string]: number;
  44617. };
  44618. availableAttributes: {
  44619. [key: string]: number;
  44620. };
  44621. availableUBOs: {
  44622. [key: string]: {
  44623. setIndex: number;
  44624. bindingIndex: number;
  44625. };
  44626. };
  44627. availableSamplers: {
  44628. [key: string]: WebGPUTextureSamplerBindingDescription;
  44629. };
  44630. leftOverUniforms: {
  44631. name: string;
  44632. type: string;
  44633. length: number;
  44634. }[];
  44635. orderedAttributes: string[];
  44636. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44637. uniformBufferNames: string[];
  44638. attributeNamesFromEffect: string[];
  44639. attributeLocationsFromEffect: number[];
  44640. private _attributeNextLocation;
  44641. private _varyingNextLocation;
  44642. constructor();
  44643. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44644. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44645. getNextFreeUBOBinding(): {
  44646. setIndex: number;
  44647. bindingIndex: number;
  44648. };
  44649. private _getNextFreeBinding;
  44650. }
  44651. }
  44652. declare module BABYLON {
  44653. /** @hidden */
  44654. export interface IWebGPUPipelineContextSamplerCache {
  44655. samplerBinding: number;
  44656. firstTextureName: string;
  44657. }
  44658. /** @hidden */
  44659. export interface IWebGPUPipelineContextTextureCache {
  44660. textureBinding: number;
  44661. texture: InternalTexture;
  44662. }
  44663. /** @hidden */
  44664. export interface IWebGPUPipelineContextVertexInputsCache {
  44665. indexBuffer: Nullable<GPUBuffer>;
  44666. indexOffset: number;
  44667. vertexStartSlot: number;
  44668. vertexBuffers: GPUBuffer[];
  44669. vertexOffsets: number[];
  44670. }
  44671. /** @hidden */
  44672. export interface IWebGPURenderPipelineStageDescriptor {
  44673. vertexStage: GPUProgrammableStageDescriptor;
  44674. fragmentStage?: GPUProgrammableStageDescriptor;
  44675. }
  44676. /** @hidden */
  44677. export class WebGPUBindGroupCacheNode {
  44678. values: {
  44679. [id: number]: WebGPUBindGroupCacheNode;
  44680. };
  44681. bindGroups: GPUBindGroup[];
  44682. constructor();
  44683. }
  44684. /** @hidden */
  44685. export class WebGPUPipelineContext implements IPipelineContext {
  44686. engine: WebGPUEngine;
  44687. shaderProcessingContext: WebGPUShaderProcessingContext;
  44688. leftOverUniformsByName: {
  44689. [name: string]: string;
  44690. };
  44691. sources: {
  44692. vertex: string;
  44693. fragment: string;
  44694. rawVertex: string;
  44695. rawFragment: string;
  44696. };
  44697. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44698. samplers: {
  44699. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44700. };
  44701. textures: {
  44702. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44703. };
  44704. bindGroupLayouts: GPUBindGroupLayout[];
  44705. bindGroupsCache: WebGPUBindGroupCacheNode;
  44706. /**
  44707. * Stores the uniform buffer
  44708. */
  44709. uniformBuffer: Nullable<UniformBuffer>;
  44710. onCompiled?: () => void;
  44711. get isAsync(): boolean;
  44712. get isReady(): boolean;
  44713. /** @hidden */
  44714. _name: string;
  44715. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44716. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44717. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44718. [key: string]: number;
  44719. }, uniformsNames: string[], uniforms: {
  44720. [key: string]: Nullable<WebGLUniformLocation>;
  44721. }, samplerList: string[], samplers: {
  44722. [key: string]: number;
  44723. }, attributesNames: string[], attributes: number[]): void;
  44724. /** @hidden */
  44725. /**
  44726. * Build the uniform buffer used in the material.
  44727. */
  44728. buildUniformLayout(): void;
  44729. /**
  44730. * Release all associated resources.
  44731. **/
  44732. dispose(): void;
  44733. /**
  44734. * Sets an integer value on a uniform variable.
  44735. * @param uniformName Name of the variable.
  44736. * @param value Value to be set.
  44737. */
  44738. setInt(uniformName: string, value: number): void;
  44739. /**
  44740. * Sets an int2 value on a uniform variable.
  44741. * @param uniformName Name of the variable.
  44742. * @param x First int in int2.
  44743. * @param y Second int in int2.
  44744. */
  44745. setInt2(uniformName: string, x: number, y: number): void;
  44746. /**
  44747. * Sets an int3 value on a uniform variable.
  44748. * @param uniformName Name of the variable.
  44749. * @param x First int in int3.
  44750. * @param y Second int in int3.
  44751. * @param z Third int in int3.
  44752. */
  44753. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44754. /**
  44755. * Sets an int4 value on a uniform variable.
  44756. * @param uniformName Name of the variable.
  44757. * @param x First int in int4.
  44758. * @param y Second int in int4.
  44759. * @param z Third int in int4.
  44760. * @param w Fourth int in int4.
  44761. */
  44762. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44763. /**
  44764. * Sets an int array on a uniform variable.
  44765. * @param uniformName Name of the variable.
  44766. * @param array array to be set.
  44767. */
  44768. setIntArray(uniformName: string, array: Int32Array): void;
  44769. /**
  44770. * 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)
  44771. * @param uniformName Name of the variable.
  44772. * @param array array to be set.
  44773. */
  44774. setIntArray2(uniformName: string, array: Int32Array): void;
  44775. /**
  44776. * 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)
  44777. * @param uniformName Name of the variable.
  44778. * @param array array to be set.
  44779. */
  44780. setIntArray3(uniformName: string, array: Int32Array): void;
  44781. /**
  44782. * 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)
  44783. * @param uniformName Name of the variable.
  44784. * @param array array to be set.
  44785. */
  44786. setIntArray4(uniformName: string, array: Int32Array): void;
  44787. /**
  44788. * Sets an array on a uniform variable.
  44789. * @param uniformName Name of the variable.
  44790. * @param array array to be set.
  44791. */
  44792. setArray(uniformName: string, array: number[]): void;
  44793. /**
  44794. * 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)
  44795. * @param uniformName Name of the variable.
  44796. * @param array array to be set.
  44797. */
  44798. setArray2(uniformName: string, array: number[]): void;
  44799. /**
  44800. * 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)
  44801. * @param uniformName Name of the variable.
  44802. * @param array array to be set.
  44803. * @returns this effect.
  44804. */
  44805. setArray3(uniformName: string, array: number[]): void;
  44806. /**
  44807. * 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)
  44808. * @param uniformName Name of the variable.
  44809. * @param array array to be set.
  44810. */
  44811. setArray4(uniformName: string, array: number[]): void;
  44812. /**
  44813. * Sets matrices on a uniform variable.
  44814. * @param uniformName Name of the variable.
  44815. * @param matrices matrices to be set.
  44816. */
  44817. setMatrices(uniformName: string, matrices: Float32Array): void;
  44818. /**
  44819. * Sets matrix on a uniform variable.
  44820. * @param uniformName Name of the variable.
  44821. * @param matrix matrix to be set.
  44822. */
  44823. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44824. /**
  44825. * 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)
  44826. * @param uniformName Name of the variable.
  44827. * @param matrix matrix to be set.
  44828. */
  44829. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44830. /**
  44831. * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44832. * @param uniformName Name of the variable.
  44833. * @param matrix matrix to be set.
  44834. */
  44835. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44836. /**
  44837. * Sets a float on a uniform variable.
  44838. * @param uniformName Name of the variable.
  44839. * @param value value to be set.
  44840. * @returns this effect.
  44841. */
  44842. setFloat(uniformName: string, value: number): void;
  44843. /**
  44844. * Sets a Vector2 on a uniform variable.
  44845. * @param uniformName Name of the variable.
  44846. * @param vector2 vector2 to be set.
  44847. */
  44848. setVector2(uniformName: string, vector2: IVector2Like): void;
  44849. /**
  44850. * Sets a float2 on a uniform variable.
  44851. * @param uniformName Name of the variable.
  44852. * @param x First float in float2.
  44853. * @param y Second float in float2.
  44854. */
  44855. setFloat2(uniformName: string, x: number, y: number): void;
  44856. /**
  44857. * Sets a Vector3 on a uniform variable.
  44858. * @param uniformName Name of the variable.
  44859. * @param vector3 Value to be set.
  44860. */
  44861. setVector3(uniformName: string, vector3: IVector3Like): void;
  44862. /**
  44863. * Sets a float3 on a uniform variable.
  44864. * @param uniformName Name of the variable.
  44865. * @param x First float in float3.
  44866. * @param y Second float in float3.
  44867. * @param z Third float in float3.
  44868. */
  44869. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44870. /**
  44871. * Sets a Vector4 on a uniform variable.
  44872. * @param uniformName Name of the variable.
  44873. * @param vector4 Value to be set.
  44874. */
  44875. setVector4(uniformName: string, vector4: IVector4Like): void;
  44876. /**
  44877. * Sets a float4 on a uniform variable.
  44878. * @param uniformName Name of the variable.
  44879. * @param x First float in float4.
  44880. * @param y Second float in float4.
  44881. * @param z Third float in float4.
  44882. * @param w Fourth float in float4.
  44883. * @returns this effect.
  44884. */
  44885. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44886. /**
  44887. * Sets a Color3 on a uniform variable.
  44888. * @param uniformName Name of the variable.
  44889. * @param color3 Value to be set.
  44890. */
  44891. setColor3(uniformName: string, color3: IColor3Like): void;
  44892. /**
  44893. * Sets a Color4 on a uniform variable.
  44894. * @param uniformName Name of the variable.
  44895. * @param color3 Value to be set.
  44896. * @param alpha Alpha value to be set.
  44897. */
  44898. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44899. /**
  44900. * Sets a Color4 on a uniform variable
  44901. * @param uniformName defines the name of the variable
  44902. * @param color4 defines the value to be set
  44903. */
  44904. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44905. _getVertexShaderCode(): string | null;
  44906. _getFragmentShaderCode(): string | null;
  44907. }
  44908. }
  44909. declare module BABYLON {
  44910. /** @hidden */
  44911. export class WebGPUDataBuffer extends DataBuffer {
  44912. private _buffer;
  44913. constructor(resource: GPUBuffer);
  44914. get underlyingResource(): any;
  44915. }
  44916. }
  44917. declare module BABYLON {
  44918. /**
  44919. * Class used to inline functions in shader code
  44920. */
  44921. export class ShaderCodeInliner {
  44922. private static readonly _RegexpFindFunctionNameAndType;
  44923. private _sourceCode;
  44924. private _functionDescr;
  44925. private _numMaxIterations;
  44926. /** Gets or sets the token used to mark the functions to inline */
  44927. inlineToken: string;
  44928. /** Gets or sets the debug mode */
  44929. debug: boolean;
  44930. /** Gets the code after the inlining process */
  44931. get code(): string;
  44932. /**
  44933. * Initializes the inliner
  44934. * @param sourceCode shader code source to inline
  44935. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44936. */
  44937. constructor(sourceCode: string, numMaxIterations?: number);
  44938. /**
  44939. * Start the processing of the shader code
  44940. */
  44941. processCode(): void;
  44942. private _collectFunctions;
  44943. private _processInlining;
  44944. private _extractBetweenMarkers;
  44945. private _skipWhitespaces;
  44946. private _isIdentifierChar;
  44947. private _removeComments;
  44948. private _replaceFunctionCallsByCode;
  44949. private _findBackward;
  44950. private _escapeRegExp;
  44951. private _replaceNames;
  44952. }
  44953. }
  44954. declare module BABYLON {
  44955. /** @hidden */
  44956. export class WebGPUShaderProcessor implements IShaderProcessor {
  44957. protected _missingVaryings: Array<string>;
  44958. protected _textureArrayProcessing: Array<string>;
  44959. protected _preProcessors: {
  44960. [key: string]: string;
  44961. };
  44962. private _getArraySize;
  44963. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44964. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44965. [key: string]: string;
  44966. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44967. attributeProcessor(attribute: string, preProcessors: {
  44968. [key: string]: string;
  44969. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44970. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44971. [key: string]: string;
  44972. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44973. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44974. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44975. private _applyTextureArrayProcessing;
  44976. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44977. vertexCode: string;
  44978. fragmentCode: string;
  44979. };
  44980. }
  44981. }
  44982. declare module BABYLON {
  44983. /** @hidden */
  44984. export class WebGPUBufferManager {
  44985. private _device;
  44986. private _deferredReleaseBuffers;
  44987. private static _IsGPUBuffer;
  44988. constructor(device: GPUDevice);
  44989. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44990. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44991. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44992. private _FromHalfFloat;
  44993. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44994. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44995. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44996. destroyDeferredBuffers(): void;
  44997. }
  44998. }
  44999. declare module BABYLON {
  45000. /** @hidden */
  45001. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  45002. private _webgpuTexture;
  45003. private _webgpuMSAATexture;
  45004. get underlyingResource(): Nullable<GPUTexture>;
  45005. get msaaTexture(): Nullable<GPUTexture>;
  45006. set msaaTexture(texture: Nullable<GPUTexture>);
  45007. view: Nullable<GPUTextureView>;
  45008. format: GPUTextureFormat;
  45009. textureUsages: number;
  45010. constructor(existingTexture?: Nullable<GPUTexture>);
  45011. set(hardwareTexture: GPUTexture): void;
  45012. setMSAATexture(hardwareTexture: GPUTexture): void;
  45013. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  45014. createView(descriptor?: GPUTextureViewDescriptor): void;
  45015. reset(): void;
  45016. release(): void;
  45017. }
  45018. }
  45019. declare module BABYLON {
  45020. /** @hidden */
  45021. export class WebGPUTextureHelper {
  45022. private _device;
  45023. private _glslang;
  45024. private _bufferManager;
  45025. private _mipmapSampler;
  45026. private _invertYPreMultiplyAlphaSampler;
  45027. private _pipelines;
  45028. private _compiledShaders;
  45029. private _deferredReleaseTextures;
  45030. private _commandEncoderForCreation;
  45031. static ComputeNumMipmapLevels(width: number, height: number): number;
  45032. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  45033. private _getPipeline;
  45034. private static _GetTextureTypeFromFormat;
  45035. private static _GetBlockInformationFromFormat;
  45036. private static _IsHardwareTexture;
  45037. private static _IsInternalTexture;
  45038. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  45039. static IsImageBitmap(imageBitmap: ImageBitmap | {
  45040. width: number;
  45041. height: number;
  45042. }): imageBitmap is ImageBitmap;
  45043. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  45044. width: number;
  45045. height: number;
  45046. }): imageBitmap is ImageBitmap[];
  45047. setCommandEncoder(encoder: GPUCommandEncoder): void;
  45048. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  45049. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  45050. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45051. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  45052. createTexture(imageBitmap: ImageBitmap | {
  45053. width: number;
  45054. height: number;
  45055. layers: number;
  45056. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45057. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  45058. width: number;
  45059. height: number;
  45060. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  45061. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  45062. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  45063. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  45064. createMSAATexture(texture: InternalTexture, samples: number): void;
  45065. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  45066. 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;
  45067. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  45068. releaseTexture(texture: InternalTexture | GPUTexture): void;
  45069. destroyDeferredTextures(): void;
  45070. }
  45071. }
  45072. declare module BABYLON {
  45073. /** @hidden */
  45074. export class WebGPURenderPassWrapper {
  45075. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  45076. renderPass: Nullable<GPURenderPassEncoder>;
  45077. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45078. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  45079. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  45080. depthTextureFormat: GPUTextureFormat | undefined;
  45081. constructor();
  45082. reset(fullReset?: boolean): void;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /** @hidden */
  45087. export class WebGPUCacheSampler {
  45088. private _samplers;
  45089. private _device;
  45090. disabled: boolean;
  45091. constructor(device: GPUDevice);
  45092. private static _GetSamplerHashCode;
  45093. private static _GetSamplerFilterDescriptor;
  45094. private static _GetWrappingMode;
  45095. private static _GetSamplerWrappingDescriptor;
  45096. private static _GetSamplerDescriptor;
  45097. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  45098. }
  45099. }
  45100. declare module BABYLON {
  45101. /** @hidden */
  45102. export class WebGPUShaderManager {
  45103. private _shaders;
  45104. private _device;
  45105. constructor(device: GPUDevice);
  45106. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  45107. }
  45108. }
  45109. declare module BABYLON {
  45110. /** @hidden */
  45111. export abstract class WebGPUCacheRenderPipeline {
  45112. static NumCacheHitWithoutHash: number;
  45113. static NumCacheHitWithHash: number;
  45114. static NumCacheMiss: number;
  45115. static NumPipelineCreationLastFrame: number;
  45116. disabled: boolean;
  45117. private static _NumPipelineCreationCurrentFrame;
  45118. protected _states: number[];
  45119. protected _stateDirtyLowestIndex: number;
  45120. lastStateDirtyLowestIndex: number;
  45121. private _device;
  45122. private _isDirty;
  45123. private _emptyVertexBuffer;
  45124. private _parameter;
  45125. private _shaderId;
  45126. private _alphaToCoverageEnabled;
  45127. private _frontFace;
  45128. private _cullEnabled;
  45129. private _cullFace;
  45130. private _clampDepth;
  45131. private _rasterizationState;
  45132. private _depthBias;
  45133. private _depthBiasClamp;
  45134. private _depthBiasSlopeScale;
  45135. private _colorFormat;
  45136. private _webgpuColorFormat;
  45137. private _mrtAttachments1;
  45138. private _mrtAttachments2;
  45139. private _mrtFormats;
  45140. private _alphaBlendEnabled;
  45141. private _alphaBlendFuncParams;
  45142. private _alphaBlendEqParams;
  45143. private _writeMask;
  45144. private _colorStates;
  45145. private _depthStencilFormat;
  45146. private _webgpuDepthStencilFormat;
  45147. private _depthTestEnabled;
  45148. private _depthWriteEnabled;
  45149. private _depthCompare;
  45150. private _stencilEnabled;
  45151. private _stencilFrontCompare;
  45152. private _stencilFrontDepthFailOp;
  45153. private _stencilFrontPassOp;
  45154. private _stencilFrontFailOp;
  45155. private _stencilReadMask;
  45156. private _stencilWriteMask;
  45157. private _depthStencilState;
  45158. private _vertexBuffers;
  45159. private _overrideVertexBuffers;
  45160. private _indexBuffer;
  45161. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45162. reset(): void;
  45163. protected abstract _getRenderPipeline(param: {
  45164. token: any;
  45165. pipeline: Nullable<GPURenderPipeline>;
  45166. }): void;
  45167. protected abstract _setRenderPipeline(param: {
  45168. token: any;
  45169. pipeline: Nullable<GPURenderPipeline>;
  45170. }): void;
  45171. getRenderPipeline(fillMode: number, effect: Effect, sampleCount: number): GPURenderPipeline;
  45172. endFrame(): void;
  45173. setAlphaToCoverage(enabled: boolean): void;
  45174. setFrontFace(frontFace: number): void;
  45175. setCullEnabled(enabled: boolean): void;
  45176. setCullFace(cullFace: number): void;
  45177. setClampDepth(clampDepth: boolean): void;
  45178. resetDepthCullingState(): void;
  45179. setDepthCullingState(cullEnabled: boolean, frontFace: number, cullFace: number, zOffset: number, depthTestEnabled: boolean, depthWriteEnabled: boolean, depthCompare: Nullable<number>): void;
  45180. setDepthBiasSlopeScale(depthBiasSlopeScale: number): void;
  45181. setColorFormat(format: GPUTextureFormat): void;
  45182. setMRTAttachments(attachments: number[], textureArray: InternalTexture[]): void;
  45183. setAlphaBlendEnabled(enabled: boolean): void;
  45184. setAlphaBlendFactors(factors: Array<Nullable<number>>, operations: Array<Nullable<number>>): void;
  45185. setWriteMask(mask: number): void;
  45186. setDepthStencilFormat(format: GPUTextureFormat | undefined): void;
  45187. setDepthTestEnabled(enabled: boolean): void;
  45188. setDepthWriteEnabled(enabled: boolean): void;
  45189. setDepthCompare(func: Nullable<number>): void;
  45190. setStencilEnabled(enabled: boolean): void;
  45191. setStencilCompare(func: Nullable<number>): void;
  45192. setStencilDepthFailOp(op: Nullable<number>): void;
  45193. setStencilPassOp(op: Nullable<number>): void;
  45194. setStencilFailOp(op: Nullable<number>): void;
  45195. setStencilReadMask(mask: number): void;
  45196. setStencilWriteMask(mask: number): void;
  45197. resetStencilState(): void;
  45198. setStencilState(stencilEnabled: boolean, compare: Nullable<number>, depthFailOp: Nullable<number>, passOp: Nullable<number>, failOp: Nullable<number>, readMask: number, writeMask: number): void;
  45199. setBuffers(vertexBuffers: Nullable<{
  45200. [key: string]: Nullable<VertexBuffer>;
  45201. }>, indexBuffer: Nullable<DataBuffer>, overrideVertexBuffers: Nullable<{
  45202. [key: string]: Nullable<VertexBuffer>;
  45203. }>): void;
  45204. private static _GetTopology;
  45205. private static _GetAphaBlendOperation;
  45206. private static _GetAphaBlendFactor;
  45207. private static _GetCompareFunction;
  45208. private static _GetStencilOpFunction;
  45209. private static _GetVertexInputDescriptorFormat;
  45210. private _getAphaBlendState;
  45211. private _getColorBlendState;
  45212. private _setShaderStage;
  45213. private _setRasterizationState;
  45214. private _setColorStates;
  45215. private _setDepthStencilState;
  45216. private _setVertexState;
  45217. private _createPipelineLayout;
  45218. private _getVertexInputDescriptor;
  45219. private _createRenderPipeline;
  45220. }
  45221. }
  45222. declare module BABYLON {
  45223. /** @hidden */
  45224. class NodeState {
  45225. values: {
  45226. [name: number]: NodeState;
  45227. };
  45228. pipeline: GPURenderPipeline;
  45229. constructor();
  45230. count(): [number, number];
  45231. }
  45232. /** @hidden */
  45233. export class WebGPUCacheRenderPipelineTree extends WebGPUCacheRenderPipeline {
  45234. private static _Cache;
  45235. private _nodeStack;
  45236. static GetNodeCounts(): {
  45237. nodeCount: number;
  45238. pipelineCount: number;
  45239. };
  45240. constructor(device: GPUDevice, emptyVertexBuffer: VertexBuffer);
  45241. protected _getRenderPipeline(param: {
  45242. token: any;
  45243. pipeline: Nullable<GPURenderPipeline>;
  45244. }): void;
  45245. protected _setRenderPipeline(param: {
  45246. token: NodeState;
  45247. pipeline: Nullable<GPURenderPipeline>;
  45248. }): void;
  45249. }
  45250. }
  45251. declare module BABYLON {
  45252. /**
  45253. * @hidden
  45254. **/
  45255. export class WebGPUStencilState extends StencilState {
  45256. private _cache;
  45257. constructor(cache: WebGPUCacheRenderPipeline);
  45258. get stencilFunc(): number;
  45259. set stencilFunc(value: number);
  45260. get stencilFuncRef(): number;
  45261. set stencilFuncRef(value: number);
  45262. get stencilFuncMask(): number;
  45263. set stencilFuncMask(value: number);
  45264. get stencilOpStencilFail(): number;
  45265. set stencilOpStencilFail(value: number);
  45266. get stencilOpDepthFail(): number;
  45267. set stencilOpDepthFail(value: number);
  45268. get stencilOpStencilDepthPass(): number;
  45269. set stencilOpStencilDepthPass(value: number);
  45270. get stencilMask(): number;
  45271. set stencilMask(value: number);
  45272. get stencilTest(): boolean;
  45273. set stencilTest(value: boolean);
  45274. reset(): void;
  45275. apply(gl: WebGLRenderingContext): void;
  45276. }
  45277. }
  45278. declare module BABYLON {
  45279. /**
  45280. * @hidden
  45281. **/
  45282. export class WebGPUDepthCullingState extends DepthCullingState {
  45283. private _cache;
  45284. /**
  45285. * Initializes the state.
  45286. */
  45287. constructor(cache: WebGPUCacheRenderPipeline);
  45288. get zOffset(): number;
  45289. set zOffset(value: number);
  45290. get cullFace(): Nullable<number>;
  45291. set cullFace(value: Nullable<number>);
  45292. get cull(): Nullable<boolean>;
  45293. set cull(value: Nullable<boolean>);
  45294. get depthFunc(): Nullable<number>;
  45295. set depthFunc(value: Nullable<number>);
  45296. get depthMask(): boolean;
  45297. set depthMask(value: boolean);
  45298. get depthTest(): boolean;
  45299. set depthTest(value: boolean);
  45300. get frontFace(): Nullable<number>;
  45301. set frontFace(value: Nullable<number>);
  45302. reset(): void;
  45303. apply(gl: WebGLRenderingContext): void;
  45304. }
  45305. }
  45306. declare module BABYLON {
  45307. /** @hidden */
  45308. export var clearQuadVertexShader: {
  45309. name: string;
  45310. shader: string;
  45311. };
  45312. }
  45313. declare module BABYLON {
  45314. /** @hidden */
  45315. export var clearQuadPixelShader: {
  45316. name: string;
  45317. shader: string;
  45318. };
  45319. }
  45320. declare module BABYLON {
  45321. /**
  45322. * Options to load the associated Glslang library
  45323. */
  45324. export interface GlslangOptions {
  45325. /**
  45326. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  45327. */
  45328. glslang?: any;
  45329. /**
  45330. * Defines the URL of the glslang JS File.
  45331. */
  45332. jsPath?: string;
  45333. /**
  45334. * Defines the URL of the glslang WASM File.
  45335. */
  45336. wasmPath?: string;
  45337. }
  45338. /**
  45339. * Options to create the WebGPU engine
  45340. */
  45341. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  45342. /**
  45343. * If delta time between frames should be constant
  45344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45345. */
  45346. deterministicLockstep?: boolean;
  45347. /**
  45348. * Maximum about of steps between frames (Default: 4)
  45349. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45350. */
  45351. lockstepMaxSteps?: number;
  45352. /**
  45353. * Defines the seconds between each deterministic lock step
  45354. */
  45355. timeStep?: number;
  45356. /**
  45357. * Defines that engine should ignore modifying touch action attribute and style
  45358. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  45359. */
  45360. doNotHandleTouchAction?: boolean;
  45361. /**
  45362. * Defines if webaudio should be initialized as well
  45363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  45364. */
  45365. audioEngine?: boolean;
  45366. /**
  45367. * Defines the category of adapter to use.
  45368. * Is it the discrete or integrated device.
  45369. */
  45370. powerPreference?: GPUPowerPreference;
  45371. /**
  45372. * Defines the device descriptor used to create a device.
  45373. */
  45374. deviceDescriptor?: GPUDeviceDescriptor;
  45375. /**
  45376. * Defines the requested Swap Chain Format.
  45377. */
  45378. swapChainFormat?: GPUTextureFormat;
  45379. /**
  45380. * Defines whether MSAA is enabled on the canvas.
  45381. */
  45382. antialiasing?: boolean;
  45383. /**
  45384. * Defines whether the stencil buffer should be enabled.
  45385. */
  45386. stencil?: boolean;
  45387. /**
  45388. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  45389. */
  45390. enableGPUDebugMarkers?: boolean;
  45391. /**
  45392. * Options to load the associated Glslang library
  45393. */
  45394. glslangOptions?: GlslangOptions;
  45395. }
  45396. /**
  45397. * The web GPU engine class provides support for WebGPU version of babylon.js.
  45398. */
  45399. export class WebGPUEngine extends Engine {
  45400. private static readonly _glslangDefaultOptions;
  45401. private readonly _uploadEncoderDescriptor;
  45402. private readonly _renderEncoderDescriptor;
  45403. private readonly _renderTargetEncoderDescriptor;
  45404. private readonly _clearDepthValue;
  45405. private readonly _clearReverseDepthValue;
  45406. private readonly _clearStencilValue;
  45407. private readonly _defaultSampleCount;
  45408. private _canvas;
  45409. private _options;
  45410. private _glslang;
  45411. private _adapter;
  45412. private _adapterSupportedExtensions;
  45413. private _device;
  45414. private _deviceEnabledExtensions;
  45415. private _context;
  45416. private _swapChain;
  45417. private _swapChainTexture;
  45418. private _mainPassSampleCount;
  45419. private _textureHelper;
  45420. private _bufferManager;
  45421. private _shaderManager;
  45422. private _cacheSampler;
  45423. private _cacheRenderPipeline;
  45424. private _emptyVertexBuffer;
  45425. private _lastCachedWrapU;
  45426. private _lastCachedWrapV;
  45427. private _lastCachedWrapR;
  45428. private _mrtAttachments;
  45429. private _counters;
  45430. private _mainTexture;
  45431. private _depthTexture;
  45432. private _mainTextureExtends;
  45433. private _depthTextureFormat;
  45434. private _colorFormat;
  45435. private _uploadEncoder;
  45436. private _renderEncoder;
  45437. private _renderTargetEncoder;
  45438. private _commandBuffers;
  45439. private _currentRenderPass;
  45440. private _mainRenderPassWrapper;
  45441. private _rttRenderPassWrapper;
  45442. private _pendingDebugCommands;
  45443. private _currentVertexBuffers;
  45444. private _currentOverrideVertexBuffers;
  45445. private _currentIndexBuffer;
  45446. private __colorWrite;
  45447. private _uniformsBuffers;
  45448. private _forceEnableEffect;
  45449. /** @hidden */
  45450. dbgShowShaderCode: boolean;
  45451. /** @hidden */
  45452. dbgSanityChecks: boolean;
  45453. /** @hidden */
  45454. dbgGenerateLogs: boolean;
  45455. /** @hidden */
  45456. dbgVerboseLogsForFirstFrames: boolean;
  45457. /** @hidden */
  45458. dbgVerboseLogsNumFrames: number;
  45459. /** @hidden */
  45460. dbgShowWarningsNotImplemented: boolean;
  45461. /**
  45462. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  45463. */
  45464. get disableCacheSamplers(): boolean;
  45465. set disableCacheSamplers(disable: boolean);
  45466. /**
  45467. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  45468. */
  45469. get disableCacheRenderPipelines(): boolean;
  45470. set disableCacheRenderPipelines(disable: boolean);
  45471. /**
  45472. * Gets a boolean indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  45473. * @returns true if the engine can be created
  45474. */
  45475. static get IsSupported(): boolean;
  45476. /**
  45477. * Gets a boolean indicating that the engine supports uniform buffers
  45478. */
  45479. get supportsUniformBuffers(): boolean;
  45480. /** Gets the supported extensions by the WebGPU adapter */
  45481. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  45482. /** Gets the currently enabled extensions on the WebGPU device */
  45483. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  45484. /**
  45485. * Returns the name of the engine
  45486. */
  45487. get name(): string;
  45488. /**
  45489. * Returns a string describing the current engine
  45490. */
  45491. get description(): string;
  45492. /**
  45493. * Returns the version of the engine
  45494. */
  45495. get version(): number;
  45496. /**
  45497. * Create a new instance of the gpu engine asynchronously
  45498. * @param canvas Defines the canvas to use to display the result
  45499. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45500. * @returns a promise that resolves with the created engine
  45501. */
  45502. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  45503. /**
  45504. * Create a new instance of the gpu engine.
  45505. * @param canvas Defines the canvas to use to display the result
  45506. * @param options Defines the options passed to the engine to create the GPU context dependencies
  45507. */
  45508. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  45509. /**
  45510. * Initializes the WebGPU context and dependencies.
  45511. * @param glslangOptions Defines the GLSLang compiler options if necessary
  45512. * @returns a promise notifying the readiness of the engine.
  45513. */
  45514. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  45515. private _initGlslang;
  45516. private _initializeLimits;
  45517. private _initializeContextAndSwapChain;
  45518. private _initializeMainAttachments;
  45519. /**
  45520. * Force a specific size of the canvas
  45521. * @param width defines the new canvas' width
  45522. * @param height defines the new canvas' height
  45523. * @param forceSetSize true to force setting the sizes of the underlying canvas
  45524. * @returns true if the size was changed
  45525. */
  45526. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  45527. /**
  45528. * Gets a shader processor implementation fitting with the current engine type.
  45529. * @returns The shader processor implementation.
  45530. */
  45531. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  45532. /** @hidden */
  45533. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  45534. /**
  45535. * Force the entire cache to be cleared
  45536. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  45537. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45538. */
  45539. wipeCaches(bruteForce?: boolean): void;
  45540. /**
  45541. * Enable or disable color writing
  45542. * @param enable defines the state to set
  45543. */
  45544. setColorWrite(enable: boolean): void;
  45545. /**
  45546. * Gets a boolean indicating if color writing is enabled
  45547. * @returns the current color writing state
  45548. */
  45549. getColorWrite(): boolean;
  45550. private _viewportsCurrent;
  45551. private _resetCurrentViewport;
  45552. private _applyViewport;
  45553. /** @hidden */
  45554. _viewport(x: number, y: number, width: number, height: number): void;
  45555. private _scissorsCurrent;
  45556. protected _scissorCached: {
  45557. x: number;
  45558. y: number;
  45559. z: number;
  45560. w: number;
  45561. };
  45562. private _resetCurrentScissor;
  45563. private _applyScissor;
  45564. private _scissorIsActive;
  45565. enableScissor(x: number, y: number, width: number, height: number): void;
  45566. disableScissor(): void;
  45567. /**
  45568. * Clear the current render buffer or the current render target (if any is set up)
  45569. * @param color defines the color to use
  45570. * @param backBuffer defines if the back buffer must be cleared
  45571. * @param depth defines if the depth buffer must be cleared
  45572. * @param stencil defines if the stencil buffer must be cleared
  45573. */
  45574. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45575. /**
  45576. * Clears a list of attachments
  45577. * @param attachments list of the attachments
  45578. * @param colorMain clear color for the main attachment (the first one)
  45579. * @param colorOthers clear color for the other attachments
  45580. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  45581. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  45582. */
  45583. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  45584. /**
  45585. * Creates a vertex buffer
  45586. * @param data the data for the vertex buffer
  45587. * @returns the new buffer
  45588. */
  45589. createVertexBuffer(data: DataArray): DataBuffer;
  45590. /**
  45591. * Creates a vertex buffer
  45592. * @param data the data for the dynamic vertex buffer
  45593. * @returns the new buffer
  45594. */
  45595. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45596. /**
  45597. * Updates a vertex buffer.
  45598. * @param vertexBuffer the vertex buffer to update
  45599. * @param data the data used to update the vertex buffer
  45600. * @param byteOffset the byte offset of the data
  45601. * @param byteLength the byte length of the data
  45602. */
  45603. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45604. /**
  45605. * Creates a new index buffer
  45606. * @param indices defines the content of the index buffer
  45607. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  45608. * @returns a new buffer
  45609. */
  45610. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  45611. /**
  45612. * Update an index buffer
  45613. * @param indexBuffer defines the target index buffer
  45614. * @param indices defines the data to update
  45615. * @param offset defines the offset in the target index buffer where update should start
  45616. */
  45617. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45618. /** @hidden */
  45619. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  45620. /** @hidden */
  45621. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  45622. /**
  45623. * Bind a list of vertex buffers with the engine
  45624. * @param vertexBuffers defines the list of vertex buffers to bind
  45625. * @param indexBuffer defines the index buffer to bind
  45626. * @param effect defines the effect associated with the vertex buffers
  45627. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  45628. */
  45629. bindBuffers(vertexBuffers: {
  45630. [key: string]: Nullable<VertexBuffer>;
  45631. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  45632. [kind: string]: Nullable<VertexBuffer>;
  45633. }): void;
  45634. /** @hidden */
  45635. _releaseBuffer(buffer: DataBuffer): boolean;
  45636. createUniformBuffer(elements: FloatArray): DataBuffer;
  45637. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45638. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45639. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45640. /**
  45641. * Create a new effect (used to store vertex/fragment shaders)
  45642. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45643. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45644. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45645. * @param samplers defines an array of string used to represent textures
  45646. * @param defines defines the string containing the defines to use to compile the shaders
  45647. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  45648. * @param onCompiled defines a function to call when the effect creation is successful
  45649. * @param onError defines a function to call when the effect creation has failed
  45650. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45651. * @returns the new Effect
  45652. */
  45653. 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;
  45654. private _compileRawShaderToSpirV;
  45655. private _compileShaderToSpirV;
  45656. private _createPipelineStageDescriptor;
  45657. private _compileRawPipelineStageDescriptor;
  45658. private _compilePipelineStageDescriptor;
  45659. /** @hidden */
  45660. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45661. /** @hidden */
  45662. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45663. /**
  45664. * Creates a new pipeline context
  45665. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45666. * @returns the new pipeline
  45667. */
  45668. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45669. /** @hidden */
  45670. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45671. /**
  45672. * Gets the list of active attributes for a given WebGPU program
  45673. * @param pipelineContext defines the pipeline context to use
  45674. * @param attributesNames defines the list of attribute names to get
  45675. * @returns an array of indices indicating the offset of each attribute
  45676. */
  45677. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45678. /**
  45679. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45680. * @param effect defines the effect to activate
  45681. */
  45682. enableEffect(effect: Nullable<Effect>): void;
  45683. /** @hidden */
  45684. _releaseEffect(effect: Effect): void;
  45685. /**
  45686. * 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
  45687. */
  45688. releaseEffects(): void;
  45689. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45690. /**
  45691. * Gets a boolean indicating that only power of 2 textures are supported
  45692. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45693. */
  45694. get needPOTTextures(): boolean;
  45695. /** @hidden */
  45696. _createHardwareTexture(): HardwareTextureWrapper;
  45697. /** @hidden */
  45698. _releaseTexture(texture: InternalTexture): void;
  45699. /** @hidden */
  45700. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45701. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45702. /**
  45703. * Usually called from Texture.ts.
  45704. * Passed information to create a hardware texture
  45705. * @param url defines a value which contains one of the following:
  45706. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45707. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45708. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45709. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45710. * @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)
  45711. * @param scene needed for loading to the correct scene
  45712. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45713. * @param onLoad optional callback to be called upon successful completion
  45714. * @param onError optional callback to be called upon failure
  45715. * @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
  45716. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45717. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45718. * @param forcedExtension defines the extension to use to pick the right loader
  45719. * @param mimeType defines an optional mime type
  45720. * @param loaderOptions options to be passed to the loader
  45721. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45722. */
  45723. 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;
  45724. /** @hidden */
  45725. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45726. /**
  45727. * Creates a cube texture
  45728. * @param rootUrl defines the url where the files to load is located
  45729. * @param scene defines the current scene
  45730. * @param files defines the list of files to load (1 per face)
  45731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45732. * @param onLoad defines an optional callback raised when the texture is loaded
  45733. * @param onError defines an optional callback raised if there is an issue to load the texture
  45734. * @param format defines the format of the data
  45735. * @param forcedExtension defines the extension to use to pick the right loader
  45736. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45737. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45738. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45739. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45740. * @param loaderOptions options to be passed to the loader
  45741. * @returns the cube texture as an InternalTexture
  45742. */
  45743. 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;
  45744. /**
  45745. * Creates a raw texture
  45746. * @param data defines the data to store in the texture
  45747. * @param width defines the width of the texture
  45748. * @param height defines the height of the texture
  45749. * @param format defines the format of the data
  45750. * @param generateMipMaps defines if the engine should generate the mip levels
  45751. * @param invertY defines if data must be stored with Y axis inverted
  45752. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45753. * @param compression defines the compression used (null by default)
  45754. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45755. * @returns the raw texture inside an InternalTexture
  45756. */
  45757. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45758. /**
  45759. * Creates a new raw cube texture
  45760. * @param data defines the array of data to use to create each face
  45761. * @param size defines the size of the textures
  45762. * @param format defines the format of the data
  45763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45764. * @param generateMipMaps defines if the engine should generate the mip levels
  45765. * @param invertY defines if data must be stored with Y axis inverted
  45766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45767. * @param compression defines the compression used (null by default)
  45768. * @returns the cube texture as an InternalTexture
  45769. */
  45770. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45771. /**
  45772. * Creates a new raw cube texture from a specified url
  45773. * @param url defines the url where the data is located
  45774. * @param scene defines the current scene
  45775. * @param size defines the size of the textures
  45776. * @param format defines the format of the data
  45777. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45778. * @param noMipmap defines if the engine should avoid generating the mip levels
  45779. * @param callback defines a callback used to extract texture data from loaded data
  45780. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45781. * @param onLoad defines a callback called when texture is loaded
  45782. * @param onError defines a callback called if there is an error
  45783. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45784. * @param invertY defines if data must be stored with Y axis inverted
  45785. * @returns the cube texture as an InternalTexture
  45786. */
  45787. 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;
  45788. /**
  45789. * Creates a new raw 2D array texture
  45790. * @param data defines the data used to create the texture
  45791. * @param width defines the width of the texture
  45792. * @param height defines the height of the texture
  45793. * @param depth defines the number of layers of the texture
  45794. * @param format defines the format of the texture
  45795. * @param generateMipMaps defines if the engine must generate mip levels
  45796. * @param invertY defines if data must be stored with Y axis inverted
  45797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45798. * @param compression defines the compressed used (can be null)
  45799. * @param textureType defines the compressed used (can be null)
  45800. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45801. */
  45802. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45803. /**
  45804. * Creates a new raw 3D texture
  45805. * @param data defines the data used to create the texture
  45806. * @param width defines the width of the texture
  45807. * @param height defines the height of the texture
  45808. * @param depth defines the depth of the texture
  45809. * @param format defines the format of the texture
  45810. * @param generateMipMaps defines if the engine must generate mip levels
  45811. * @param invertY defines if data must be stored with Y axis inverted
  45812. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45813. * @param compression defines the compressed used (can be null)
  45814. * @param textureType defines the compressed used (can be null)
  45815. * @returns a new raw 3D texture (stored in an InternalTexture)
  45816. */
  45817. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45818. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45819. /**
  45820. * Update the sampling mode of a given texture
  45821. * @param samplingMode defines the required sampling mode
  45822. * @param texture defines the texture to update
  45823. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45824. */
  45825. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45826. /**
  45827. * Update the sampling mode of a given texture
  45828. * @param texture defines the texture to update
  45829. * @param wrapU defines the texture wrap mode of the u coordinates
  45830. * @param wrapV defines the texture wrap mode of the v coordinates
  45831. * @param wrapR defines the texture wrap mode of the r coordinates
  45832. */
  45833. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45834. /**
  45835. * Update the dimensions of a texture
  45836. * @param texture texture to update
  45837. * @param width new width of the texture
  45838. * @param height new height of the texture
  45839. * @param depth new depth of the texture
  45840. */
  45841. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45842. private _setInternalTexture;
  45843. /**
  45844. * Sets a texture to the according uniform.
  45845. * @param channel The texture channel
  45846. * @param unused unused parameter
  45847. * @param texture The texture to apply
  45848. * @param name The name of the uniform in the effect
  45849. */
  45850. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45851. /**
  45852. * Sets an array of texture to the WebGPU context
  45853. * @param channel defines the channel where the texture array must be set
  45854. * @param unused unused parameter
  45855. * @param textures defines the array of textures to bind
  45856. * @param name name of the channel
  45857. */
  45858. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45859. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45860. /** @hidden */
  45861. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45862. /** @hidden */
  45863. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45864. private _generateMipmaps;
  45865. /**
  45866. * Update the content of a texture
  45867. * @param texture defines the texture to update
  45868. * @param canvas defines the source containing the data
  45869. * @param invertY defines if data must be stored with Y axis inverted
  45870. * @param premulAlpha defines if alpha is stored as premultiplied
  45871. * @param format defines the format of the data
  45872. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45873. */
  45874. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45875. /**
  45876. * Update a portion of an internal texture
  45877. * @param texture defines the texture to update
  45878. * @param imageData defines the data to store into the texture
  45879. * @param xOffset defines the x coordinates of the update rectangle
  45880. * @param yOffset defines the y coordinates of the update rectangle
  45881. * @param width defines the width of the update rectangle
  45882. * @param height defines the height of the update rectangle
  45883. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45884. * @param lod defines the lod level to update (0 by default)
  45885. */
  45886. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45887. /**
  45888. * Update a video texture
  45889. * @param texture defines the texture to update
  45890. * @param video defines the video element to use
  45891. * @param invertY defines if data must be stored with Y axis inverted
  45892. */
  45893. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45894. /** @hidden */
  45895. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45896. /** @hidden */
  45897. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45898. /** @hidden */
  45899. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45900. /** @hidden */
  45901. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45902. /**
  45903. * Update a raw texture
  45904. * @param texture defines the texture to update
  45905. * @param bufferView defines the data to store in the texture
  45906. * @param format defines the format of the data
  45907. * @param invertY defines if data must be stored with Y axis inverted
  45908. * @param compression defines the compression used (null by default)
  45909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45910. */
  45911. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45912. /**
  45913. * Update a raw cube texture
  45914. * @param texture defines the texture to update
  45915. * @param bufferView defines the data to store
  45916. * @param format defines the data format
  45917. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45918. * @param invertY defines if data must be stored with Y axis inverted
  45919. * @param compression defines the compression used (null by default)
  45920. * @param level defines which level of the texture to update
  45921. */
  45922. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45923. /**
  45924. * Update a raw 2D array texture
  45925. * @param texture defines the texture to update
  45926. * @param bufferView defines the data to store
  45927. * @param format defines the data format
  45928. * @param invertY defines if data must be stored with Y axis inverted
  45929. * @param compression defines the used compression (can be null)
  45930. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45931. */
  45932. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45933. /**
  45934. * Update a raw 3D texture
  45935. * @param texture defines the texture to update
  45936. * @param bufferView defines the data to store
  45937. * @param format defines the data format
  45938. * @param invertY defines if data must be stored with Y axis inverted
  45939. * @param compression defines the used compression (can be null)
  45940. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45941. */
  45942. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45943. /**
  45944. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45945. * @param x defines the x coordinate of the rectangle where pixels must be read
  45946. * @param y defines the y coordinate of the rectangle where pixels must be read
  45947. * @param width defines the width of the rectangle where pixels must be read
  45948. * @param height defines the height of the rectangle where pixels must be read
  45949. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45950. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45951. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45952. */
  45953. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45954. /** @hidden */
  45955. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45956. /** @hidden */
  45957. _readTexturePixelsSync(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): ArrayBufferView;
  45958. /**
  45959. * Creates a new render target texture
  45960. * @param size defines the size of the texture
  45961. * @param options defines the options used to create the texture
  45962. * @returns a new render target texture stored in an InternalTexture
  45963. */
  45964. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45965. /**
  45966. * Create a multi render target texture
  45967. * @param size defines the size of the texture
  45968. * @param options defines the creation options
  45969. * @returns the cube texture as an InternalTexture
  45970. */
  45971. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45972. /**
  45973. * Creates a new render target cube texture
  45974. * @param size defines the size of the texture
  45975. * @param options defines the options used to create the texture
  45976. * @returns a new render target cube texture stored in an InternalTexture
  45977. */
  45978. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45979. /** @hidden */
  45980. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45981. width: number;
  45982. height: number;
  45983. layers?: number;
  45984. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45985. /** @hidden */
  45986. _createDepthStencilTexture(size: number | {
  45987. width: number;
  45988. height: number;
  45989. layers?: number;
  45990. }, options: DepthTextureCreationOptions): InternalTexture;
  45991. /** @hidden */
  45992. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45993. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45994. /**
  45995. * Update the sample count for a given multiple render target texture
  45996. * @param textures defines the textures to update
  45997. * @param samples defines the sample count to set
  45998. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45999. */
  46000. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46001. /**
  46002. * Begin a new frame
  46003. */
  46004. beginFrame(): void;
  46005. /**
  46006. * End the current frame
  46007. */
  46008. endFrame(): void;
  46009. /**
  46010. * Force a WebGPU flush (ie. a flush of all waiting commands)
  46011. */
  46012. flushFramebuffer(): void;
  46013. private _startRenderTargetRenderPass;
  46014. private _endRenderTargetRenderPass;
  46015. private _getCurrentRenderPass;
  46016. private _startMainRenderPass;
  46017. private _endMainRenderPass;
  46018. /**
  46019. * Restores the WebGPU state to only draw on the main color attachment
  46020. */
  46021. restoreSingleAttachment(): void;
  46022. /**
  46023. * Creates a layout object to draw/clear on specific textures in a MRT
  46024. * @param textureStatus textureStatus[i] indicates if the i-th is active
  46025. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  46026. */
  46027. buildTextureLayout(textureStatus: boolean[]): number[];
  46028. /**
  46029. * Select a subsets of attachments to draw to.
  46030. * @param attachments index of attachments
  46031. */
  46032. bindAttachments(attachments: number[]): void;
  46033. /**
  46034. * Binds the frame buffer to the specified texture.
  46035. * @param texture The texture to render to or null for the default canvas
  46036. * @param faceIndex The face of the texture to render to in case of cube texture
  46037. * @param requiredWidth The width of the target to render to
  46038. * @param requiredHeight The height of the target to render to
  46039. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46040. * @param lodLevel defines the lod level to bind to the frame buffer
  46041. * @param layer defines the 2d array index to bind to frame buffer to
  46042. */
  46043. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  46044. /**
  46045. * Unbind the current render target texture from the WebGPU context
  46046. * @param texture defines the render target texture to unbind
  46047. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46048. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46049. */
  46050. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46051. /**
  46052. * Unbind a list of render target textures from the WebGPU context
  46053. * @param textures defines the render target textures to unbind
  46054. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46055. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46056. */
  46057. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46058. /**
  46059. * Unbind the current render target and bind the default framebuffer
  46060. */
  46061. restoreDefaultFramebuffer(): void;
  46062. private _setColorFormat;
  46063. private _setDepthTextureFormat;
  46064. setDitheringState(value: boolean): void;
  46065. setRasterizerState(value: boolean): void;
  46066. /**
  46067. * Set various states to the context
  46068. * @param culling defines backface culling state
  46069. * @param zOffset defines the value to apply to zOffset (0 by default)
  46070. * @param force defines if states must be applied even if cache is up to date
  46071. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46072. */
  46073. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46074. /**
  46075. * Sets the current alpha mode
  46076. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46077. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46079. */
  46080. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46081. /**
  46082. * Sets the current alpha equation
  46083. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  46084. */
  46085. setAlphaEquation(equation: number): void;
  46086. private _getBindGroupsToRender;
  46087. private _bindVertexInputs;
  46088. private _setRenderBindGroups;
  46089. private _setRenderPipeline;
  46090. /**
  46091. * Draw a list of indexed primitives
  46092. * @param fillMode defines the primitive to use
  46093. * @param indexStart defines the starting index
  46094. * @param indexCount defines the number of index to draw
  46095. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46096. */
  46097. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46098. /**
  46099. * Draw a list of unindexed primitives
  46100. * @param fillMode defines the primitive to use
  46101. * @param verticesStart defines the index of first vertex to draw
  46102. * @param verticesCount defines the count of vertices to draw
  46103. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  46104. */
  46105. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46106. private _bundleEncoder;
  46107. /**
  46108. * Start recording all the gpu calls into a bundle.
  46109. */
  46110. startRecordBundle(): void;
  46111. /**
  46112. * Stops recording the bundle.
  46113. * @returns the recorded bundle
  46114. */
  46115. stopRecordBundle(): GPURenderBundle;
  46116. /**
  46117. * Execute the previously recorded bundle.
  46118. * @param bundles defines the bundle to replay
  46119. */
  46120. executeBundles(bundles: GPURenderBundle[]): void;
  46121. /**
  46122. * Dispose and release all associated resources
  46123. */
  46124. dispose(): void;
  46125. /**
  46126. * Gets the current render width
  46127. * @param useScreen defines if screen size must be used (or the current render target if any)
  46128. * @returns a number defining the current render width
  46129. */
  46130. getRenderWidth(useScreen?: boolean): number;
  46131. /**
  46132. * Gets the current render height
  46133. * @param useScreen defines if screen size must be used (or the current render target if any)
  46134. * @returns a number defining the current render height
  46135. */
  46136. getRenderHeight(useScreen?: boolean): number;
  46137. /**
  46138. * Gets the HTML canvas attached with the current WebGPU context
  46139. * @returns a HTML canvas
  46140. */
  46141. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  46142. /** @hidden */
  46143. _debugPushGroup(groupName: string, targetObject?: number): void;
  46144. /** @hidden */
  46145. _debugPopGroup(targetObject?: number): void;
  46146. /** @hidden */
  46147. _debugInsertMarker(text: string, targetObject?: number): void;
  46148. private _debugFlushPendingCommands;
  46149. /**
  46150. * Get the current error code of the WebGPU context
  46151. * @returns the error code
  46152. */
  46153. getError(): number;
  46154. /** @hidden */
  46155. bindSamplers(effect: Effect): void;
  46156. /** @hidden */
  46157. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  46158. /** @hidden */
  46159. _releaseFramebufferObjects(texture: InternalTexture): void;
  46160. /** @hidden */
  46161. applyStates(): void;
  46162. /**
  46163. * Gets a boolean indicating if all created effects are ready
  46164. * @returns always true - No parallel shader compilation
  46165. */
  46166. areAllEffectsReady(): boolean;
  46167. /** @hidden */
  46168. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46169. /** @hidden */
  46170. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46171. /** @hidden */
  46172. _getUnpackAlignement(): number;
  46173. /** @hidden */
  46174. _unpackFlipY(value: boolean): void;
  46175. /** @hidden */
  46176. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  46177. min: number;
  46178. mag: number;
  46179. };
  46180. /** @hidden */
  46181. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46182. /** @hidden */
  46183. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46184. /** @hidden */
  46185. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46186. /** @hidden */
  46187. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46188. /** @hidden */
  46189. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46190. /** @hidden */
  46191. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  46192. /** @hidden */
  46193. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  46194. /** @hidden */
  46195. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  46196. /** @hidden */
  46197. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  46198. /** @hidden */
  46199. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  46200. /** @hidden */
  46201. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  46202. /** @hidden */
  46203. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46204. /** @hidden */
  46205. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  46206. /** @hidden */
  46207. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  46208. /** @hidden */
  46209. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  46210. /** @hidden */
  46211. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  46212. /** @hidden */
  46213. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  46214. }
  46215. }
  46216. declare module BABYLON {
  46217. /**
  46218. * Define an interface for all classes that will hold resources
  46219. */
  46220. export interface IDisposable {
  46221. /**
  46222. * Releases all held resources
  46223. */
  46224. dispose(): void;
  46225. }
  46226. /** Interface defining initialization parameters for Scene class */
  46227. export interface SceneOptions {
  46228. /**
  46229. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  46230. * It will improve performance when the number of geometries becomes important.
  46231. */
  46232. useGeometryUniqueIdsMap?: boolean;
  46233. /**
  46234. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  46235. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46236. */
  46237. useMaterialMeshMap?: boolean;
  46238. /**
  46239. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  46240. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  46241. */
  46242. useClonedMeshMap?: boolean;
  46243. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  46244. virtual?: boolean;
  46245. }
  46246. /**
  46247. * Represents a scene to be rendered by the engine.
  46248. * @see https://doc.babylonjs.com/features/scene
  46249. */
  46250. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  46251. /** The fog is deactivated */
  46252. static readonly FOGMODE_NONE: number;
  46253. /** The fog density is following an exponential function */
  46254. static readonly FOGMODE_EXP: number;
  46255. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  46256. static readonly FOGMODE_EXP2: number;
  46257. /** The fog density is following a linear function. */
  46258. static readonly FOGMODE_LINEAR: number;
  46259. /**
  46260. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  46261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46262. */
  46263. static MinDeltaTime: number;
  46264. /**
  46265. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  46266. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46267. */
  46268. static MaxDeltaTime: number;
  46269. /**
  46270. * Factory used to create the default material.
  46271. * @param name The name of the material to create
  46272. * @param scene The scene to create the material for
  46273. * @returns The default material
  46274. */
  46275. static DefaultMaterialFactory(scene: Scene): Material;
  46276. /**
  46277. * Factory used to create the a collision coordinator.
  46278. * @returns The collision coordinator
  46279. */
  46280. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  46281. /** @hidden */
  46282. _inputManager: InputManager;
  46283. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  46284. cameraToUseForPointers: Nullable<Camera>;
  46285. /** @hidden */
  46286. readonly _isScene: boolean;
  46287. /** @hidden */
  46288. _blockEntityCollection: boolean;
  46289. /**
  46290. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  46291. */
  46292. autoClear: boolean;
  46293. /**
  46294. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  46295. */
  46296. autoClearDepthAndStencil: boolean;
  46297. /**
  46298. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  46299. */
  46300. clearColor: Color4;
  46301. /**
  46302. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  46303. */
  46304. ambientColor: Color3;
  46305. /**
  46306. * This is use to store the default BRDF lookup for PBR materials in your scene.
  46307. * It should only be one of the following (if not the default embedded one):
  46308. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46309. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  46310. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46311. * The material properties need to be setup according to the type of texture in use.
  46312. */
  46313. environmentBRDFTexture: BaseTexture;
  46314. /**
  46315. * Texture used in all pbr material as the reflection texture.
  46316. * As in the majority of the scene they are the same (exception for multi room and so on),
  46317. * this is easier to reference from here than from all the materials.
  46318. */
  46319. get environmentTexture(): Nullable<BaseTexture>;
  46320. /**
  46321. * Texture used in all pbr material as the reflection texture.
  46322. * As in the majority of the scene they are the same (exception for multi room and so on),
  46323. * this is easier to set here than in all the materials.
  46324. */
  46325. set environmentTexture(value: Nullable<BaseTexture>);
  46326. /** @hidden */
  46327. protected _environmentIntensity: number;
  46328. /**
  46329. * Intensity of the environment in all pbr material.
  46330. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46331. * As in the majority of the scene they are the same (exception for multi room and so on),
  46332. * this is easier to reference from here than from all the materials.
  46333. */
  46334. get environmentIntensity(): number;
  46335. /**
  46336. * Intensity of the environment in all pbr material.
  46337. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  46338. * As in the majority of the scene they are the same (exception for multi room and so on),
  46339. * this is easier to set here than in all the materials.
  46340. */
  46341. set environmentIntensity(value: number);
  46342. /** @hidden */
  46343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46344. /**
  46345. * Default image processing configuration used either in the rendering
  46346. * Forward main pass or through the imageProcessingPostProcess if present.
  46347. * As in the majority of the scene they are the same (exception for multi camera),
  46348. * this is easier to reference from here than from all the materials and post process.
  46349. *
  46350. * No setter as we it is a shared configuration, you can set the values instead.
  46351. */
  46352. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  46353. private _forceWireframe;
  46354. /**
  46355. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  46356. */
  46357. set forceWireframe(value: boolean);
  46358. get forceWireframe(): boolean;
  46359. private _skipFrustumClipping;
  46360. /**
  46361. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  46362. */
  46363. set skipFrustumClipping(value: boolean);
  46364. get skipFrustumClipping(): boolean;
  46365. private _forcePointsCloud;
  46366. /**
  46367. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  46368. */
  46369. set forcePointsCloud(value: boolean);
  46370. get forcePointsCloud(): boolean;
  46371. /**
  46372. * Gets or sets the active clipplane 1
  46373. */
  46374. clipPlane: Nullable<Plane>;
  46375. /**
  46376. * Gets or sets the active clipplane 2
  46377. */
  46378. clipPlane2: Nullable<Plane>;
  46379. /**
  46380. * Gets or sets the active clipplane 3
  46381. */
  46382. clipPlane3: Nullable<Plane>;
  46383. /**
  46384. * Gets or sets the active clipplane 4
  46385. */
  46386. clipPlane4: Nullable<Plane>;
  46387. /**
  46388. * Gets or sets the active clipplane 5
  46389. */
  46390. clipPlane5: Nullable<Plane>;
  46391. /**
  46392. * Gets or sets the active clipplane 6
  46393. */
  46394. clipPlane6: Nullable<Plane>;
  46395. /**
  46396. * Gets or sets a boolean indicating if animations are enabled
  46397. */
  46398. animationsEnabled: boolean;
  46399. private _animationPropertiesOverride;
  46400. /**
  46401. * Gets or sets the animation properties override
  46402. */
  46403. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  46404. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  46405. /**
  46406. * Gets or sets a boolean indicating if a constant deltatime has to be used
  46407. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  46408. */
  46409. useConstantAnimationDeltaTime: boolean;
  46410. /**
  46411. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  46412. * Please note that it requires to run a ray cast through the scene on every frame
  46413. */
  46414. constantlyUpdateMeshUnderPointer: boolean;
  46415. /**
  46416. * Defines the HTML cursor to use when hovering over interactive elements
  46417. */
  46418. hoverCursor: string;
  46419. /**
  46420. * Defines the HTML default cursor to use (empty by default)
  46421. */
  46422. defaultCursor: string;
  46423. /**
  46424. * Defines whether cursors are handled by the scene.
  46425. */
  46426. doNotHandleCursors: boolean;
  46427. /**
  46428. * This is used to call preventDefault() on pointer down
  46429. * in order to block unwanted artifacts like system double clicks
  46430. */
  46431. preventDefaultOnPointerDown: boolean;
  46432. /**
  46433. * This is used to call preventDefault() on pointer up
  46434. * in order to block unwanted artifacts like system double clicks
  46435. */
  46436. preventDefaultOnPointerUp: boolean;
  46437. /**
  46438. * Gets or sets user defined metadata
  46439. */
  46440. metadata: any;
  46441. /**
  46442. * For internal use only. Please do not use.
  46443. */
  46444. reservedDataStore: any;
  46445. /**
  46446. * Gets the name of the plugin used to load this scene (null by default)
  46447. */
  46448. loadingPluginName: string;
  46449. /**
  46450. * Use this array to add regular expressions used to disable offline support for specific urls
  46451. */
  46452. disableOfflineSupportExceptionRules: RegExp[];
  46453. /**
  46454. * An event triggered when the scene is disposed.
  46455. */
  46456. onDisposeObservable: Observable<Scene>;
  46457. private _onDisposeObserver;
  46458. /** Sets a function to be executed when this scene is disposed. */
  46459. set onDispose(callback: () => void);
  46460. /**
  46461. * An event triggered before rendering the scene (right after animations and physics)
  46462. */
  46463. onBeforeRenderObservable: Observable<Scene>;
  46464. private _onBeforeRenderObserver;
  46465. /** Sets a function to be executed before rendering this scene */
  46466. set beforeRender(callback: Nullable<() => void>);
  46467. /**
  46468. * An event triggered after rendering the scene
  46469. */
  46470. onAfterRenderObservable: Observable<Scene>;
  46471. /**
  46472. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  46473. */
  46474. onAfterRenderCameraObservable: Observable<Camera>;
  46475. private _onAfterRenderObserver;
  46476. /** Sets a function to be executed after rendering this scene */
  46477. set afterRender(callback: Nullable<() => void>);
  46478. /**
  46479. * An event triggered before animating the scene
  46480. */
  46481. onBeforeAnimationsObservable: Observable<Scene>;
  46482. /**
  46483. * An event triggered after animations processing
  46484. */
  46485. onAfterAnimationsObservable: Observable<Scene>;
  46486. /**
  46487. * An event triggered before draw calls are ready to be sent
  46488. */
  46489. onBeforeDrawPhaseObservable: Observable<Scene>;
  46490. /**
  46491. * An event triggered after draw calls have been sent
  46492. */
  46493. onAfterDrawPhaseObservable: Observable<Scene>;
  46494. /**
  46495. * An event triggered when the scene is ready
  46496. */
  46497. onReadyObservable: Observable<Scene>;
  46498. /**
  46499. * An event triggered before rendering a camera
  46500. */
  46501. onBeforeCameraRenderObservable: Observable<Camera>;
  46502. private _onBeforeCameraRenderObserver;
  46503. /** Sets a function to be executed before rendering a camera*/
  46504. set beforeCameraRender(callback: () => void);
  46505. /**
  46506. * An event triggered after rendering a camera
  46507. */
  46508. onAfterCameraRenderObservable: Observable<Camera>;
  46509. private _onAfterCameraRenderObserver;
  46510. /** Sets a function to be executed after rendering a camera*/
  46511. set afterCameraRender(callback: () => void);
  46512. /**
  46513. * An event triggered when active meshes evaluation is about to start
  46514. */
  46515. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  46516. /**
  46517. * An event triggered when active meshes evaluation is done
  46518. */
  46519. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  46520. /**
  46521. * An event triggered when particles rendering is about to start
  46522. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46523. */
  46524. onBeforeParticlesRenderingObservable: Observable<Scene>;
  46525. /**
  46526. * An event triggered when particles rendering is done
  46527. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  46528. */
  46529. onAfterParticlesRenderingObservable: Observable<Scene>;
  46530. /**
  46531. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  46532. */
  46533. onDataLoadedObservable: Observable<Scene>;
  46534. /**
  46535. * An event triggered when a camera is created
  46536. */
  46537. onNewCameraAddedObservable: Observable<Camera>;
  46538. /**
  46539. * An event triggered when a camera is removed
  46540. */
  46541. onCameraRemovedObservable: Observable<Camera>;
  46542. /**
  46543. * An event triggered when a light is created
  46544. */
  46545. onNewLightAddedObservable: Observable<Light>;
  46546. /**
  46547. * An event triggered when a light is removed
  46548. */
  46549. onLightRemovedObservable: Observable<Light>;
  46550. /**
  46551. * An event triggered when a geometry is created
  46552. */
  46553. onNewGeometryAddedObservable: Observable<Geometry>;
  46554. /**
  46555. * An event triggered when a geometry is removed
  46556. */
  46557. onGeometryRemovedObservable: Observable<Geometry>;
  46558. /**
  46559. * An event triggered when a transform node is created
  46560. */
  46561. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  46562. /**
  46563. * An event triggered when a transform node is removed
  46564. */
  46565. onTransformNodeRemovedObservable: Observable<TransformNode>;
  46566. /**
  46567. * An event triggered when a mesh is created
  46568. */
  46569. onNewMeshAddedObservable: Observable<AbstractMesh>;
  46570. /**
  46571. * An event triggered when a mesh is removed
  46572. */
  46573. onMeshRemovedObservable: Observable<AbstractMesh>;
  46574. /**
  46575. * An event triggered when a skeleton is created
  46576. */
  46577. onNewSkeletonAddedObservable: Observable<Skeleton>;
  46578. /**
  46579. * An event triggered when a skeleton is removed
  46580. */
  46581. onSkeletonRemovedObservable: Observable<Skeleton>;
  46582. /**
  46583. * An event triggered when a material is created
  46584. */
  46585. onNewMaterialAddedObservable: Observable<Material>;
  46586. /**
  46587. * An event triggered when a multi material is created
  46588. */
  46589. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  46590. /**
  46591. * An event triggered when a material is removed
  46592. */
  46593. onMaterialRemovedObservable: Observable<Material>;
  46594. /**
  46595. * An event triggered when a multi material is removed
  46596. */
  46597. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  46598. /**
  46599. * An event triggered when a texture is created
  46600. */
  46601. onNewTextureAddedObservable: Observable<BaseTexture>;
  46602. /**
  46603. * An event triggered when a texture is removed
  46604. */
  46605. onTextureRemovedObservable: Observable<BaseTexture>;
  46606. /**
  46607. * An event triggered when render targets are about to be rendered
  46608. * Can happen multiple times per frame.
  46609. */
  46610. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46611. /**
  46612. * An event triggered when render targets were rendered.
  46613. * Can happen multiple times per frame.
  46614. */
  46615. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46616. /**
  46617. * An event triggered before calculating deterministic simulation step
  46618. */
  46619. onBeforeStepObservable: Observable<Scene>;
  46620. /**
  46621. * An event triggered after calculating deterministic simulation step
  46622. */
  46623. onAfterStepObservable: Observable<Scene>;
  46624. /**
  46625. * An event triggered when the activeCamera property is updated
  46626. */
  46627. onActiveCameraChanged: Observable<Scene>;
  46628. /**
  46629. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46630. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46631. * 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)
  46632. */
  46633. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46634. /**
  46635. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46636. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46637. * 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)
  46638. */
  46639. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46640. /**
  46641. * This Observable will when a mesh has been imported into the scene.
  46642. */
  46643. onMeshImportedObservable: Observable<AbstractMesh>;
  46644. /**
  46645. * This Observable will when an animation file has been imported into the scene.
  46646. */
  46647. onAnimationFileImportedObservable: Observable<Scene>;
  46648. /**
  46649. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46650. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46651. */
  46652. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46653. /** @hidden */
  46654. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46655. /**
  46656. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46657. */
  46658. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46659. /**
  46660. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46661. */
  46662. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46663. /**
  46664. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46665. */
  46666. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46667. /** Callback called when a pointer move is detected */
  46668. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46669. /** Callback called when a pointer down is detected */
  46670. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46671. /** Callback called when a pointer up is detected */
  46672. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46673. /** Callback called when a pointer pick is detected */
  46674. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46675. /**
  46676. * 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).
  46677. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46678. */
  46679. onPrePointerObservable: Observable<PointerInfoPre>;
  46680. /**
  46681. * Observable event triggered each time an input event is received from the rendering canvas
  46682. */
  46683. onPointerObservable: Observable<PointerInfo>;
  46684. /**
  46685. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46686. */
  46687. get unTranslatedPointer(): Vector2;
  46688. /**
  46689. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46690. */
  46691. static get DragMovementThreshold(): number;
  46692. static set DragMovementThreshold(value: number);
  46693. /**
  46694. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46695. */
  46696. static get LongPressDelay(): number;
  46697. static set LongPressDelay(value: number);
  46698. /**
  46699. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46700. */
  46701. static get DoubleClickDelay(): number;
  46702. static set DoubleClickDelay(value: number);
  46703. /** If you need to check double click without raising a single click at first click, enable this flag */
  46704. static get ExclusiveDoubleClickMode(): boolean;
  46705. static set ExclusiveDoubleClickMode(value: boolean);
  46706. /** @hidden */
  46707. _mirroredCameraPosition: Nullable<Vector3>;
  46708. /**
  46709. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46710. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46711. */
  46712. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46713. /**
  46714. * Observable event triggered each time an keyboard event is received from the hosting window
  46715. */
  46716. onKeyboardObservable: Observable<KeyboardInfo>;
  46717. private _useRightHandedSystem;
  46718. /**
  46719. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46720. */
  46721. set useRightHandedSystem(value: boolean);
  46722. get useRightHandedSystem(): boolean;
  46723. private _timeAccumulator;
  46724. private _currentStepId;
  46725. private _currentInternalStep;
  46726. /**
  46727. * Sets the step Id used by deterministic lock step
  46728. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46729. * @param newStepId defines the step Id
  46730. */
  46731. setStepId(newStepId: number): void;
  46732. /**
  46733. * Gets the step Id used by deterministic lock step
  46734. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46735. * @returns the step Id
  46736. */
  46737. getStepId(): number;
  46738. /**
  46739. * Gets the internal step used by deterministic lock step
  46740. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46741. * @returns the internal step
  46742. */
  46743. getInternalStep(): number;
  46744. private _fogEnabled;
  46745. /**
  46746. * Gets or sets a boolean indicating if fog is enabled on this scene
  46747. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46748. * (Default is true)
  46749. */
  46750. set fogEnabled(value: boolean);
  46751. get fogEnabled(): boolean;
  46752. private _fogMode;
  46753. /**
  46754. * Gets or sets the fog mode to use
  46755. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46756. * | mode | value |
  46757. * | --- | --- |
  46758. * | FOGMODE_NONE | 0 |
  46759. * | FOGMODE_EXP | 1 |
  46760. * | FOGMODE_EXP2 | 2 |
  46761. * | FOGMODE_LINEAR | 3 |
  46762. */
  46763. set fogMode(value: number);
  46764. get fogMode(): number;
  46765. /**
  46766. * Gets or sets the fog color to use
  46767. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46768. * (Default is Color3(0.2, 0.2, 0.3))
  46769. */
  46770. fogColor: Color3;
  46771. /**
  46772. * Gets or sets the fog density to use
  46773. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46774. * (Default is 0.1)
  46775. */
  46776. fogDensity: number;
  46777. /**
  46778. * Gets or sets the fog start distance to use
  46779. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46780. * (Default is 0)
  46781. */
  46782. fogStart: number;
  46783. /**
  46784. * Gets or sets the fog end distance to use
  46785. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46786. * (Default is 1000)
  46787. */
  46788. fogEnd: number;
  46789. /**
  46790. * Flag indicating that the frame buffer binding is handled by another component
  46791. */
  46792. get prePass(): boolean;
  46793. private _shadowsEnabled;
  46794. /**
  46795. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46796. */
  46797. set shadowsEnabled(value: boolean);
  46798. get shadowsEnabled(): boolean;
  46799. private _lightsEnabled;
  46800. /**
  46801. * Gets or sets a boolean indicating if lights are enabled on this scene
  46802. */
  46803. set lightsEnabled(value: boolean);
  46804. get lightsEnabled(): boolean;
  46805. /** All of the active cameras added to this scene. */
  46806. activeCameras: Nullable<Camera[]>;
  46807. /** @hidden */
  46808. _activeCamera: Nullable<Camera>;
  46809. /** Gets or sets the current active camera */
  46810. get activeCamera(): Nullable<Camera>;
  46811. set activeCamera(value: Nullable<Camera>);
  46812. private _defaultMaterial;
  46813. /** The default material used on meshes when no material is affected */
  46814. get defaultMaterial(): Material;
  46815. /** The default material used on meshes when no material is affected */
  46816. set defaultMaterial(value: Material);
  46817. private _texturesEnabled;
  46818. /**
  46819. * Gets or sets a boolean indicating if textures are enabled on this scene
  46820. */
  46821. set texturesEnabled(value: boolean);
  46822. get texturesEnabled(): boolean;
  46823. /**
  46824. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46825. */
  46826. physicsEnabled: boolean;
  46827. /**
  46828. * Gets or sets a boolean indicating if particles are enabled on this scene
  46829. */
  46830. particlesEnabled: boolean;
  46831. /**
  46832. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46833. */
  46834. spritesEnabled: boolean;
  46835. private _skeletonsEnabled;
  46836. /**
  46837. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46838. */
  46839. set skeletonsEnabled(value: boolean);
  46840. get skeletonsEnabled(): boolean;
  46841. /**
  46842. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46843. */
  46844. lensFlaresEnabled: boolean;
  46845. /**
  46846. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46847. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46848. */
  46849. collisionsEnabled: boolean;
  46850. private _collisionCoordinator;
  46851. /** @hidden */
  46852. get collisionCoordinator(): ICollisionCoordinator;
  46853. /**
  46854. * Defines the gravity applied to this scene (used only for collisions)
  46855. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46856. */
  46857. gravity: Vector3;
  46858. /**
  46859. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46860. */
  46861. postProcessesEnabled: boolean;
  46862. /**
  46863. * Gets the current postprocess manager
  46864. */
  46865. postProcessManager: PostProcessManager;
  46866. /**
  46867. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46868. */
  46869. renderTargetsEnabled: boolean;
  46870. /**
  46871. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46872. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46873. */
  46874. dumpNextRenderTargets: boolean;
  46875. /**
  46876. * The list of user defined render targets added to the scene
  46877. */
  46878. customRenderTargets: RenderTargetTexture[];
  46879. /**
  46880. * Defines if texture loading must be delayed
  46881. * If true, textures will only be loaded when they need to be rendered
  46882. */
  46883. useDelayedTextureLoading: boolean;
  46884. /**
  46885. * Gets the list of meshes imported to the scene through SceneLoader
  46886. */
  46887. importedMeshesFiles: String[];
  46888. /**
  46889. * Gets or sets a boolean indicating if probes are enabled on this scene
  46890. */
  46891. probesEnabled: boolean;
  46892. /**
  46893. * Gets or sets the current offline provider to use to store scene data
  46894. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46895. */
  46896. offlineProvider: IOfflineProvider;
  46897. /**
  46898. * Gets or sets the action manager associated with the scene
  46899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46900. */
  46901. actionManager: AbstractActionManager;
  46902. private _meshesForIntersections;
  46903. /**
  46904. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46905. */
  46906. proceduralTexturesEnabled: boolean;
  46907. private _engine;
  46908. private _totalVertices;
  46909. /** @hidden */
  46910. _activeIndices: PerfCounter;
  46911. /** @hidden */
  46912. _activeParticles: PerfCounter;
  46913. /** @hidden */
  46914. _activeBones: PerfCounter;
  46915. private _animationRatio;
  46916. /** @hidden */
  46917. _animationTimeLast: number;
  46918. /** @hidden */
  46919. _animationTime: number;
  46920. /**
  46921. * Gets or sets a general scale for animation speed
  46922. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46923. */
  46924. animationTimeScale: number;
  46925. /** @hidden */
  46926. _cachedMaterial: Nullable<Material>;
  46927. /** @hidden */
  46928. _cachedEffect: Nullable<Effect>;
  46929. /** @hidden */
  46930. _cachedVisibility: Nullable<number>;
  46931. private _renderId;
  46932. private _frameId;
  46933. private _executeWhenReadyTimeoutId;
  46934. private _intermediateRendering;
  46935. private _viewUpdateFlag;
  46936. private _projectionUpdateFlag;
  46937. /** @hidden */
  46938. _toBeDisposed: Nullable<IDisposable>[];
  46939. private _activeRequests;
  46940. /** @hidden */
  46941. _pendingData: any[];
  46942. private _isDisposed;
  46943. /**
  46944. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46945. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46946. */
  46947. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46948. private _activeMeshes;
  46949. private _processedMaterials;
  46950. private _renderTargets;
  46951. /** @hidden */
  46952. _activeParticleSystems: SmartArray<IParticleSystem>;
  46953. private _activeSkeletons;
  46954. private _softwareSkinnedMeshes;
  46955. private _renderingManager;
  46956. /** @hidden */
  46957. _activeAnimatables: Animatable[];
  46958. private _transformMatrix;
  46959. private _sceneUbo;
  46960. /** @hidden */
  46961. _viewMatrix: Matrix;
  46962. /** @hidden */
  46963. _projectionMatrix: Matrix;
  46964. /** @hidden */
  46965. _forcedViewPosition: Nullable<Vector3>;
  46966. /** @hidden */
  46967. _frustumPlanes: Plane[];
  46968. /**
  46969. * Gets the list of frustum planes (built from the active camera)
  46970. */
  46971. get frustumPlanes(): Plane[];
  46972. /**
  46973. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46974. * This is useful if there are more lights that the maximum simulteanous authorized
  46975. */
  46976. requireLightSorting: boolean;
  46977. /** @hidden */
  46978. readonly useMaterialMeshMap: boolean;
  46979. /** @hidden */
  46980. readonly useClonedMeshMap: boolean;
  46981. private _externalData;
  46982. private _uid;
  46983. /**
  46984. * @hidden
  46985. * Backing store of defined scene components.
  46986. */
  46987. _components: ISceneComponent[];
  46988. /**
  46989. * @hidden
  46990. * Backing store of defined scene components.
  46991. */
  46992. _serializableComponents: ISceneSerializableComponent[];
  46993. /**
  46994. * List of components to register on the next registration step.
  46995. */
  46996. private _transientComponents;
  46997. /**
  46998. * Registers the transient components if needed.
  46999. */
  47000. private _registerTransientComponents;
  47001. /**
  47002. * @hidden
  47003. * Add a component to the scene.
  47004. * Note that the ccomponent could be registered on th next frame if this is called after
  47005. * the register component stage.
  47006. * @param component Defines the component to add to the scene
  47007. */
  47008. _addComponent(component: ISceneComponent): void;
  47009. /**
  47010. * @hidden
  47011. * Gets a component from the scene.
  47012. * @param name defines the name of the component to retrieve
  47013. * @returns the component or null if not present
  47014. */
  47015. _getComponent(name: string): Nullable<ISceneComponent>;
  47016. /**
  47017. * @hidden
  47018. * Defines the actions happening before camera updates.
  47019. */
  47020. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  47021. /**
  47022. * @hidden
  47023. * Defines the actions happening before clear the canvas.
  47024. */
  47025. _beforeClearStage: Stage<SimpleStageAction>;
  47026. /**
  47027. * @hidden
  47028. * Defines the actions happening before clear the canvas.
  47029. */
  47030. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  47031. /**
  47032. * @hidden
  47033. * Defines the actions when collecting render targets for the frame.
  47034. */
  47035. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47036. /**
  47037. * @hidden
  47038. * Defines the actions happening for one camera in the frame.
  47039. */
  47040. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  47041. /**
  47042. * @hidden
  47043. * Defines the actions happening during the per mesh ready checks.
  47044. */
  47045. _isReadyForMeshStage: Stage<MeshStageAction>;
  47046. /**
  47047. * @hidden
  47048. * Defines the actions happening before evaluate active mesh checks.
  47049. */
  47050. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  47051. /**
  47052. * @hidden
  47053. * Defines the actions happening during the evaluate sub mesh checks.
  47054. */
  47055. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  47056. /**
  47057. * @hidden
  47058. * Defines the actions happening during the active mesh stage.
  47059. */
  47060. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  47061. /**
  47062. * @hidden
  47063. * Defines the actions happening during the per camera render target step.
  47064. */
  47065. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  47066. /**
  47067. * @hidden
  47068. * Defines the actions happening just before the active camera is drawing.
  47069. */
  47070. _beforeCameraDrawStage: Stage<CameraStageAction>;
  47071. /**
  47072. * @hidden
  47073. * Defines the actions happening just before a render target is drawing.
  47074. */
  47075. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47076. /**
  47077. * @hidden
  47078. * Defines the actions happening just before a rendering group is drawing.
  47079. */
  47080. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47081. /**
  47082. * @hidden
  47083. * Defines the actions happening just before a mesh is drawing.
  47084. */
  47085. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47086. /**
  47087. * @hidden
  47088. * Defines the actions happening just after a mesh has been drawn.
  47089. */
  47090. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  47091. /**
  47092. * @hidden
  47093. * Defines the actions happening just after a rendering group has been drawn.
  47094. */
  47095. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  47096. /**
  47097. * @hidden
  47098. * Defines the actions happening just after the active camera has been drawn.
  47099. */
  47100. _afterCameraDrawStage: Stage<CameraStageAction>;
  47101. /**
  47102. * @hidden
  47103. * Defines the actions happening just after a render target has been drawn.
  47104. */
  47105. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  47106. /**
  47107. * @hidden
  47108. * Defines the actions happening just after rendering all cameras and computing intersections.
  47109. */
  47110. _afterRenderStage: Stage<SimpleStageAction>;
  47111. /**
  47112. * @hidden
  47113. * Defines the actions happening when a pointer move event happens.
  47114. */
  47115. _pointerMoveStage: Stage<PointerMoveStageAction>;
  47116. /**
  47117. * @hidden
  47118. * Defines the actions happening when a pointer down event happens.
  47119. */
  47120. _pointerDownStage: Stage<PointerUpDownStageAction>;
  47121. /**
  47122. * @hidden
  47123. * Defines the actions happening when a pointer up event happens.
  47124. */
  47125. _pointerUpStage: Stage<PointerUpDownStageAction>;
  47126. /**
  47127. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  47128. */
  47129. private geometriesByUniqueId;
  47130. private _renderBundles;
  47131. /**
  47132. * Creates a new Scene
  47133. * @param engine defines the engine to use to render this scene
  47134. * @param options defines the scene options
  47135. */
  47136. constructor(engine: Engine, options?: SceneOptions);
  47137. /**
  47138. * Gets a string identifying the name of the class
  47139. * @returns "Scene" string
  47140. */
  47141. getClassName(): string;
  47142. private _defaultMeshCandidates;
  47143. /**
  47144. * @hidden
  47145. */
  47146. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47147. private _defaultSubMeshCandidates;
  47148. /**
  47149. * @hidden
  47150. */
  47151. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47152. /**
  47153. * Sets the default candidate providers for the scene.
  47154. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  47155. * and getCollidingSubMeshCandidates to their default function
  47156. */
  47157. setDefaultCandidateProviders(): void;
  47158. /**
  47159. * Gets the mesh that is currently under the pointer
  47160. */
  47161. get meshUnderPointer(): Nullable<AbstractMesh>;
  47162. /**
  47163. * Gets or sets the current on-screen X position of the pointer
  47164. */
  47165. get pointerX(): number;
  47166. set pointerX(value: number);
  47167. /**
  47168. * Gets or sets the current on-screen Y position of the pointer
  47169. */
  47170. get pointerY(): number;
  47171. set pointerY(value: number);
  47172. /**
  47173. * Gets the cached material (ie. the latest rendered one)
  47174. * @returns the cached material
  47175. */
  47176. getCachedMaterial(): Nullable<Material>;
  47177. /**
  47178. * Gets the cached effect (ie. the latest rendered one)
  47179. * @returns the cached effect
  47180. */
  47181. getCachedEffect(): Nullable<Effect>;
  47182. /**
  47183. * Gets the cached visibility state (ie. the latest rendered one)
  47184. * @returns the cached visibility state
  47185. */
  47186. getCachedVisibility(): Nullable<number>;
  47187. /**
  47188. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  47189. * @param material defines the current material
  47190. * @param effect defines the current effect
  47191. * @param visibility defines the current visibility state
  47192. * @returns true if one parameter is not cached
  47193. */
  47194. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  47195. /**
  47196. * Gets the engine associated with the scene
  47197. * @returns an Engine
  47198. */
  47199. getEngine(): Engine;
  47200. /**
  47201. * Gets the total number of vertices rendered per frame
  47202. * @returns the total number of vertices rendered per frame
  47203. */
  47204. getTotalVertices(): number;
  47205. /**
  47206. * Gets the performance counter for total vertices
  47207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47208. */
  47209. get totalVerticesPerfCounter(): PerfCounter;
  47210. /**
  47211. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  47212. * @returns the total number of active indices rendered per frame
  47213. */
  47214. getActiveIndices(): number;
  47215. /**
  47216. * Gets the performance counter for active indices
  47217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47218. */
  47219. get totalActiveIndicesPerfCounter(): PerfCounter;
  47220. /**
  47221. * Gets the total number of active particles rendered per frame
  47222. * @returns the total number of active particles rendered per frame
  47223. */
  47224. getActiveParticles(): number;
  47225. /**
  47226. * Gets the performance counter for active particles
  47227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47228. */
  47229. get activeParticlesPerfCounter(): PerfCounter;
  47230. /**
  47231. * Gets the total number of active bones rendered per frame
  47232. * @returns the total number of active bones rendered per frame
  47233. */
  47234. getActiveBones(): number;
  47235. /**
  47236. * Gets the performance counter for active bones
  47237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  47238. */
  47239. get activeBonesPerfCounter(): PerfCounter;
  47240. /**
  47241. * Gets the array of active meshes
  47242. * @returns an array of AbstractMesh
  47243. */
  47244. getActiveMeshes(): SmartArray<AbstractMesh>;
  47245. /**
  47246. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  47247. * @returns a number
  47248. */
  47249. getAnimationRatio(): number;
  47250. /**
  47251. * Gets an unique Id for the current render phase
  47252. * @returns a number
  47253. */
  47254. getRenderId(): number;
  47255. /**
  47256. * Gets an unique Id for the current frame
  47257. * @returns a number
  47258. */
  47259. getFrameId(): number;
  47260. /** Call this function if you want to manually increment the render Id*/
  47261. incrementRenderId(): void;
  47262. private _createUbo;
  47263. /**
  47264. * Use this method to simulate a pointer move on a mesh
  47265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47268. * @returns the current scene
  47269. */
  47270. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47271. /**
  47272. * Use this method to simulate a pointer down on a mesh
  47273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47276. * @returns the current scene
  47277. */
  47278. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  47279. /**
  47280. * Use this method to simulate a pointer up on a mesh
  47281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  47282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  47283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  47284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  47285. * @returns the current scene
  47286. */
  47287. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  47288. /**
  47289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  47290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  47291. * @returns true if the pointer was captured
  47292. */
  47293. isPointerCaptured(pointerId?: number): boolean;
  47294. /**
  47295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  47296. * @param attachUp defines if you want to attach events to pointerup
  47297. * @param attachDown defines if you want to attach events to pointerdown
  47298. * @param attachMove defines if you want to attach events to pointermove
  47299. */
  47300. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  47301. /** Detaches all event handlers*/
  47302. detachControl(): void;
  47303. /**
  47304. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  47305. * Delay loaded resources are not taking in account
  47306. * @return true if all required resources are ready
  47307. */
  47308. isReady(): boolean;
  47309. /** Resets all cached information relative to material (including effect and visibility) */
  47310. resetCachedMaterial(): void;
  47311. /**
  47312. * Registers a function to be called before every frame render
  47313. * @param func defines the function to register
  47314. */
  47315. registerBeforeRender(func: () => void): void;
  47316. /**
  47317. * Unregisters a function called before every frame render
  47318. * @param func defines the function to unregister
  47319. */
  47320. unregisterBeforeRender(func: () => void): void;
  47321. /**
  47322. * Registers a function to be called after every frame render
  47323. * @param func defines the function to register
  47324. */
  47325. registerAfterRender(func: () => void): void;
  47326. /**
  47327. * Unregisters a function called after every frame render
  47328. * @param func defines the function to unregister
  47329. */
  47330. unregisterAfterRender(func: () => void): void;
  47331. private _executeOnceBeforeRender;
  47332. /**
  47333. * The provided function will run before render once and will be disposed afterwards.
  47334. * A timeout delay can be provided so that the function will be executed in N ms.
  47335. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  47336. * @param func The function to be executed.
  47337. * @param timeout optional delay in ms
  47338. */
  47339. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  47340. /** @hidden */
  47341. _addPendingData(data: any): void;
  47342. /** @hidden */
  47343. _removePendingData(data: any): void;
  47344. /**
  47345. * Returns the number of items waiting to be loaded
  47346. * @returns the number of items waiting to be loaded
  47347. */
  47348. getWaitingItemsCount(): number;
  47349. /**
  47350. * Returns a boolean indicating if the scene is still loading data
  47351. */
  47352. get isLoading(): boolean;
  47353. /**
  47354. * Registers a function to be executed when the scene is ready
  47355. * @param {Function} func - the function to be executed
  47356. */
  47357. executeWhenReady(func: () => void): void;
  47358. /**
  47359. * Returns a promise that resolves when the scene is ready
  47360. * @returns A promise that resolves when the scene is ready
  47361. */
  47362. whenReadyAsync(): Promise<void>;
  47363. /** @hidden */
  47364. _checkIsReady(): void;
  47365. /**
  47366. * Gets all animatable attached to the scene
  47367. */
  47368. get animatables(): Animatable[];
  47369. /**
  47370. * Resets the last animation time frame.
  47371. * Useful to override when animations start running when loading a scene for the first time.
  47372. */
  47373. resetLastAnimationTimeFrame(): void;
  47374. /**
  47375. * Gets the current view matrix
  47376. * @returns a Matrix
  47377. */
  47378. getViewMatrix(): Matrix;
  47379. /**
  47380. * Gets the current projection matrix
  47381. * @returns a Matrix
  47382. */
  47383. getProjectionMatrix(): Matrix;
  47384. /**
  47385. * Gets the current transform matrix
  47386. * @returns a Matrix made of View * Projection
  47387. */
  47388. getTransformMatrix(): Matrix;
  47389. /**
  47390. * Sets the current transform matrix
  47391. * @param viewL defines the View matrix to use
  47392. * @param projectionL defines the Projection matrix to use
  47393. * @param viewR defines the right View matrix to use (if provided)
  47394. * @param projectionR defines the right Projection matrix to use (if provided)
  47395. */
  47396. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  47397. /**
  47398. * Gets the uniform buffer used to store scene data
  47399. * @returns a UniformBuffer
  47400. */
  47401. getSceneUniformBuffer(): UniformBuffer;
  47402. /**
  47403. * Gets an unique (relatively to the current scene) Id
  47404. * @returns an unique number for the scene
  47405. */
  47406. getUniqueId(): number;
  47407. /**
  47408. * Add a mesh to the list of scene's meshes
  47409. * @param newMesh defines the mesh to add
  47410. * @param recursive if all child meshes should also be added to the scene
  47411. */
  47412. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  47413. /**
  47414. * Remove a mesh for the list of scene's meshes
  47415. * @param toRemove defines the mesh to remove
  47416. * @param recursive if all child meshes should also be removed from the scene
  47417. * @returns the index where the mesh was in the mesh list
  47418. */
  47419. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  47420. /**
  47421. * Add a transform node to the list of scene's transform nodes
  47422. * @param newTransformNode defines the transform node to add
  47423. */
  47424. addTransformNode(newTransformNode: TransformNode): void;
  47425. /**
  47426. * Remove a transform node for the list of scene's transform nodes
  47427. * @param toRemove defines the transform node to remove
  47428. * @returns the index where the transform node was in the transform node list
  47429. */
  47430. removeTransformNode(toRemove: TransformNode): number;
  47431. /**
  47432. * Remove a skeleton for the list of scene's skeletons
  47433. * @param toRemove defines the skeleton to remove
  47434. * @returns the index where the skeleton was in the skeleton list
  47435. */
  47436. removeSkeleton(toRemove: Skeleton): number;
  47437. /**
  47438. * Remove a morph target for the list of scene's morph targets
  47439. * @param toRemove defines the morph target to remove
  47440. * @returns the index where the morph target was in the morph target list
  47441. */
  47442. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  47443. /**
  47444. * Remove a light for the list of scene's lights
  47445. * @param toRemove defines the light to remove
  47446. * @returns the index where the light was in the light list
  47447. */
  47448. removeLight(toRemove: Light): number;
  47449. /**
  47450. * Remove a camera for the list of scene's cameras
  47451. * @param toRemove defines the camera to remove
  47452. * @returns the index where the camera was in the camera list
  47453. */
  47454. removeCamera(toRemove: Camera): number;
  47455. /**
  47456. * Remove a particle system for the list of scene's particle systems
  47457. * @param toRemove defines the particle system to remove
  47458. * @returns the index where the particle system was in the particle system list
  47459. */
  47460. removeParticleSystem(toRemove: IParticleSystem): number;
  47461. /**
  47462. * Remove a animation for the list of scene's animations
  47463. * @param toRemove defines the animation to remove
  47464. * @returns the index where the animation was in the animation list
  47465. */
  47466. removeAnimation(toRemove: Animation): number;
  47467. /**
  47468. * Will stop the animation of the given target
  47469. * @param target - the target
  47470. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  47471. * @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)
  47472. */
  47473. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  47474. /**
  47475. * Removes the given animation group from this scene.
  47476. * @param toRemove The animation group to remove
  47477. * @returns The index of the removed animation group
  47478. */
  47479. removeAnimationGroup(toRemove: AnimationGroup): number;
  47480. /**
  47481. * Removes the given multi-material from this scene.
  47482. * @param toRemove The multi-material to remove
  47483. * @returns The index of the removed multi-material
  47484. */
  47485. removeMultiMaterial(toRemove: MultiMaterial): number;
  47486. /**
  47487. * Removes the given material from this scene.
  47488. * @param toRemove The material to remove
  47489. * @returns The index of the removed material
  47490. */
  47491. removeMaterial(toRemove: Material): number;
  47492. /**
  47493. * Removes the given action manager from this scene.
  47494. * @param toRemove The action manager to remove
  47495. * @returns The index of the removed action manager
  47496. */
  47497. removeActionManager(toRemove: AbstractActionManager): number;
  47498. /**
  47499. * Removes the given texture from this scene.
  47500. * @param toRemove The texture to remove
  47501. * @returns The index of the removed texture
  47502. */
  47503. removeTexture(toRemove: BaseTexture): number;
  47504. /**
  47505. * Adds the given light to this scene
  47506. * @param newLight The light to add
  47507. */
  47508. addLight(newLight: Light): void;
  47509. /**
  47510. * Sorts the list list based on light priorities
  47511. */
  47512. sortLightsByPriority(): void;
  47513. /**
  47514. * Adds the given camera to this scene
  47515. * @param newCamera The camera to add
  47516. */
  47517. addCamera(newCamera: Camera): void;
  47518. /**
  47519. * Adds the given skeleton to this scene
  47520. * @param newSkeleton The skeleton to add
  47521. */
  47522. addSkeleton(newSkeleton: Skeleton): void;
  47523. /**
  47524. * Adds the given particle system to this scene
  47525. * @param newParticleSystem The particle system to add
  47526. */
  47527. addParticleSystem(newParticleSystem: IParticleSystem): void;
  47528. /**
  47529. * Adds the given animation to this scene
  47530. * @param newAnimation The animation to add
  47531. */
  47532. addAnimation(newAnimation: Animation): void;
  47533. /**
  47534. * Adds the given animation group to this scene.
  47535. * @param newAnimationGroup The animation group to add
  47536. */
  47537. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  47538. /**
  47539. * Adds the given multi-material to this scene
  47540. * @param newMultiMaterial The multi-material to add
  47541. */
  47542. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  47543. /**
  47544. * Adds the given material to this scene
  47545. * @param newMaterial The material to add
  47546. */
  47547. addMaterial(newMaterial: Material): void;
  47548. /**
  47549. * Adds the given morph target to this scene
  47550. * @param newMorphTargetManager The morph target to add
  47551. */
  47552. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  47553. /**
  47554. * Adds the given geometry to this scene
  47555. * @param newGeometry The geometry to add
  47556. */
  47557. addGeometry(newGeometry: Geometry): void;
  47558. /**
  47559. * Adds the given action manager to this scene
  47560. * @param newActionManager The action manager to add
  47561. */
  47562. addActionManager(newActionManager: AbstractActionManager): void;
  47563. /**
  47564. * Adds the given texture to this scene.
  47565. * @param newTexture The texture to add
  47566. */
  47567. addTexture(newTexture: BaseTexture): void;
  47568. /**
  47569. * Switch active camera
  47570. * @param newCamera defines the new active camera
  47571. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  47572. */
  47573. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  47574. /**
  47575. * sets the active camera of the scene using its ID
  47576. * @param id defines the camera's ID
  47577. * @return the new active camera or null if none found.
  47578. */
  47579. setActiveCameraByID(id: string): Nullable<Camera>;
  47580. /**
  47581. * sets the active camera of the scene using its name
  47582. * @param name defines the camera's name
  47583. * @returns the new active camera or null if none found.
  47584. */
  47585. setActiveCameraByName(name: string): Nullable<Camera>;
  47586. /**
  47587. * get an animation group using its name
  47588. * @param name defines the material's name
  47589. * @return the animation group or null if none found.
  47590. */
  47591. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  47592. /**
  47593. * Get a material using its unique id
  47594. * @param uniqueId defines the material's unique id
  47595. * @return the material or null if none found.
  47596. */
  47597. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  47598. /**
  47599. * get a material using its id
  47600. * @param id defines the material's ID
  47601. * @return the material or null if none found.
  47602. */
  47603. getMaterialByID(id: string): Nullable<Material>;
  47604. /**
  47605. * Gets a the last added material using a given id
  47606. * @param id defines the material's ID
  47607. * @return the last material with the given id or null if none found.
  47608. */
  47609. getLastMaterialByID(id: string): Nullable<Material>;
  47610. /**
  47611. * Gets a material using its name
  47612. * @param name defines the material's name
  47613. * @return the material or null if none found.
  47614. */
  47615. getMaterialByName(name: string): Nullable<Material>;
  47616. /**
  47617. * Get a texture using its unique id
  47618. * @param uniqueId defines the texture's unique id
  47619. * @return the texture or null if none found.
  47620. */
  47621. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47622. /**
  47623. * Gets a camera using its id
  47624. * @param id defines the id to look for
  47625. * @returns the camera or null if not found
  47626. */
  47627. getCameraByID(id: string): Nullable<Camera>;
  47628. /**
  47629. * Gets a camera using its unique id
  47630. * @param uniqueId defines the unique id to look for
  47631. * @returns the camera or null if not found
  47632. */
  47633. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47634. /**
  47635. * Gets a camera using its name
  47636. * @param name defines the camera's name
  47637. * @return the camera or null if none found.
  47638. */
  47639. getCameraByName(name: string): Nullable<Camera>;
  47640. /**
  47641. * Gets a bone using its id
  47642. * @param id defines the bone's id
  47643. * @return the bone or null if not found
  47644. */
  47645. getBoneByID(id: string): Nullable<Bone>;
  47646. /**
  47647. * Gets a bone using its id
  47648. * @param name defines the bone's name
  47649. * @return the bone or null if not found
  47650. */
  47651. getBoneByName(name: string): Nullable<Bone>;
  47652. /**
  47653. * Gets a light node using its name
  47654. * @param name defines the the light's name
  47655. * @return the light or null if none found.
  47656. */
  47657. getLightByName(name: string): Nullable<Light>;
  47658. /**
  47659. * Gets a light node using its id
  47660. * @param id defines the light's id
  47661. * @return the light or null if none found.
  47662. */
  47663. getLightByID(id: string): Nullable<Light>;
  47664. /**
  47665. * Gets a light node using its scene-generated unique ID
  47666. * @param uniqueId defines the light's unique id
  47667. * @return the light or null if none found.
  47668. */
  47669. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47670. /**
  47671. * Gets a particle system by id
  47672. * @param id defines the particle system id
  47673. * @return the corresponding system or null if none found
  47674. */
  47675. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47676. /**
  47677. * Gets a geometry using its ID
  47678. * @param id defines the geometry's id
  47679. * @return the geometry or null if none found.
  47680. */
  47681. getGeometryByID(id: string): Nullable<Geometry>;
  47682. private _getGeometryByUniqueID;
  47683. /**
  47684. * Add a new geometry to this scene
  47685. * @param geometry defines the geometry to be added to the scene.
  47686. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47687. * @return a boolean defining if the geometry was added or not
  47688. */
  47689. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47690. /**
  47691. * Removes an existing geometry
  47692. * @param geometry defines the geometry to be removed from the scene
  47693. * @return a boolean defining if the geometry was removed or not
  47694. */
  47695. removeGeometry(geometry: Geometry): boolean;
  47696. /**
  47697. * Gets the list of geometries attached to the scene
  47698. * @returns an array of Geometry
  47699. */
  47700. getGeometries(): Geometry[];
  47701. /**
  47702. * Gets the first added mesh found of a given ID
  47703. * @param id defines the id to search for
  47704. * @return the mesh found or null if not found at all
  47705. */
  47706. getMeshByID(id: string): Nullable<AbstractMesh>;
  47707. /**
  47708. * Gets a list of meshes using their id
  47709. * @param id defines the id to search for
  47710. * @returns a list of meshes
  47711. */
  47712. getMeshesByID(id: string): Array<AbstractMesh>;
  47713. /**
  47714. * Gets the first added transform node found of a given ID
  47715. * @param id defines the id to search for
  47716. * @return the found transform node or null if not found at all.
  47717. */
  47718. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47719. /**
  47720. * Gets a transform node with its auto-generated unique id
  47721. * @param uniqueId efines the unique id to search for
  47722. * @return the found transform node or null if not found at all.
  47723. */
  47724. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47725. /**
  47726. * Gets a list of transform nodes using their id
  47727. * @param id defines the id to search for
  47728. * @returns a list of transform nodes
  47729. */
  47730. getTransformNodesByID(id: string): Array<TransformNode>;
  47731. /**
  47732. * Gets a mesh with its auto-generated unique id
  47733. * @param uniqueId defines the unique id to search for
  47734. * @return the found mesh or null if not found at all.
  47735. */
  47736. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47737. /**
  47738. * Gets a the last added mesh using a given id
  47739. * @param id defines the id to search for
  47740. * @return the found mesh or null if not found at all.
  47741. */
  47742. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47743. /**
  47744. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47745. * @param id defines the id to search for
  47746. * @return the found node or null if not found at all
  47747. */
  47748. getLastEntryByID(id: string): Nullable<Node>;
  47749. /**
  47750. * Gets a node (Mesh, Camera, Light) using a given id
  47751. * @param id defines the id to search for
  47752. * @return the found node or null if not found at all
  47753. */
  47754. getNodeByID(id: string): Nullable<Node>;
  47755. /**
  47756. * Gets a node (Mesh, Camera, Light) using a given name
  47757. * @param name defines the name to search for
  47758. * @return the found node or null if not found at all.
  47759. */
  47760. getNodeByName(name: string): Nullable<Node>;
  47761. /**
  47762. * Gets a mesh using a given name
  47763. * @param name defines the name to search for
  47764. * @return the found mesh or null if not found at all.
  47765. */
  47766. getMeshByName(name: string): Nullable<AbstractMesh>;
  47767. /**
  47768. * Gets a transform node using a given name
  47769. * @param name defines the name to search for
  47770. * @return the found transform node or null if not found at all.
  47771. */
  47772. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47773. /**
  47774. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47775. * @param id defines the id to search for
  47776. * @return the found skeleton or null if not found at all.
  47777. */
  47778. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47779. /**
  47780. * Gets a skeleton using a given auto generated unique id
  47781. * @param uniqueId defines the unique id to search for
  47782. * @return the found skeleton or null if not found at all.
  47783. */
  47784. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47785. /**
  47786. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47787. * @param id defines the id to search for
  47788. * @return the found skeleton or null if not found at all.
  47789. */
  47790. getSkeletonById(id: string): Nullable<Skeleton>;
  47791. /**
  47792. * Gets a skeleton using a given name
  47793. * @param name defines the name to search for
  47794. * @return the found skeleton or null if not found at all.
  47795. */
  47796. getSkeletonByName(name: string): Nullable<Skeleton>;
  47797. /**
  47798. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47799. * @param id defines the id to search for
  47800. * @return the found morph target manager or null if not found at all.
  47801. */
  47802. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47803. /**
  47804. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47805. * @param id defines the id to search for
  47806. * @return the found morph target or null if not found at all.
  47807. */
  47808. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47809. /**
  47810. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47811. * @param name defines the name to search for
  47812. * @return the found morph target or null if not found at all.
  47813. */
  47814. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47815. /**
  47816. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47817. * @param name defines the name to search for
  47818. * @return the found post process or null if not found at all.
  47819. */
  47820. getPostProcessByName(name: string): Nullable<PostProcess>;
  47821. /**
  47822. * Gets a boolean indicating if the given mesh is active
  47823. * @param mesh defines the mesh to look for
  47824. * @returns true if the mesh is in the active list
  47825. */
  47826. isActiveMesh(mesh: AbstractMesh): boolean;
  47827. /**
  47828. * Return a unique id as a string which can serve as an identifier for the scene
  47829. */
  47830. get uid(): string;
  47831. /**
  47832. * Add an externaly attached data from its key.
  47833. * This method call will fail and return false, if such key already exists.
  47834. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47835. * @param key the unique key that identifies the data
  47836. * @param data the data object to associate to the key for this Engine instance
  47837. * @return true if no such key were already present and the data was added successfully, false otherwise
  47838. */
  47839. addExternalData<T>(key: string, data: T): boolean;
  47840. /**
  47841. * Get an externaly attached data from its key
  47842. * @param key the unique key that identifies the data
  47843. * @return the associated data, if present (can be null), or undefined if not present
  47844. */
  47845. getExternalData<T>(key: string): Nullable<T>;
  47846. /**
  47847. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47848. * @param key the unique key that identifies the data
  47849. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47850. * @return the associated data, can be null if the factory returned null.
  47851. */
  47852. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47853. /**
  47854. * Remove an externaly attached data from the Engine instance
  47855. * @param key the unique key that identifies the data
  47856. * @return true if the data was successfully removed, false if it doesn't exist
  47857. */
  47858. removeExternalData(key: string): boolean;
  47859. private _evaluateSubMesh;
  47860. /**
  47861. * Clear the processed materials smart array preventing retention point in material dispose.
  47862. */
  47863. freeProcessedMaterials(): void;
  47864. private _preventFreeActiveMeshesAndRenderingGroups;
  47865. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47866. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47867. * when disposing several meshes in a row or a hierarchy of meshes.
  47868. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47869. */
  47870. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47871. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47872. /**
  47873. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47874. */
  47875. freeActiveMeshes(): void;
  47876. /**
  47877. * Clear the info related to rendering groups preventing retention points during dispose.
  47878. */
  47879. freeRenderingGroups(): void;
  47880. /** @hidden */
  47881. _isInIntermediateRendering(): boolean;
  47882. /**
  47883. * Lambda returning the list of potentially active meshes.
  47884. */
  47885. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47886. /**
  47887. * Lambda returning the list of potentially active sub meshes.
  47888. */
  47889. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47890. /**
  47891. * Lambda returning the list of potentially intersecting sub meshes.
  47892. */
  47893. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47894. /**
  47895. * Lambda returning the list of potentially colliding sub meshes.
  47896. */
  47897. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47898. /** @hidden */
  47899. _activeMeshesFrozen: boolean;
  47900. private _skipEvaluateActiveMeshesCompletely;
  47901. /**
  47902. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47903. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47904. * @param onSuccess optional success callback
  47905. * @param onError optional error callback
  47906. * @returns the current scene
  47907. */
  47908. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47909. /**
  47910. * Use this function to restart evaluating active meshes on every frame
  47911. * @returns the current scene
  47912. */
  47913. unfreezeActiveMeshes(): Scene;
  47914. private _evaluateActiveMeshes;
  47915. private _activeMesh;
  47916. /**
  47917. * Update the transform matrix to update from the current active camera
  47918. * @param force defines a boolean used to force the update even if cache is up to date
  47919. */
  47920. updateTransformMatrix(force?: boolean): void;
  47921. private _bindFrameBuffer;
  47922. /** @hidden */
  47923. _allowPostProcessClearColor: boolean;
  47924. /** @hidden */
  47925. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47926. private _processSubCameras;
  47927. private _checkIntersections;
  47928. /** @hidden */
  47929. _advancePhysicsEngineStep(step: number): void;
  47930. /**
  47931. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47932. */
  47933. getDeterministicFrameTime: () => number;
  47934. /** @hidden */
  47935. _animate(): void;
  47936. /** Execute all animations (for a frame) */
  47937. animate(): void;
  47938. /**
  47939. * Render the scene
  47940. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47941. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47942. */
  47943. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47944. /**
  47945. * Freeze all materials
  47946. * A frozen material will not be updatable but should be faster to render
  47947. */
  47948. freezeMaterials(): void;
  47949. /**
  47950. * Unfreeze all materials
  47951. * A frozen material will not be updatable but should be faster to render
  47952. */
  47953. unfreezeMaterials(): void;
  47954. /**
  47955. * Releases all held ressources
  47956. */
  47957. dispose(): void;
  47958. /**
  47959. * Gets if the scene is already disposed
  47960. */
  47961. get isDisposed(): boolean;
  47962. /**
  47963. * Call this function to reduce memory footprint of the scene.
  47964. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47965. */
  47966. clearCachedVertexData(): void;
  47967. /**
  47968. * This function will remove the local cached buffer data from texture.
  47969. * It will save memory but will prevent the texture from being rebuilt
  47970. */
  47971. cleanCachedTextureBuffer(): void;
  47972. /**
  47973. * Get the world extend vectors with an optional filter
  47974. *
  47975. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47976. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47977. */
  47978. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47979. min: Vector3;
  47980. max: Vector3;
  47981. };
  47982. /**
  47983. * Creates a ray that can be used to pick in the scene
  47984. * @param x defines the x coordinate of the origin (on-screen)
  47985. * @param y defines the y coordinate of the origin (on-screen)
  47986. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47987. * @param camera defines the camera to use for the picking
  47988. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47989. * @returns a Ray
  47990. */
  47991. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47992. /**
  47993. * Creates a ray that can be used to pick in the scene
  47994. * @param x defines the x coordinate of the origin (on-screen)
  47995. * @param y defines the y coordinate of the origin (on-screen)
  47996. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47997. * @param result defines the ray where to store the picking ray
  47998. * @param camera defines the camera to use for the picking
  47999. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  48000. * @returns the current scene
  48001. */
  48002. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  48003. /**
  48004. * Creates a ray that can be used to pick in the scene
  48005. * @param x defines the x coordinate of the origin (on-screen)
  48006. * @param y defines the y coordinate of the origin (on-screen)
  48007. * @param camera defines the camera to use for the picking
  48008. * @returns a Ray
  48009. */
  48010. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  48011. /**
  48012. * Creates a ray that can be used to pick in the scene
  48013. * @param x defines the x coordinate of the origin (on-screen)
  48014. * @param y defines the y coordinate of the origin (on-screen)
  48015. * @param result defines the ray where to store the picking ray
  48016. * @param camera defines the camera to use for the picking
  48017. * @returns the current scene
  48018. */
  48019. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  48020. /** Launch a ray to try to pick a mesh in the scene
  48021. * @param x position on screen
  48022. * @param y position on screen
  48023. * @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
  48024. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48025. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48026. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48027. * @returns a PickingInfo
  48028. */
  48029. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48030. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  48031. * @param x position on screen
  48032. * @param y position on screen
  48033. * @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
  48034. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48035. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48036. * @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)
  48037. */
  48038. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  48039. /** Use the given ray to pick a mesh in the scene
  48040. * @param ray The ray to use to pick meshes
  48041. * @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
  48042. * @param fastCheck defines if the first intersection will be used (and not the closest)
  48043. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48044. * @returns a PickingInfo
  48045. */
  48046. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  48047. /**
  48048. * Launch a ray to try to pick a mesh in the scene
  48049. * @param x X position on screen
  48050. * @param y Y position on screen
  48051. * @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
  48052. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  48053. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48054. * @returns an array of PickingInfo
  48055. */
  48056. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48057. /**
  48058. * Launch a ray to try to pick a mesh in the scene
  48059. * @param ray Ray to use
  48060. * @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
  48061. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  48062. * @returns an array of PickingInfo
  48063. */
  48064. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  48065. /**
  48066. * Force the value of meshUnderPointer
  48067. * @param mesh defines the mesh to use
  48068. * @param pointerId optional pointer id when using more than one pointer
  48069. */
  48070. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  48071. /**
  48072. * Gets the mesh under the pointer
  48073. * @returns a Mesh or null if no mesh is under the pointer
  48074. */
  48075. getPointerOverMesh(): Nullable<AbstractMesh>;
  48076. /** @hidden */
  48077. _rebuildGeometries(): void;
  48078. /** @hidden */
  48079. _rebuildTextures(): void;
  48080. private _getByTags;
  48081. /**
  48082. * Get a list of meshes by tags
  48083. * @param tagsQuery defines the tags query to use
  48084. * @param forEach defines a predicate used to filter results
  48085. * @returns an array of Mesh
  48086. */
  48087. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  48088. /**
  48089. * Get a list of cameras by tags
  48090. * @param tagsQuery defines the tags query to use
  48091. * @param forEach defines a predicate used to filter results
  48092. * @returns an array of Camera
  48093. */
  48094. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  48095. /**
  48096. * Get a list of lights by tags
  48097. * @param tagsQuery defines the tags query to use
  48098. * @param forEach defines a predicate used to filter results
  48099. * @returns an array of Light
  48100. */
  48101. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  48102. /**
  48103. * Get a list of materials by tags
  48104. * @param tagsQuery defines the tags query to use
  48105. * @param forEach defines a predicate used to filter results
  48106. * @returns an array of Material
  48107. */
  48108. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  48109. /**
  48110. * Get a list of transform nodes by tags
  48111. * @param tagsQuery defines the tags query to use
  48112. * @param forEach defines a predicate used to filter results
  48113. * @returns an array of TransformNode
  48114. */
  48115. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  48116. /**
  48117. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48118. * This allowed control for front to back rendering or reversly depending of the special needs.
  48119. *
  48120. * @param renderingGroupId The rendering group id corresponding to its index
  48121. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48122. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48123. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48124. */
  48125. 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;
  48126. /**
  48127. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48128. *
  48129. * @param renderingGroupId The rendering group id corresponding to its index
  48130. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48131. * @param depth Automatically clears depth between groups if true and autoClear is true.
  48132. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  48133. */
  48134. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  48135. /**
  48136. * Gets the current auto clear configuration for one rendering group of the rendering
  48137. * manager.
  48138. * @param index the rendering group index to get the information for
  48139. * @returns The auto clear setup for the requested rendering group
  48140. */
  48141. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  48142. private _blockMaterialDirtyMechanism;
  48143. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  48144. get blockMaterialDirtyMechanism(): boolean;
  48145. set blockMaterialDirtyMechanism(value: boolean);
  48146. /**
  48147. * Will flag all materials as dirty to trigger new shader compilation
  48148. * @param flag defines the flag used to specify which material part must be marked as dirty
  48149. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  48150. */
  48151. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  48152. /** @hidden */
  48153. _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;
  48154. /** @hidden */
  48155. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48156. /** @hidden */
  48157. _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;
  48158. /** @hidden */
  48159. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  48160. /** @hidden */
  48161. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  48162. /** @hidden */
  48163. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  48164. }
  48165. }
  48166. declare module BABYLON {
  48167. /**
  48168. * Set of assets to keep when moving a scene into an asset container.
  48169. */
  48170. export class KeepAssets extends AbstractScene {
  48171. }
  48172. /**
  48173. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  48174. */
  48175. export class InstantiatedEntries {
  48176. /**
  48177. * List of new root nodes (eg. nodes with no parent)
  48178. */
  48179. rootNodes: TransformNode[];
  48180. /**
  48181. * List of new skeletons
  48182. */
  48183. skeletons: Skeleton[];
  48184. /**
  48185. * List of new animation groups
  48186. */
  48187. animationGroups: AnimationGroup[];
  48188. }
  48189. /**
  48190. * Container with a set of assets that can be added or removed from a scene.
  48191. */
  48192. export class AssetContainer extends AbstractScene {
  48193. private _wasAddedToScene;
  48194. /**
  48195. * The scene the AssetContainer belongs to.
  48196. */
  48197. scene: Scene;
  48198. /**
  48199. * Instantiates an AssetContainer.
  48200. * @param scene The scene the AssetContainer belongs to.
  48201. */
  48202. constructor(scene: Scene);
  48203. /**
  48204. * Instantiate or clone all meshes and add the new ones to the scene.
  48205. * Skeletons and animation groups will all be cloned
  48206. * @param nameFunction defines an optional function used to get new names for clones
  48207. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  48208. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  48209. */
  48210. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  48211. /**
  48212. * Adds all the assets from the container to the scene.
  48213. */
  48214. addAllToScene(): void;
  48215. /**
  48216. * Removes all the assets in the container from the scene
  48217. */
  48218. removeAllFromScene(): void;
  48219. /**
  48220. * Disposes all the assets in the container
  48221. */
  48222. dispose(): void;
  48223. private _moveAssets;
  48224. /**
  48225. * Removes all the assets contained in the scene and adds them to the container.
  48226. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  48227. */
  48228. moveAllFromScene(keepAssets?: KeepAssets): void;
  48229. /**
  48230. * 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.
  48231. * @returns the root mesh
  48232. */
  48233. createRootMesh(): Mesh;
  48234. /**
  48235. * Merge animations (direct and animation groups) from this asset container into a scene
  48236. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48237. * @param animatables set of animatables to retarget to a node from the scene
  48238. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  48239. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  48240. */
  48241. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  48242. }
  48243. }
  48244. declare module BABYLON {
  48245. /**
  48246. * Defines how the parser contract is defined.
  48247. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  48248. */
  48249. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  48250. /**
  48251. * Defines how the individual parser contract is defined.
  48252. * These parser can parse an individual asset
  48253. */
  48254. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  48255. /**
  48256. * Base class of the scene acting as a container for the different elements composing a scene.
  48257. * This class is dynamically extended by the different components of the scene increasing
  48258. * flexibility and reducing coupling
  48259. */
  48260. export abstract class AbstractScene {
  48261. /**
  48262. * Stores the list of available parsers in the application.
  48263. */
  48264. private static _BabylonFileParsers;
  48265. /**
  48266. * Stores the list of available individual parsers in the application.
  48267. */
  48268. private static _IndividualBabylonFileParsers;
  48269. /**
  48270. * Adds a parser in the list of available ones
  48271. * @param name Defines the name of the parser
  48272. * @param parser Defines the parser to add
  48273. */
  48274. static AddParser(name: string, parser: BabylonFileParser): void;
  48275. /**
  48276. * Gets a general parser from the list of avaialble ones
  48277. * @param name Defines the name of the parser
  48278. * @returns the requested parser or null
  48279. */
  48280. static GetParser(name: string): Nullable<BabylonFileParser>;
  48281. /**
  48282. * Adds n individual parser in the list of available ones
  48283. * @param name Defines the name of the parser
  48284. * @param parser Defines the parser to add
  48285. */
  48286. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  48287. /**
  48288. * Gets an individual parser from the list of avaialble ones
  48289. * @param name Defines the name of the parser
  48290. * @returns the requested parser or null
  48291. */
  48292. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  48293. /**
  48294. * Parser json data and populate both a scene and its associated container object
  48295. * @param jsonData Defines the data to parse
  48296. * @param scene Defines the scene to parse the data for
  48297. * @param container Defines the container attached to the parsing sequence
  48298. * @param rootUrl Defines the root url of the data
  48299. */
  48300. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  48301. /**
  48302. * Gets the list of root nodes (ie. nodes with no parent)
  48303. */
  48304. rootNodes: Node[];
  48305. /** All of the cameras added to this scene
  48306. * @see https://doc.babylonjs.com/babylon101/cameras
  48307. */
  48308. cameras: Camera[];
  48309. /**
  48310. * All of the lights added to this scene
  48311. * @see https://doc.babylonjs.com/babylon101/lights
  48312. */
  48313. lights: Light[];
  48314. /**
  48315. * All of the (abstract) meshes added to this scene
  48316. */
  48317. meshes: AbstractMesh[];
  48318. /**
  48319. * The list of skeletons added to the scene
  48320. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  48321. */
  48322. skeletons: Skeleton[];
  48323. /**
  48324. * All of the particle systems added to this scene
  48325. * @see https://doc.babylonjs.com/babylon101/particles
  48326. */
  48327. particleSystems: IParticleSystem[];
  48328. /**
  48329. * Gets a list of Animations associated with the scene
  48330. */
  48331. animations: Animation[];
  48332. /**
  48333. * All of the animation groups added to this scene
  48334. * @see https://doc.babylonjs.com/how_to/group
  48335. */
  48336. animationGroups: AnimationGroup[];
  48337. /**
  48338. * All of the multi-materials added to this scene
  48339. * @see https://doc.babylonjs.com/how_to/multi_materials
  48340. */
  48341. multiMaterials: MultiMaterial[];
  48342. /**
  48343. * All of the materials added to this scene
  48344. * In the context of a Scene, it is not supposed to be modified manually.
  48345. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  48346. * Note also that the order of the Material within the array is not significant and might change.
  48347. * @see https://doc.babylonjs.com/babylon101/materials
  48348. */
  48349. materials: Material[];
  48350. /**
  48351. * The list of morph target managers added to the scene
  48352. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  48353. */
  48354. morphTargetManagers: MorphTargetManager[];
  48355. /**
  48356. * The list of geometries used in the scene.
  48357. */
  48358. geometries: Geometry[];
  48359. /**
  48360. * All of the tranform nodes added to this scene
  48361. * In the context of a Scene, it is not supposed to be modified manually.
  48362. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  48363. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  48364. * @see https://doc.babylonjs.com/how_to/transformnode
  48365. */
  48366. transformNodes: TransformNode[];
  48367. /**
  48368. * ActionManagers available on the scene.
  48369. */
  48370. actionManagers: AbstractActionManager[];
  48371. /**
  48372. * Textures to keep.
  48373. */
  48374. textures: BaseTexture[];
  48375. /** @hidden */
  48376. protected _environmentTexture: Nullable<BaseTexture>;
  48377. /**
  48378. * Texture used in all pbr material as the reflection texture.
  48379. * As in the majority of the scene they are the same (exception for multi room and so on),
  48380. * this is easier to reference from here than from all the materials.
  48381. */
  48382. get environmentTexture(): Nullable<BaseTexture>;
  48383. set environmentTexture(value: Nullable<BaseTexture>);
  48384. /**
  48385. * The list of postprocesses added to the scene
  48386. */
  48387. postProcesses: PostProcess[];
  48388. /**
  48389. * @returns all meshes, lights, cameras, transformNodes and bones
  48390. */
  48391. getNodes(): Array<Node>;
  48392. }
  48393. }
  48394. declare module BABYLON {
  48395. /**
  48396. * Interface used to define options for Sound class
  48397. */
  48398. export interface ISoundOptions {
  48399. /**
  48400. * Does the sound autoplay once loaded.
  48401. */
  48402. autoplay?: boolean;
  48403. /**
  48404. * Does the sound loop after it finishes playing once.
  48405. */
  48406. loop?: boolean;
  48407. /**
  48408. * Sound's volume
  48409. */
  48410. volume?: number;
  48411. /**
  48412. * Is it a spatial sound?
  48413. */
  48414. spatialSound?: boolean;
  48415. /**
  48416. * Maximum distance to hear that sound
  48417. */
  48418. maxDistance?: number;
  48419. /**
  48420. * Uses user defined attenuation function
  48421. */
  48422. useCustomAttenuation?: boolean;
  48423. /**
  48424. * Define the roll off factor of spatial sounds.
  48425. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48426. */
  48427. rolloffFactor?: number;
  48428. /**
  48429. * Define the reference distance the sound should be heard perfectly.
  48430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48431. */
  48432. refDistance?: number;
  48433. /**
  48434. * Define the distance attenuation model the sound will follow.
  48435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48436. */
  48437. distanceModel?: string;
  48438. /**
  48439. * Defines the playback speed (1 by default)
  48440. */
  48441. playbackRate?: number;
  48442. /**
  48443. * Defines if the sound is from a streaming source
  48444. */
  48445. streaming?: boolean;
  48446. /**
  48447. * Defines an optional length (in seconds) inside the sound file
  48448. */
  48449. length?: number;
  48450. /**
  48451. * Defines an optional offset (in seconds) inside the sound file
  48452. */
  48453. offset?: number;
  48454. /**
  48455. * If true, URLs will not be required to state the audio file codec to use.
  48456. */
  48457. skipCodecCheck?: boolean;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * Defines a sound that can be played in the application.
  48463. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  48464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48465. */
  48466. export class Sound {
  48467. /**
  48468. * The name of the sound in the scene.
  48469. */
  48470. name: string;
  48471. /**
  48472. * Does the sound autoplay once loaded.
  48473. */
  48474. autoplay: boolean;
  48475. private _loop;
  48476. /**
  48477. * Does the sound loop after it finishes playing once.
  48478. */
  48479. get loop(): boolean;
  48480. set loop(value: boolean);
  48481. /**
  48482. * Does the sound use a custom attenuation curve to simulate the falloff
  48483. * happening when the source gets further away from the camera.
  48484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48485. */
  48486. useCustomAttenuation: boolean;
  48487. /**
  48488. * The sound track id this sound belongs to.
  48489. */
  48490. soundTrackId: number;
  48491. /**
  48492. * Is this sound currently played.
  48493. */
  48494. isPlaying: boolean;
  48495. /**
  48496. * Is this sound currently paused.
  48497. */
  48498. isPaused: boolean;
  48499. /**
  48500. * Does this sound enables spatial sound.
  48501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48502. */
  48503. spatialSound: boolean;
  48504. /**
  48505. * Define the reference distance the sound should be heard perfectly.
  48506. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48507. */
  48508. refDistance: number;
  48509. /**
  48510. * Define the roll off factor of spatial sounds.
  48511. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48512. */
  48513. rolloffFactor: number;
  48514. /**
  48515. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  48516. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48517. */
  48518. maxDistance: number;
  48519. /**
  48520. * Define the distance attenuation model the sound will follow.
  48521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48522. */
  48523. distanceModel: string;
  48524. /**
  48525. * @hidden
  48526. * Back Compat
  48527. **/
  48528. onended: () => any;
  48529. /**
  48530. * Gets or sets an object used to store user defined information for the sound.
  48531. */
  48532. metadata: any;
  48533. /**
  48534. * Observable event when the current playing sound finishes.
  48535. */
  48536. onEndedObservable: Observable<Sound>;
  48537. /**
  48538. * Gets the current time for the sound.
  48539. */
  48540. get currentTime(): number;
  48541. private _panningModel;
  48542. private _playbackRate;
  48543. private _streaming;
  48544. private _startTime;
  48545. private _startOffset;
  48546. private _position;
  48547. /** @hidden */
  48548. _positionInEmitterSpace: boolean;
  48549. private _localDirection;
  48550. private _volume;
  48551. private _isReadyToPlay;
  48552. private _isDirectional;
  48553. private _readyToPlayCallback;
  48554. private _audioBuffer;
  48555. private _soundSource;
  48556. private _streamingSource;
  48557. private _soundPanner;
  48558. private _soundGain;
  48559. private _inputAudioNode;
  48560. private _outputAudioNode;
  48561. private _coneInnerAngle;
  48562. private _coneOuterAngle;
  48563. private _coneOuterGain;
  48564. private _scene;
  48565. private _connectedTransformNode;
  48566. private _customAttenuationFunction;
  48567. private _registerFunc;
  48568. private _isOutputConnected;
  48569. private _htmlAudioElement;
  48570. private _urlType;
  48571. private _length?;
  48572. private _offset?;
  48573. /** @hidden */
  48574. static _SceneComponentInitialization: (scene: Scene) => void;
  48575. /**
  48576. * Create a sound and attach it to a scene
  48577. * @param name Name of your sound
  48578. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  48579. * @param scene defines the scene the sound belongs to
  48580. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  48581. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  48582. */
  48583. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  48584. /**
  48585. * Release the sound and its associated resources
  48586. */
  48587. dispose(): void;
  48588. /**
  48589. * Gets if the sounds is ready to be played or not.
  48590. * @returns true if ready, otherwise false
  48591. */
  48592. isReady(): boolean;
  48593. /**
  48594. * Get the current class name.
  48595. * @returns current class name
  48596. */
  48597. getClassName(): string;
  48598. private _soundLoaded;
  48599. /**
  48600. * Sets the data of the sound from an audiobuffer
  48601. * @param audioBuffer The audioBuffer containing the data
  48602. */
  48603. setAudioBuffer(audioBuffer: AudioBuffer): void;
  48604. /**
  48605. * Updates the current sounds options such as maxdistance, loop...
  48606. * @param options A JSON object containing values named as the object properties
  48607. */
  48608. updateOptions(options: ISoundOptions): void;
  48609. private _createSpatialParameters;
  48610. private _updateSpatialParameters;
  48611. /**
  48612. * Switch the panning model to HRTF:
  48613. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48615. */
  48616. switchPanningModelToHRTF(): void;
  48617. /**
  48618. * Switch the panning model to Equal Power:
  48619. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48621. */
  48622. switchPanningModelToEqualPower(): void;
  48623. private _switchPanningModel;
  48624. /**
  48625. * Connect this sound to a sound track audio node like gain...
  48626. * @param soundTrackAudioNode the sound track audio node to connect to
  48627. */
  48628. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48629. /**
  48630. * Transform this sound into a directional source
  48631. * @param coneInnerAngle Size of the inner cone in degree
  48632. * @param coneOuterAngle Size of the outer cone in degree
  48633. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48634. */
  48635. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48636. /**
  48637. * Gets or sets the inner angle for the directional cone.
  48638. */
  48639. get directionalConeInnerAngle(): number;
  48640. /**
  48641. * Gets or sets the inner angle for the directional cone.
  48642. */
  48643. set directionalConeInnerAngle(value: number);
  48644. /**
  48645. * Gets or sets the outer angle for the directional cone.
  48646. */
  48647. get directionalConeOuterAngle(): number;
  48648. /**
  48649. * Gets or sets the outer angle for the directional cone.
  48650. */
  48651. set directionalConeOuterAngle(value: number);
  48652. /**
  48653. * Sets the position of the emitter if spatial sound is enabled
  48654. * @param newPosition Defines the new position
  48655. */
  48656. setPosition(newPosition: Vector3): void;
  48657. /**
  48658. * Sets the local direction of the emitter if spatial sound is enabled
  48659. * @param newLocalDirection Defines the new local direction
  48660. */
  48661. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48662. private _updateDirection;
  48663. /** @hidden */
  48664. updateDistanceFromListener(): void;
  48665. /**
  48666. * Sets a new custom attenuation function for the sound.
  48667. * @param callback Defines the function used for the attenuation
  48668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48669. */
  48670. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48671. /**
  48672. * Play the sound
  48673. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48674. * @param offset (optional) Start the sound at a specific time in seconds
  48675. * @param length (optional) Sound duration (in seconds)
  48676. */
  48677. play(time?: number, offset?: number, length?: number): void;
  48678. private _onended;
  48679. /**
  48680. * Stop the sound
  48681. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48682. */
  48683. stop(time?: number): void;
  48684. /**
  48685. * Put the sound in pause
  48686. */
  48687. pause(): void;
  48688. /**
  48689. * Sets a dedicated volume for this sounds
  48690. * @param newVolume Define the new volume of the sound
  48691. * @param time Define time for gradual change to new volume
  48692. */
  48693. setVolume(newVolume: number, time?: number): void;
  48694. /**
  48695. * Set the sound play back rate
  48696. * @param newPlaybackRate Define the playback rate the sound should be played at
  48697. */
  48698. setPlaybackRate(newPlaybackRate: number): void;
  48699. /**
  48700. * Gets the volume of the sound.
  48701. * @returns the volume of the sound
  48702. */
  48703. getVolume(): number;
  48704. /**
  48705. * Attach the sound to a dedicated mesh
  48706. * @param transformNode The transform node to connect the sound with
  48707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48708. */
  48709. attachToMesh(transformNode: TransformNode): void;
  48710. /**
  48711. * Detach the sound from the previously attached mesh
  48712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48713. */
  48714. detachFromMesh(): void;
  48715. private _onRegisterAfterWorldMatrixUpdate;
  48716. /**
  48717. * Clone the current sound in the scene.
  48718. * @returns the new sound clone
  48719. */
  48720. clone(): Nullable<Sound>;
  48721. /**
  48722. * Gets the current underlying audio buffer containing the data
  48723. * @returns the audio buffer
  48724. */
  48725. getAudioBuffer(): Nullable<AudioBuffer>;
  48726. /**
  48727. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48728. * @returns the source node
  48729. */
  48730. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48731. /**
  48732. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48733. * @returns the gain node
  48734. */
  48735. getSoundGain(): Nullable<GainNode>;
  48736. /**
  48737. * Serializes the Sound in a JSON representation
  48738. * @returns the JSON representation of the sound
  48739. */
  48740. serialize(): any;
  48741. /**
  48742. * Parse a JSON representation of a sound to instantiate in a given scene
  48743. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48744. * @param scene Define the scene the new parsed sound should be created in
  48745. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48746. * @param sourceSound Define a sound place holder if do not need to instantiate a new one
  48747. * @returns the newly parsed sound
  48748. */
  48749. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48750. }
  48751. }
  48752. declare module BABYLON {
  48753. /**
  48754. * This defines an action helpful to play a defined sound on a triggered action.
  48755. */
  48756. export class PlaySoundAction extends Action {
  48757. private _sound;
  48758. /**
  48759. * Instantiate the action
  48760. * @param triggerOptions defines the trigger options
  48761. * @param sound defines the sound to play
  48762. * @param condition defines the trigger related conditions
  48763. */
  48764. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48765. /** @hidden */
  48766. _prepare(): void;
  48767. /**
  48768. * Execute the action and play the sound.
  48769. */
  48770. execute(): void;
  48771. /**
  48772. * Serializes the actions and its related information.
  48773. * @param parent defines the object to serialize in
  48774. * @returns the serialized object
  48775. */
  48776. serialize(parent: any): any;
  48777. }
  48778. /**
  48779. * This defines an action helpful to stop a defined sound on a triggered action.
  48780. */
  48781. export class StopSoundAction extends Action {
  48782. private _sound;
  48783. /**
  48784. * Instantiate the action
  48785. * @param triggerOptions defines the trigger options
  48786. * @param sound defines the sound to stop
  48787. * @param condition defines the trigger related conditions
  48788. */
  48789. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48790. /** @hidden */
  48791. _prepare(): void;
  48792. /**
  48793. * Execute the action and stop the sound.
  48794. */
  48795. execute(): void;
  48796. /**
  48797. * Serializes the actions and its related information.
  48798. * @param parent defines the object to serialize in
  48799. * @returns the serialized object
  48800. */
  48801. serialize(parent: any): any;
  48802. }
  48803. }
  48804. declare module BABYLON {
  48805. /**
  48806. * This defines an action responsible to change the value of a property
  48807. * by interpolating between its current value and the newly set one once triggered.
  48808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48809. */
  48810. export class InterpolateValueAction extends Action {
  48811. /**
  48812. * Defines the path of the property where the value should be interpolated
  48813. */
  48814. propertyPath: string;
  48815. /**
  48816. * Defines the target value at the end of the interpolation.
  48817. */
  48818. value: any;
  48819. /**
  48820. * Defines the time it will take for the property to interpolate to the value.
  48821. */
  48822. duration: number;
  48823. /**
  48824. * Defines if the other scene animations should be stopped when the action has been triggered
  48825. */
  48826. stopOtherAnimations?: boolean;
  48827. /**
  48828. * Defines a callback raised once the interpolation animation has been done.
  48829. */
  48830. onInterpolationDone?: () => void;
  48831. /**
  48832. * Observable triggered once the interpolation animation has been done.
  48833. */
  48834. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48835. private _target;
  48836. private _effectiveTarget;
  48837. private _property;
  48838. /**
  48839. * Instantiate the action
  48840. * @param triggerOptions defines the trigger options
  48841. * @param target defines the object containing the value to interpolate
  48842. * @param propertyPath defines the path to the property in the target object
  48843. * @param value defines the target value at the end of the interpolation
  48844. * @param duration defines the time it will take for the property to interpolate to the value.
  48845. * @param condition defines the trigger related conditions
  48846. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48847. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48848. */
  48849. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48850. /** @hidden */
  48851. _prepare(): void;
  48852. /**
  48853. * Execute the action starts the value interpolation.
  48854. */
  48855. execute(): void;
  48856. /**
  48857. * Serializes the actions and its related information.
  48858. * @param parent defines the object to serialize in
  48859. * @returns the serialized object
  48860. */
  48861. serialize(parent: any): any;
  48862. }
  48863. }
  48864. declare module BABYLON {
  48865. /**
  48866. * A cursor which tracks a point on a path
  48867. */
  48868. export class PathCursor {
  48869. private path;
  48870. /**
  48871. * Stores path cursor callbacks for when an onchange event is triggered
  48872. */
  48873. private _onchange;
  48874. /**
  48875. * The value of the path cursor
  48876. */
  48877. value: number;
  48878. /**
  48879. * The animation array of the path cursor
  48880. */
  48881. animations: Animation[];
  48882. /**
  48883. * Initializes the path cursor
  48884. * @param path The path to track
  48885. */
  48886. constructor(path: Path2);
  48887. /**
  48888. * Gets the cursor point on the path
  48889. * @returns A point on the path cursor at the cursor location
  48890. */
  48891. getPoint(): Vector3;
  48892. /**
  48893. * Moves the cursor ahead by the step amount
  48894. * @param step The amount to move the cursor forward
  48895. * @returns This path cursor
  48896. */
  48897. moveAhead(step?: number): PathCursor;
  48898. /**
  48899. * Moves the cursor behind by the step amount
  48900. * @param step The amount to move the cursor back
  48901. * @returns This path cursor
  48902. */
  48903. moveBack(step?: number): PathCursor;
  48904. /**
  48905. * Moves the cursor by the step amount
  48906. * If the step amount is greater than one, an exception is thrown
  48907. * @param step The amount to move the cursor
  48908. * @returns This path cursor
  48909. */
  48910. move(step: number): PathCursor;
  48911. /**
  48912. * Ensures that the value is limited between zero and one
  48913. * @returns This path cursor
  48914. */
  48915. private ensureLimits;
  48916. /**
  48917. * Runs onchange callbacks on change (used by the animation engine)
  48918. * @returns This path cursor
  48919. */
  48920. private raiseOnChange;
  48921. /**
  48922. * Executes a function on change
  48923. * @param f A path cursor onchange callback
  48924. * @returns This path cursor
  48925. */
  48926. onchange(f: (cursor: PathCursor) => void): PathCursor;
  48927. }
  48928. }
  48929. declare module BABYLON {
  48930. /**
  48931. * This represents the default audio engine used in babylon.
  48932. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48933. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48934. */
  48935. export class AudioEngine implements IAudioEngine {
  48936. private _audioContext;
  48937. private _audioContextInitialized;
  48938. private _muteButton;
  48939. private _hostElement;
  48940. /**
  48941. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48942. */
  48943. canUseWebAudio: boolean;
  48944. /**
  48945. * The master gain node defines the global audio volume of your audio engine.
  48946. */
  48947. masterGain: GainNode;
  48948. /**
  48949. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48950. * @ignoreNaming
  48951. */
  48952. WarnedWebAudioUnsupported: boolean;
  48953. /**
  48954. * Gets whether or not mp3 are supported by your browser.
  48955. */
  48956. isMP3supported: boolean;
  48957. /**
  48958. * Gets whether or not ogg are supported by your browser.
  48959. */
  48960. isOGGsupported: boolean;
  48961. /**
  48962. * Gets whether audio has been unlocked on the device.
  48963. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48964. * a user interaction has happened.
  48965. */
  48966. unlocked: boolean;
  48967. /**
  48968. * Defines if the audio engine relies on a custom unlocked button.
  48969. * In this case, the embedded button will not be displayed.
  48970. */
  48971. useCustomUnlockedButton: boolean;
  48972. /**
  48973. * Event raised when audio has been unlocked on the browser.
  48974. */
  48975. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48976. /**
  48977. * Event raised when audio has been locked on the browser.
  48978. */
  48979. onAudioLockedObservable: Observable<IAudioEngine>;
  48980. /**
  48981. * Gets the current AudioContext if available.
  48982. */
  48983. get audioContext(): Nullable<AudioContext>;
  48984. private _connectedAnalyser;
  48985. /**
  48986. * Instantiates a new audio engine.
  48987. *
  48988. * There should be only one per page as some browsers restrict the number
  48989. * of audio contexts you can create.
  48990. * @param hostElement defines the host element where to display the mute icon if necessary
  48991. */
  48992. constructor(hostElement?: Nullable<HTMLElement>);
  48993. /**
  48994. * Flags the audio engine in Locked state.
  48995. * This happens due to new browser policies preventing audio to autoplay.
  48996. */
  48997. lock(): void;
  48998. /**
  48999. * Unlocks the audio engine once a user action has been done on the dom.
  49000. * This is helpful to resume play once browser policies have been satisfied.
  49001. */
  49002. unlock(): void;
  49003. private _resumeAudioContext;
  49004. private _initializeAudioContext;
  49005. private _tryToRun;
  49006. private _triggerRunningState;
  49007. private _triggerSuspendedState;
  49008. private _displayMuteButton;
  49009. private _moveButtonToTopLeft;
  49010. private _onResize;
  49011. private _hideMuteButton;
  49012. /**
  49013. * Destroy and release the resources associated with the audio context.
  49014. */
  49015. dispose(): void;
  49016. /**
  49017. * Gets the global volume sets on the master gain.
  49018. * @returns the global volume if set or -1 otherwise
  49019. */
  49020. getGlobalVolume(): number;
  49021. /**
  49022. * Sets the global volume of your experience (sets on the master gain).
  49023. * @param newVolume Defines the new global volume of the application
  49024. */
  49025. setGlobalVolume(newVolume: number): void;
  49026. /**
  49027. * Connect the audio engine to an audio analyser allowing some amazing
  49028. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49030. * @param analyser The analyser to connect to the engine
  49031. */
  49032. connectToAnalyser(analyser: Analyser): void;
  49033. }
  49034. }
  49035. declare module BABYLON {
  49036. /**
  49037. * Options allowed during the creation of a sound track.
  49038. */
  49039. export interface ISoundTrackOptions {
  49040. /**
  49041. * The volume the sound track should take during creation
  49042. */
  49043. volume?: number;
  49044. /**
  49045. * Define if the sound track is the main sound track of the scene
  49046. */
  49047. mainTrack?: boolean;
  49048. }
  49049. /**
  49050. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  49051. * It will be also used in a future release to apply effects on a specific track.
  49052. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49053. */
  49054. export class SoundTrack {
  49055. /**
  49056. * The unique identifier of the sound track in the scene.
  49057. */
  49058. id: number;
  49059. /**
  49060. * The list of sounds included in the sound track.
  49061. */
  49062. soundCollection: Array<Sound>;
  49063. private _outputAudioNode;
  49064. private _scene;
  49065. private _connectedAnalyser;
  49066. private _options;
  49067. private _isInitialized;
  49068. /**
  49069. * Creates a new sound track.
  49070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  49071. * @param scene Define the scene the sound track belongs to
  49072. * @param options
  49073. */
  49074. constructor(scene: Scene, options?: ISoundTrackOptions);
  49075. private _initializeSoundTrackAudioGraph;
  49076. /**
  49077. * Release the sound track and its associated resources
  49078. */
  49079. dispose(): void;
  49080. /**
  49081. * Adds a sound to this sound track
  49082. * @param sound define the sound to add
  49083. * @ignoreNaming
  49084. */
  49085. addSound(sound: Sound): void;
  49086. /**
  49087. * Removes a sound to this sound track
  49088. * @param sound define the sound to remove
  49089. * @ignoreNaming
  49090. */
  49091. removeSound(sound: Sound): void;
  49092. /**
  49093. * Set a global volume for the full sound track.
  49094. * @param newVolume Define the new volume of the sound track
  49095. */
  49096. setVolume(newVolume: number): void;
  49097. /**
  49098. * Switch the panning model to HRTF:
  49099. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  49100. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49101. */
  49102. switchPanningModelToHRTF(): void;
  49103. /**
  49104. * Switch the panning model to Equal Power:
  49105. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  49106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  49107. */
  49108. switchPanningModelToEqualPower(): void;
  49109. /**
  49110. * Connect the sound track to an audio analyser allowing some amazing
  49111. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  49112. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  49113. * @param analyser The analyser to connect to the engine
  49114. */
  49115. connectToAnalyser(analyser: Analyser): void;
  49116. }
  49117. }
  49118. declare module BABYLON {
  49119. interface AbstractScene {
  49120. /**
  49121. * The list of sounds used in the scene.
  49122. */
  49123. sounds: Nullable<Array<Sound>>;
  49124. }
  49125. interface Scene {
  49126. /**
  49127. * @hidden
  49128. * Backing field
  49129. */
  49130. _mainSoundTrack: SoundTrack;
  49131. /**
  49132. * The main sound track played by the scene.
  49133. * It contains your primary collection of sounds.
  49134. */
  49135. mainSoundTrack: SoundTrack;
  49136. /**
  49137. * The list of sound tracks added to the scene
  49138. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49139. */
  49140. soundTracks: Nullable<Array<SoundTrack>>;
  49141. /**
  49142. * Gets a sound using a given name
  49143. * @param name defines the name to search for
  49144. * @return the found sound or null if not found at all.
  49145. */
  49146. getSoundByName(name: string): Nullable<Sound>;
  49147. /**
  49148. * Gets or sets if audio support is enabled
  49149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49150. */
  49151. audioEnabled: boolean;
  49152. /**
  49153. * Gets or sets if audio will be output to headphones
  49154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49155. */
  49156. headphone: boolean;
  49157. /**
  49158. * Gets or sets custom audio listener position provider
  49159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  49160. */
  49161. audioListenerPositionProvider: Nullable<() => Vector3>;
  49162. /**
  49163. * Gets or sets a refresh rate when using 3D audio positioning
  49164. */
  49165. audioPositioningRefreshRate: number;
  49166. }
  49167. /**
  49168. * Defines the sound scene component responsible to manage any sounds
  49169. * in a given scene.
  49170. */
  49171. export class AudioSceneComponent implements ISceneSerializableComponent {
  49172. private static _CameraDirectionLH;
  49173. private static _CameraDirectionRH;
  49174. /**
  49175. * The component name helpful to identify the component in the list of scene components.
  49176. */
  49177. readonly name: string;
  49178. /**
  49179. * The scene the component belongs to.
  49180. */
  49181. scene: Scene;
  49182. private _audioEnabled;
  49183. /**
  49184. * Gets whether audio is enabled or not.
  49185. * Please use related enable/disable method to switch state.
  49186. */
  49187. get audioEnabled(): boolean;
  49188. private _headphone;
  49189. /**
  49190. * Gets whether audio is outputting to headphone or not.
  49191. * Please use the according Switch methods to change output.
  49192. */
  49193. get headphone(): boolean;
  49194. /**
  49195. * Gets or sets a refresh rate when using 3D audio positioning
  49196. */
  49197. audioPositioningRefreshRate: number;
  49198. private _audioListenerPositionProvider;
  49199. /**
  49200. * Gets the current audio listener position provider
  49201. */
  49202. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  49203. /**
  49204. * Sets a custom listener position for all sounds in the scene
  49205. * By default, this is the position of the first active camera
  49206. */
  49207. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  49208. /**
  49209. * Creates a new instance of the component for the given scene
  49210. * @param scene Defines the scene to register the component in
  49211. */
  49212. constructor(scene: Scene);
  49213. /**
  49214. * Registers the component in a given scene
  49215. */
  49216. register(): void;
  49217. /**
  49218. * Rebuilds the elements related to this component in case of
  49219. * context lost for instance.
  49220. */
  49221. rebuild(): void;
  49222. /**
  49223. * Serializes the component data to the specified json object
  49224. * @param serializationObject The object to serialize to
  49225. */
  49226. serialize(serializationObject: any): void;
  49227. /**
  49228. * Adds all the elements from the container to the scene
  49229. * @param container the container holding the elements
  49230. */
  49231. addFromContainer(container: AbstractScene): void;
  49232. /**
  49233. * Removes all the elements in the container from the scene
  49234. * @param container contains the elements to remove
  49235. * @param dispose if the removed element should be disposed (default: false)
  49236. */
  49237. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49238. /**
  49239. * Disposes the component and the associated resources.
  49240. */
  49241. dispose(): void;
  49242. /**
  49243. * Disables audio in the associated scene.
  49244. */
  49245. disableAudio(): void;
  49246. /**
  49247. * Enables audio in the associated scene.
  49248. */
  49249. enableAudio(): void;
  49250. /**
  49251. * Switch audio to headphone output.
  49252. */
  49253. switchAudioModeForHeadphones(): void;
  49254. /**
  49255. * Switch audio to normal speakers.
  49256. */
  49257. switchAudioModeForNormalSpeakers(): void;
  49258. private _cachedCameraDirection;
  49259. private _cachedCameraPosition;
  49260. private _lastCheck;
  49261. private _afterRender;
  49262. }
  49263. }
  49264. declare module BABYLON {
  49265. /**
  49266. * Wraps one or more Sound objects and selects one with random weight for playback.
  49267. */
  49268. export class WeightedSound {
  49269. /** When true a Sound will be selected and played when the current playing Sound completes. */
  49270. loop: boolean;
  49271. private _coneInnerAngle;
  49272. private _coneOuterAngle;
  49273. private _volume;
  49274. /** A Sound is currently playing. */
  49275. isPlaying: boolean;
  49276. /** A Sound is currently paused. */
  49277. isPaused: boolean;
  49278. private _sounds;
  49279. private _weights;
  49280. private _currentIndex?;
  49281. /**
  49282. * Creates a new WeightedSound from the list of sounds given.
  49283. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  49284. * @param sounds Array of Sounds that will be selected from.
  49285. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  49286. */
  49287. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  49288. /**
  49289. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49290. */
  49291. get directionalConeInnerAngle(): number;
  49292. /**
  49293. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  49294. */
  49295. set directionalConeInnerAngle(value: number);
  49296. /**
  49297. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49298. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49299. */
  49300. get directionalConeOuterAngle(): number;
  49301. /**
  49302. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  49303. * Listener angles between innerAngle and outerAngle will falloff linearly.
  49304. */
  49305. set directionalConeOuterAngle(value: number);
  49306. /**
  49307. * Playback volume.
  49308. */
  49309. get volume(): number;
  49310. /**
  49311. * Playback volume.
  49312. */
  49313. set volume(value: number);
  49314. private _onended;
  49315. /**
  49316. * Suspend playback
  49317. */
  49318. pause(): void;
  49319. /**
  49320. * Stop playback
  49321. */
  49322. stop(): void;
  49323. /**
  49324. * Start playback.
  49325. * @param startOffset Position the clip head at a specific time in seconds.
  49326. */
  49327. play(startOffset?: number): void;
  49328. }
  49329. }
  49330. declare module BABYLON {
  49331. /**
  49332. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  49333. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49334. */
  49335. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  49336. /**
  49337. * Gets the name of the behavior.
  49338. */
  49339. get name(): string;
  49340. /**
  49341. * The easing function used by animations
  49342. */
  49343. static EasingFunction: BackEase;
  49344. /**
  49345. * The easing mode used by animations
  49346. */
  49347. static EasingMode: number;
  49348. /**
  49349. * The duration of the animation, in milliseconds
  49350. */
  49351. transitionDuration: number;
  49352. /**
  49353. * Length of the distance animated by the transition when lower radius is reached
  49354. */
  49355. lowerRadiusTransitionRange: number;
  49356. /**
  49357. * Length of the distance animated by the transition when upper radius is reached
  49358. */
  49359. upperRadiusTransitionRange: number;
  49360. private _autoTransitionRange;
  49361. /**
  49362. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49363. */
  49364. get autoTransitionRange(): boolean;
  49365. /**
  49366. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  49367. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  49368. */
  49369. set autoTransitionRange(value: boolean);
  49370. private _attachedCamera;
  49371. private _onAfterCheckInputsObserver;
  49372. private _onMeshTargetChangedObserver;
  49373. /**
  49374. * Initializes the behavior.
  49375. */
  49376. init(): void;
  49377. /**
  49378. * Attaches the behavior to its arc rotate camera.
  49379. * @param camera Defines the camera to attach the behavior to
  49380. */
  49381. attach(camera: ArcRotateCamera): void;
  49382. /**
  49383. * Detaches the behavior from its current arc rotate camera.
  49384. */
  49385. detach(): void;
  49386. private _radiusIsAnimating;
  49387. private _radiusBounceTransition;
  49388. private _animatables;
  49389. private _cachedWheelPrecision;
  49390. /**
  49391. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  49392. * @param radiusLimit The limit to check against.
  49393. * @return Bool to indicate if at limit.
  49394. */
  49395. private _isRadiusAtLimit;
  49396. /**
  49397. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  49398. * @param radiusDelta The delta by which to animate to. Can be negative.
  49399. */
  49400. private _applyBoundRadiusAnimation;
  49401. /**
  49402. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  49403. */
  49404. protected _clearAnimationLocks(): void;
  49405. /**
  49406. * Stops and removes all animations that have been applied to the camera
  49407. */
  49408. stopAllAnimations(): void;
  49409. }
  49410. }
  49411. declare module BABYLON {
  49412. /**
  49413. * 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.
  49414. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49415. */
  49416. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  49417. /**
  49418. * Gets the name of the behavior.
  49419. */
  49420. get name(): string;
  49421. private _mode;
  49422. private _radiusScale;
  49423. private _positionScale;
  49424. private _defaultElevation;
  49425. private _elevationReturnTime;
  49426. private _elevationReturnWaitTime;
  49427. private _zoomStopsAnimation;
  49428. private _framingTime;
  49429. /**
  49430. * The easing function used by animations
  49431. */
  49432. static EasingFunction: ExponentialEase;
  49433. /**
  49434. * The easing mode used by animations
  49435. */
  49436. static EasingMode: number;
  49437. /**
  49438. * Sets the current mode used by the behavior
  49439. */
  49440. set mode(mode: number);
  49441. /**
  49442. * Gets current mode used by the behavior.
  49443. */
  49444. get mode(): number;
  49445. /**
  49446. * Sets the scale applied to the radius (1 by default)
  49447. */
  49448. set radiusScale(radius: number);
  49449. /**
  49450. * Gets the scale applied to the radius
  49451. */
  49452. get radiusScale(): number;
  49453. /**
  49454. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49455. */
  49456. set positionScale(scale: number);
  49457. /**
  49458. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  49459. */
  49460. get positionScale(): number;
  49461. /**
  49462. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49463. * behaviour is triggered, in radians.
  49464. */
  49465. set defaultElevation(elevation: number);
  49466. /**
  49467. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  49468. * behaviour is triggered, in radians.
  49469. */
  49470. get defaultElevation(): number;
  49471. /**
  49472. * Sets the time (in milliseconds) taken to return to the default beta position.
  49473. * Negative value indicates camera should not return to default.
  49474. */
  49475. set elevationReturnTime(speed: number);
  49476. /**
  49477. * Gets the time (in milliseconds) taken to return to the default beta position.
  49478. * Negative value indicates camera should not return to default.
  49479. */
  49480. get elevationReturnTime(): number;
  49481. /**
  49482. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49483. */
  49484. set elevationReturnWaitTime(time: number);
  49485. /**
  49486. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  49487. */
  49488. get elevationReturnWaitTime(): number;
  49489. /**
  49490. * Sets the flag that indicates if user zooming should stop animation.
  49491. */
  49492. set zoomStopsAnimation(flag: boolean);
  49493. /**
  49494. * Gets the flag that indicates if user zooming should stop animation.
  49495. */
  49496. get zoomStopsAnimation(): boolean;
  49497. /**
  49498. * Sets the transition time when framing the mesh, in milliseconds
  49499. */
  49500. set framingTime(time: number);
  49501. /**
  49502. * Gets the transition time when framing the mesh, in milliseconds
  49503. */
  49504. get framingTime(): number;
  49505. /**
  49506. * Define if the behavior should automatically change the configured
  49507. * camera limits and sensibilities.
  49508. */
  49509. autoCorrectCameraLimitsAndSensibility: boolean;
  49510. private _onPrePointerObservableObserver;
  49511. private _onAfterCheckInputsObserver;
  49512. private _onMeshTargetChangedObserver;
  49513. private _attachedCamera;
  49514. private _isPointerDown;
  49515. private _lastInteractionTime;
  49516. /**
  49517. * Initializes the behavior.
  49518. */
  49519. init(): void;
  49520. /**
  49521. * Attaches the behavior to its arc rotate camera.
  49522. * @param camera Defines the camera to attach the behavior to
  49523. */
  49524. attach(camera: ArcRotateCamera): void;
  49525. /**
  49526. * Detaches the behavior from its current arc rotate camera.
  49527. */
  49528. detach(): void;
  49529. private _animatables;
  49530. private _betaIsAnimating;
  49531. private _betaTransition;
  49532. private _radiusTransition;
  49533. private _vectorTransition;
  49534. /**
  49535. * Targets the given mesh and updates zoom level accordingly.
  49536. * @param mesh The mesh to target.
  49537. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49538. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49539. */
  49540. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49541. /**
  49542. * Targets the given mesh with its children and updates zoom level accordingly.
  49543. * @param mesh The mesh to target.
  49544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49546. */
  49547. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49548. /**
  49549. * Targets the given meshes with their children and updates zoom level accordingly.
  49550. * @param meshes The mesh to target.
  49551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49553. */
  49554. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49555. /**
  49556. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  49557. * @param minimumWorld Determines the smaller position of the bounding box extend
  49558. * @param maximumWorld Determines the bigger position of the bounding box extend
  49559. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  49560. * @param onAnimationEnd Callback triggered at the end of the framing animation
  49561. */
  49562. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  49563. /**
  49564. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  49565. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  49566. * frustum width.
  49567. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  49568. * to fully enclose the mesh in the viewing frustum.
  49569. */
  49570. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  49571. /**
  49572. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  49573. * is automatically returned to its default position (expected to be above ground plane).
  49574. */
  49575. private _maintainCameraAboveGround;
  49576. /**
  49577. * Returns the frustum slope based on the canvas ratio and camera FOV
  49578. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  49579. */
  49580. private _getFrustumSlope;
  49581. /**
  49582. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  49583. */
  49584. private _clearAnimationLocks;
  49585. /**
  49586. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49587. */
  49588. private _applyUserInteraction;
  49589. /**
  49590. * Stops and removes all animations that have been applied to the camera
  49591. */
  49592. stopAllAnimations(): void;
  49593. /**
  49594. * Gets a value indicating if the user is moving the camera
  49595. */
  49596. get isUserIsMoving(): boolean;
  49597. /**
  49598. * The camera can move all the way towards the mesh.
  49599. */
  49600. static IgnoreBoundsSizeMode: number;
  49601. /**
  49602. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  49603. */
  49604. static FitFrustumSidesMode: number;
  49605. }
  49606. }
  49607. declare module BABYLON {
  49608. /**
  49609. * Base class for Camera Pointer Inputs.
  49610. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  49611. * for example usage.
  49612. */
  49613. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  49614. /**
  49615. * Defines the camera the input is attached to.
  49616. */
  49617. abstract camera: Camera;
  49618. /**
  49619. * Whether keyboard modifier keys are pressed at time of last mouse event.
  49620. */
  49621. protected _altKey: boolean;
  49622. protected _ctrlKey: boolean;
  49623. protected _metaKey: boolean;
  49624. protected _shiftKey: boolean;
  49625. /**
  49626. * Which mouse buttons were pressed at time of last mouse event.
  49627. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  49628. */
  49629. protected _buttonsPressed: number;
  49630. /**
  49631. * Defines the buttons associated with the input to handle camera move.
  49632. */
  49633. buttons: number[];
  49634. /**
  49635. * Attach the input controls to a specific dom element to get the input from.
  49636. * @param element Defines the element the controls should be listened from
  49637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49638. */
  49639. attachControl(noPreventDefault?: boolean): void;
  49640. /**
  49641. * Detach the current controls from the specified dom element.
  49642. */
  49643. detachControl(): void;
  49644. /**
  49645. * Gets the class name of the current input.
  49646. * @returns the class name
  49647. */
  49648. getClassName(): string;
  49649. /**
  49650. * Get the friendly name associated with the input class.
  49651. * @returns the input friendly name
  49652. */
  49653. getSimpleName(): string;
  49654. /**
  49655. * Called on pointer POINTERDOUBLETAP event.
  49656. * Override this method to provide functionality on POINTERDOUBLETAP event.
  49657. */
  49658. protected onDoubleTap(type: string): void;
  49659. /**
  49660. * Called on pointer POINTERMOVE event if only a single touch is active.
  49661. * Override this method to provide functionality.
  49662. */
  49663. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49664. /**
  49665. * Called on pointer POINTERMOVE event if multiple touches are active.
  49666. * Override this method to provide functionality.
  49667. */
  49668. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49669. /**
  49670. * Called on JS contextmenu event.
  49671. * Override this method to provide functionality.
  49672. */
  49673. protected onContextMenu(evt: PointerEvent): void;
  49674. /**
  49675. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49676. * press.
  49677. * Override this method to provide functionality.
  49678. */
  49679. protected onButtonDown(evt: PointerEvent): void;
  49680. /**
  49681. * Called each time a new POINTERUP event occurs. Ie, for each button
  49682. * release.
  49683. * Override this method to provide functionality.
  49684. */
  49685. protected onButtonUp(evt: PointerEvent): void;
  49686. /**
  49687. * Called when window becomes inactive.
  49688. * Override this method to provide functionality.
  49689. */
  49690. protected onLostFocus(): void;
  49691. private _pointerInput;
  49692. private _observer;
  49693. private _onLostFocus;
  49694. private pointA;
  49695. private pointB;
  49696. }
  49697. }
  49698. declare module BABYLON {
  49699. /**
  49700. * Manage the pointers inputs to control an arc rotate camera.
  49701. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49702. */
  49703. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49704. /**
  49705. * Defines the camera the input is attached to.
  49706. */
  49707. camera: ArcRotateCamera;
  49708. /**
  49709. * Gets the class name of the current input.
  49710. * @returns the class name
  49711. */
  49712. getClassName(): string;
  49713. /**
  49714. * Defines the buttons associated with the input to handle camera move.
  49715. */
  49716. buttons: number[];
  49717. /**
  49718. * Defines the pointer angular sensibility along the X axis or how fast is
  49719. * the camera rotating.
  49720. */
  49721. angularSensibilityX: number;
  49722. /**
  49723. * Defines the pointer angular sensibility along the Y axis or how fast is
  49724. * the camera rotating.
  49725. */
  49726. angularSensibilityY: number;
  49727. /**
  49728. * Defines the pointer pinch precision or how fast is the camera zooming.
  49729. */
  49730. pinchPrecision: number;
  49731. /**
  49732. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49733. * from 0.
  49734. * It defines the percentage of current camera.radius to use as delta when
  49735. * pinch zoom is used.
  49736. */
  49737. pinchDeltaPercentage: number;
  49738. /**
  49739. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49740. * that any object in the plane at the camera's target point will scale
  49741. * perfectly with finger motion.
  49742. * Overrides pinchDeltaPercentage and pinchPrecision.
  49743. */
  49744. useNaturalPinchZoom: boolean;
  49745. /**
  49746. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49747. */
  49748. pinchZoom: boolean;
  49749. /**
  49750. * Defines the pointer panning sensibility or how fast is the camera moving.
  49751. */
  49752. panningSensibility: number;
  49753. /**
  49754. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49755. */
  49756. multiTouchPanning: boolean;
  49757. /**
  49758. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49759. * zoom (pinch) through multitouch.
  49760. */
  49761. multiTouchPanAndZoom: boolean;
  49762. /**
  49763. * Revers pinch action direction.
  49764. */
  49765. pinchInwards: boolean;
  49766. private _isPanClick;
  49767. private _twoFingerActivityCount;
  49768. private _isPinching;
  49769. /**
  49770. * Move camera from multi touch panning positions.
  49771. */
  49772. private _computeMultiTouchPanning;
  49773. /**
  49774. * Move camera from pinch zoom distances.
  49775. */
  49776. private _computePinchZoom;
  49777. /**
  49778. * Called on pointer POINTERMOVE event if only a single touch is active.
  49779. */
  49780. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49781. /**
  49782. * Called on pointer POINTERDOUBLETAP event.
  49783. */
  49784. protected onDoubleTap(type: string): void;
  49785. /**
  49786. * Called on pointer POINTERMOVE event if multiple touches are active.
  49787. */
  49788. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49789. /**
  49790. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49791. * press.
  49792. */
  49793. protected onButtonDown(evt: PointerEvent): void;
  49794. /**
  49795. * Called each time a new POINTERUP event occurs. Ie, for each button
  49796. * release.
  49797. */
  49798. protected onButtonUp(evt: PointerEvent): void;
  49799. /**
  49800. * Called when window becomes inactive.
  49801. */
  49802. protected onLostFocus(): void;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49808. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49809. */
  49810. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49811. /**
  49812. * Defines the camera the input is attached to.
  49813. */
  49814. camera: ArcRotateCamera;
  49815. /**
  49816. * Defines the list of key codes associated with the up action (increase alpha)
  49817. */
  49818. keysUp: number[];
  49819. /**
  49820. * Defines the list of key codes associated with the down action (decrease alpha)
  49821. */
  49822. keysDown: number[];
  49823. /**
  49824. * Defines the list of key codes associated with the left action (increase beta)
  49825. */
  49826. keysLeft: number[];
  49827. /**
  49828. * Defines the list of key codes associated with the right action (decrease beta)
  49829. */
  49830. keysRight: number[];
  49831. /**
  49832. * Defines the list of key codes associated with the reset action.
  49833. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49834. */
  49835. keysReset: number[];
  49836. /**
  49837. * Defines the panning sensibility of the inputs.
  49838. * (How fast is the camera panning)
  49839. */
  49840. panningSensibility: number;
  49841. /**
  49842. * Defines the zooming sensibility of the inputs.
  49843. * (How fast is the camera zooming)
  49844. */
  49845. zoomingSensibility: number;
  49846. /**
  49847. * Defines whether maintaining the alt key down switch the movement mode from
  49848. * orientation to zoom.
  49849. */
  49850. useAltToZoom: boolean;
  49851. /**
  49852. * Rotation speed of the camera
  49853. */
  49854. angularSpeed: number;
  49855. private _keys;
  49856. private _ctrlPressed;
  49857. private _altPressed;
  49858. private _onCanvasBlurObserver;
  49859. private _onKeyboardObserver;
  49860. private _engine;
  49861. private _scene;
  49862. /**
  49863. * Attach the input controls to a specific dom element to get the input from.
  49864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49865. */
  49866. attachControl(noPreventDefault?: boolean): void;
  49867. /**
  49868. * Detach the current controls from the specified dom element.
  49869. */
  49870. detachControl(): void;
  49871. /**
  49872. * Update the current camera state depending on the inputs that have been used this frame.
  49873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49874. */
  49875. checkInputs(): void;
  49876. /**
  49877. * Gets the class name of the current input.
  49878. * @returns the class name
  49879. */
  49880. getClassName(): string;
  49881. /**
  49882. * Get the friendly name associated with the input class.
  49883. * @returns the input friendly name
  49884. */
  49885. getSimpleName(): string;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /**
  49890. * Manage the mouse wheel inputs to control an arc rotate camera.
  49891. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49892. */
  49893. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49894. /**
  49895. * Defines the camera the input is attached to.
  49896. */
  49897. camera: ArcRotateCamera;
  49898. /**
  49899. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49900. */
  49901. wheelPrecision: number;
  49902. /**
  49903. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49904. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49905. */
  49906. wheelDeltaPercentage: number;
  49907. private _wheel;
  49908. private _observer;
  49909. private computeDeltaFromMouseWheelLegacyEvent;
  49910. /**
  49911. * Attach the input controls to a specific dom element to get the input from.
  49912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49913. */
  49914. attachControl(noPreventDefault?: boolean): void;
  49915. /**
  49916. * Detach the current controls from the specified dom element.
  49917. */
  49918. detachControl(): void;
  49919. /**
  49920. * Gets the class name of the current input.
  49921. * @returns the class name
  49922. */
  49923. getClassName(): string;
  49924. /**
  49925. * Get the friendly name associated with the input class.
  49926. * @returns the input friendly name
  49927. */
  49928. getSimpleName(): string;
  49929. }
  49930. }
  49931. declare module BABYLON {
  49932. /**
  49933. * Default Inputs manager for the ArcRotateCamera.
  49934. * It groups all the default supported inputs for ease of use.
  49935. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49936. */
  49937. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49938. /**
  49939. * Instantiates a new ArcRotateCameraInputsManager.
  49940. * @param camera Defines the camera the inputs belong to
  49941. */
  49942. constructor(camera: ArcRotateCamera);
  49943. /**
  49944. * Add mouse wheel input support to the input manager.
  49945. * @returns the current input manager
  49946. */
  49947. addMouseWheel(): ArcRotateCameraInputsManager;
  49948. /**
  49949. * Add pointers input support to the input manager.
  49950. * @returns the current input manager
  49951. */
  49952. addPointers(): ArcRotateCameraInputsManager;
  49953. /**
  49954. * Add keyboard input support to the input manager.
  49955. * @returns the current input manager
  49956. */
  49957. addKeyboard(): ArcRotateCameraInputsManager;
  49958. }
  49959. }
  49960. declare module BABYLON {
  49961. /**
  49962. * This represents an orbital type of camera.
  49963. *
  49964. * 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.
  49965. * 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.
  49966. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49967. */
  49968. export class ArcRotateCamera extends TargetCamera {
  49969. /**
  49970. * Defines the rotation angle of the camera along the longitudinal axis.
  49971. */
  49972. alpha: number;
  49973. /**
  49974. * Defines the rotation angle of the camera along the latitudinal axis.
  49975. */
  49976. beta: number;
  49977. /**
  49978. * Defines the radius of the camera from it s target point.
  49979. */
  49980. radius: number;
  49981. protected _target: Vector3;
  49982. protected _targetHost: Nullable<AbstractMesh>;
  49983. /**
  49984. * Defines the target point of the camera.
  49985. * The camera looks towards it form the radius distance.
  49986. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49987. */
  49988. get target(): Vector3;
  49989. set target(value: Vector3);
  49990. /**
  49991. * Define the current local position of the camera in the scene
  49992. */
  49993. get position(): Vector3;
  49994. set position(newPosition: Vector3);
  49995. protected _upToYMatrix: Matrix;
  49996. protected _YToUpMatrix: Matrix;
  49997. /**
  49998. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49999. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  50000. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  50001. */
  50002. set upVector(vec: Vector3);
  50003. get upVector(): Vector3;
  50004. /**
  50005. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  50006. */
  50007. setMatUp(): void;
  50008. /**
  50009. * Current inertia value on the longitudinal axis.
  50010. * The bigger this number the longer it will take for the camera to stop.
  50011. */
  50012. inertialAlphaOffset: number;
  50013. /**
  50014. * Current inertia value on the latitudinal axis.
  50015. * The bigger this number the longer it will take for the camera to stop.
  50016. */
  50017. inertialBetaOffset: number;
  50018. /**
  50019. * Current inertia value on the radius axis.
  50020. * The bigger this number the longer it will take for the camera to stop.
  50021. */
  50022. inertialRadiusOffset: number;
  50023. /**
  50024. * Minimum allowed angle on the longitudinal axis.
  50025. * This can help limiting how the Camera is able to move in the scene.
  50026. */
  50027. lowerAlphaLimit: Nullable<number>;
  50028. /**
  50029. * Maximum allowed angle on the longitudinal axis.
  50030. * This can help limiting how the Camera is able to move in the scene.
  50031. */
  50032. upperAlphaLimit: Nullable<number>;
  50033. /**
  50034. * Minimum allowed angle on the latitudinal axis.
  50035. * This can help limiting how the Camera is able to move in the scene.
  50036. */
  50037. lowerBetaLimit: number;
  50038. /**
  50039. * Maximum allowed angle on the latitudinal axis.
  50040. * This can help limiting how the Camera is able to move in the scene.
  50041. */
  50042. upperBetaLimit: number;
  50043. /**
  50044. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  50045. * This can help limiting how the Camera is able to move in the scene.
  50046. */
  50047. lowerRadiusLimit: Nullable<number>;
  50048. /**
  50049. * Maximum allowed distance of the camera to the target (The camera can not get further).
  50050. * This can help limiting how the Camera is able to move in the scene.
  50051. */
  50052. upperRadiusLimit: Nullable<number>;
  50053. /**
  50054. * Defines the current inertia value used during panning of the camera along the X axis.
  50055. */
  50056. inertialPanningX: number;
  50057. /**
  50058. * Defines the current inertia value used during panning of the camera along the Y axis.
  50059. */
  50060. inertialPanningY: number;
  50061. /**
  50062. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  50063. * Basically if your fingers moves away from more than this distance you will be considered
  50064. * in pinch mode.
  50065. */
  50066. pinchToPanMaxDistance: number;
  50067. /**
  50068. * Defines the maximum distance the camera can pan.
  50069. * This could help keeping the camera always in your scene.
  50070. */
  50071. panningDistanceLimit: Nullable<number>;
  50072. /**
  50073. * Defines the target of the camera before panning.
  50074. */
  50075. panningOriginTarget: Vector3;
  50076. /**
  50077. * Defines the value of the inertia used during panning.
  50078. * 0 would mean stop inertia and one would mean no decelleration at all.
  50079. */
  50080. panningInertia: number;
  50081. /**
  50082. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  50083. */
  50084. get angularSensibilityX(): number;
  50085. set angularSensibilityX(value: number);
  50086. /**
  50087. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  50088. */
  50089. get angularSensibilityY(): number;
  50090. set angularSensibilityY(value: number);
  50091. /**
  50092. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  50093. */
  50094. get pinchPrecision(): number;
  50095. set pinchPrecision(value: number);
  50096. /**
  50097. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  50098. * It will be used instead of pinchDeltaPrecision if different from 0.
  50099. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50100. */
  50101. get pinchDeltaPercentage(): number;
  50102. set pinchDeltaPercentage(value: number);
  50103. /**
  50104. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  50105. * and pinch delta percentage.
  50106. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  50107. * that any object in the plane at the camera's target point will scale
  50108. * perfectly with finger motion.
  50109. */
  50110. get useNaturalPinchZoom(): boolean;
  50111. set useNaturalPinchZoom(value: boolean);
  50112. /**
  50113. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  50114. */
  50115. get panningSensibility(): number;
  50116. set panningSensibility(value: number);
  50117. /**
  50118. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  50119. */
  50120. get keysUp(): number[];
  50121. set keysUp(value: number[]);
  50122. /**
  50123. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  50124. */
  50125. get keysDown(): number[];
  50126. set keysDown(value: number[]);
  50127. /**
  50128. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  50129. */
  50130. get keysLeft(): number[];
  50131. set keysLeft(value: number[]);
  50132. /**
  50133. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  50134. */
  50135. get keysRight(): number[];
  50136. set keysRight(value: number[]);
  50137. /**
  50138. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  50139. */
  50140. get wheelPrecision(): number;
  50141. set wheelPrecision(value: number);
  50142. /**
  50143. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  50144. * It will be used instead of pinchDeltaPrecision if different from 0.
  50145. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  50146. */
  50147. get wheelDeltaPercentage(): number;
  50148. set wheelDeltaPercentage(value: number);
  50149. /**
  50150. * Defines how much the radius should be scaled while zooming on a particular mesh (through the zoomOn function)
  50151. */
  50152. zoomOnFactor: number;
  50153. /**
  50154. * Defines a screen offset for the camera position.
  50155. */
  50156. targetScreenOffset: Vector2;
  50157. /**
  50158. * Allows the camera to be completely reversed.
  50159. * If false the camera can not arrive upside down.
  50160. */
  50161. allowUpsideDown: boolean;
  50162. /**
  50163. * Define if double tap/click is used to restore the previously saved state of the camera.
  50164. */
  50165. useInputToRestoreState: boolean;
  50166. /** @hidden */
  50167. _viewMatrix: Matrix;
  50168. /** @hidden */
  50169. _useCtrlForPanning: boolean;
  50170. /** @hidden */
  50171. _panningMouseButton: number;
  50172. /**
  50173. * Defines the input associated to the camera.
  50174. */
  50175. inputs: ArcRotateCameraInputsManager;
  50176. /** @hidden */
  50177. _reset: () => void;
  50178. /**
  50179. * Defines the allowed panning axis.
  50180. */
  50181. panningAxis: Vector3;
  50182. protected _transformedDirection: Vector3;
  50183. private _bouncingBehavior;
  50184. /**
  50185. * Gets the bouncing behavior of the camera if it has been enabled.
  50186. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50187. */
  50188. get bouncingBehavior(): Nullable<BouncingBehavior>;
  50189. /**
  50190. * Defines if the bouncing behavior of the camera is enabled on the camera.
  50191. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  50192. */
  50193. get useBouncingBehavior(): boolean;
  50194. set useBouncingBehavior(value: boolean);
  50195. private _framingBehavior;
  50196. /**
  50197. * Gets the framing behavior of the camera if it has been enabled.
  50198. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50199. */
  50200. get framingBehavior(): Nullable<FramingBehavior>;
  50201. /**
  50202. * Defines if the framing behavior of the camera is enabled on the camera.
  50203. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  50204. */
  50205. get useFramingBehavior(): boolean;
  50206. set useFramingBehavior(value: boolean);
  50207. private _autoRotationBehavior;
  50208. /**
  50209. * Gets the auto rotation behavior of the camera if it has been enabled.
  50210. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50211. */
  50212. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  50213. /**
  50214. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  50215. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50216. */
  50217. get useAutoRotationBehavior(): boolean;
  50218. set useAutoRotationBehavior(value: boolean);
  50219. /**
  50220. * Observable triggered when the mesh target has been changed on the camera.
  50221. */
  50222. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  50223. /**
  50224. * Event raised when the camera is colliding with a mesh.
  50225. */
  50226. onCollide: (collidedMesh: AbstractMesh) => void;
  50227. /**
  50228. * Defines whether the camera should check collision with the objects oh the scene.
  50229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  50230. */
  50231. checkCollisions: boolean;
  50232. /**
  50233. * Defines the collision radius of the camera.
  50234. * This simulates a sphere around the camera.
  50235. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50236. */
  50237. collisionRadius: Vector3;
  50238. protected _collider: Collider;
  50239. protected _previousPosition: Vector3;
  50240. protected _collisionVelocity: Vector3;
  50241. protected _newPosition: Vector3;
  50242. protected _previousAlpha: number;
  50243. protected _previousBeta: number;
  50244. protected _previousRadius: number;
  50245. protected _collisionTriggered: boolean;
  50246. protected _targetBoundingCenter: Nullable<Vector3>;
  50247. private _computationVector;
  50248. /**
  50249. * Instantiates a new ArcRotateCamera in a given scene
  50250. * @param name Defines the name of the camera
  50251. * @param alpha Defines the camera rotation along the longitudinal axis
  50252. * @param beta Defines the camera rotation along the latitudinal axis
  50253. * @param radius Defines the camera distance from its target
  50254. * @param target Defines the camera target
  50255. * @param scene Defines the scene the camera belongs to
  50256. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active if not other active cameras have been defined
  50257. */
  50258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50259. /** @hidden */
  50260. _initCache(): void;
  50261. /** @hidden */
  50262. _updateCache(ignoreParentClass?: boolean): void;
  50263. protected _getTargetPosition(): Vector3;
  50264. private _storedAlpha;
  50265. private _storedBeta;
  50266. private _storedRadius;
  50267. private _storedTarget;
  50268. private _storedTargetScreenOffset;
  50269. /**
  50270. * Stores the current state of the camera (alpha, beta, radius and target)
  50271. * @returns the camera itself
  50272. */
  50273. storeState(): Camera;
  50274. /**
  50275. * @hidden
  50276. * Restored camera state. You must call storeState() first
  50277. */
  50278. _restoreStateValues(): boolean;
  50279. /** @hidden */
  50280. _isSynchronizedViewMatrix(): boolean;
  50281. /**
  50282. * Attach the input controls to a specific dom element to get the input from.
  50283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50284. */
  50285. attachControl(noPreventDefault?: boolean): void;
  50286. /**
  50287. * Attach the input controls to a specific dom element to get the input from.
  50288. * @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
  50289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50290. */
  50291. attachControl(ignored: any, noPreventDefault?: boolean): void;
  50292. /**
  50293. * Attached controls to the current camera.
  50294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50295. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50296. */
  50297. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50298. /**
  50299. * Attached controls to the current camera.
  50300. * @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
  50301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50302. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50303. */
  50304. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  50305. /**
  50306. * Attached controls to the current camera.
  50307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50308. * @param useCtrlForPanning Defines whether ctrl is used for panning within the controls
  50309. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  50310. */
  50311. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  50312. /**
  50313. * Detach the current controls from the specified dom element.
  50314. */
  50315. detachControl(): void;
  50316. /**
  50317. * Detach the current controls from the specified dom element.
  50318. * @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
  50319. */
  50320. detachControl(ignored: any): void;
  50321. /** @hidden */
  50322. _checkInputs(): void;
  50323. protected _checkLimits(): void;
  50324. /**
  50325. * Rebuilds angles (alpha, beta) and radius from the give position and target
  50326. */
  50327. rebuildAnglesAndRadius(): void;
  50328. /**
  50329. * Use a position to define the current camera related information like alpha, beta and radius
  50330. * @param position Defines the position to set the camera at
  50331. */
  50332. setPosition(position: Vector3): void;
  50333. /**
  50334. * Defines the target the camera should look at.
  50335. * This will automatically adapt alpha beta and radius to fit within the new target.
  50336. * @param target Defines the new target as a Vector or a mesh
  50337. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  50338. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  50339. */
  50340. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  50341. /** @hidden */
  50342. _getViewMatrix(): Matrix;
  50343. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  50344. /**
  50345. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  50346. * @param meshes Defines the mesh to zoom on
  50347. * @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)
  50348. */
  50349. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  50350. /**
  50351. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  50352. * The target will be changed but the radius
  50353. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  50354. * @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)
  50355. */
  50356. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  50357. min: Vector3;
  50358. max: Vector3;
  50359. distance: number;
  50360. }, doNotUpdateMaxZ?: boolean): void;
  50361. /**
  50362. * @override
  50363. * Override Camera.createRigCamera
  50364. */
  50365. createRigCamera(name: string, cameraIndex: number): Camera;
  50366. /**
  50367. * @hidden
  50368. * @override
  50369. * Override Camera._updateRigCameras
  50370. */
  50371. _updateRigCameras(): void;
  50372. /**
  50373. * Destroy the camera and release the current resources hold by it.
  50374. */
  50375. dispose(): void;
  50376. /**
  50377. * Gets the current object class name.
  50378. * @return the class name
  50379. */
  50380. getClassName(): string;
  50381. }
  50382. }
  50383. declare module BABYLON {
  50384. /**
  50385. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  50386. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  50387. */
  50388. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  50389. /**
  50390. * Gets the name of the behavior.
  50391. */
  50392. get name(): string;
  50393. private _zoomStopsAnimation;
  50394. private _idleRotationSpeed;
  50395. private _idleRotationWaitTime;
  50396. private _idleRotationSpinupTime;
  50397. /**
  50398. * Sets the flag that indicates if user zooming should stop animation.
  50399. */
  50400. set zoomStopsAnimation(flag: boolean);
  50401. /**
  50402. * Gets the flag that indicates if user zooming should stop animation.
  50403. */
  50404. get zoomStopsAnimation(): boolean;
  50405. /**
  50406. * Sets the default speed at which the camera rotates around the model.
  50407. */
  50408. set idleRotationSpeed(speed: number);
  50409. /**
  50410. * Gets the default speed at which the camera rotates around the model.
  50411. */
  50412. get idleRotationSpeed(): number;
  50413. /**
  50414. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  50415. */
  50416. set idleRotationWaitTime(time: number);
  50417. /**
  50418. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  50419. */
  50420. get idleRotationWaitTime(): number;
  50421. /**
  50422. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50423. */
  50424. set idleRotationSpinupTime(time: number);
  50425. /**
  50426. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  50427. */
  50428. get idleRotationSpinupTime(): number;
  50429. /**
  50430. * Gets a value indicating if the camera is currently rotating because of this behavior
  50431. */
  50432. get rotationInProgress(): boolean;
  50433. private _onPrePointerObservableObserver;
  50434. private _onAfterCheckInputsObserver;
  50435. private _attachedCamera;
  50436. private _isPointerDown;
  50437. private _lastFrameTime;
  50438. private _lastInteractionTime;
  50439. private _cameraRotationSpeed;
  50440. /**
  50441. * Initializes the behavior.
  50442. */
  50443. init(): void;
  50444. /**
  50445. * Attaches the behavior to its arc rotate camera.
  50446. * @param camera Defines the camera to attach the behavior to
  50447. */
  50448. attach(camera: ArcRotateCamera): void;
  50449. /**
  50450. * Detaches the behavior from its current arc rotate camera.
  50451. */
  50452. detach(): void;
  50453. /**
  50454. * Returns true if user is scrolling.
  50455. * @return true if user is scrolling.
  50456. */
  50457. private _userIsZooming;
  50458. private _lastFrameRadius;
  50459. private _shouldAnimationStopForInteraction;
  50460. /**
  50461. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  50462. */
  50463. private _applyUserInteraction;
  50464. private _userIsMoving;
  50465. }
  50466. }
  50467. declare module BABYLON {
  50468. /**
  50469. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  50470. */
  50471. export class AttachToBoxBehavior implements Behavior<Mesh> {
  50472. private ui;
  50473. /**
  50474. * The name of the behavior
  50475. */
  50476. name: string;
  50477. /**
  50478. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  50479. */
  50480. distanceAwayFromFace: number;
  50481. /**
  50482. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  50483. */
  50484. distanceAwayFromBottomOfFace: number;
  50485. private _faceVectors;
  50486. private _target;
  50487. private _scene;
  50488. private _onRenderObserver;
  50489. private _tmpMatrix;
  50490. private _tmpVector;
  50491. /**
  50492. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  50493. * @param ui The transform node that should be attached to the mesh
  50494. */
  50495. constructor(ui: TransformNode);
  50496. /**
  50497. * Initializes the behavior
  50498. */
  50499. init(): void;
  50500. private _closestFace;
  50501. private _zeroVector;
  50502. private _lookAtTmpMatrix;
  50503. private _lookAtToRef;
  50504. /**
  50505. * Attaches the AttachToBoxBehavior to the passed in mesh
  50506. * @param target The mesh that the specified node will be attached to
  50507. */
  50508. attach(target: Mesh): void;
  50509. /**
  50510. * Detaches the behavior from the mesh
  50511. */
  50512. detach(): void;
  50513. }
  50514. }
  50515. declare module BABYLON {
  50516. /**
  50517. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  50518. */
  50519. export class FadeInOutBehavior implements Behavior<Mesh> {
  50520. /**
  50521. * Time in milliseconds to delay before fading in (Default: 0)
  50522. */
  50523. delay: number;
  50524. /**
  50525. * Time in milliseconds for the mesh to fade in (Default: 300)
  50526. */
  50527. fadeInTime: number;
  50528. private _millisecondsPerFrame;
  50529. private _hovered;
  50530. private _hoverValue;
  50531. private _ownerNode;
  50532. /**
  50533. * Instantiates the FadeInOutBehavior
  50534. */
  50535. constructor();
  50536. /**
  50537. * The name of the behavior
  50538. */
  50539. get name(): string;
  50540. /**
  50541. * Initializes the behavior
  50542. */
  50543. init(): void;
  50544. /**
  50545. * Attaches the fade behavior on the passed in mesh
  50546. * @param ownerNode The mesh that will be faded in/out once attached
  50547. */
  50548. attach(ownerNode: Mesh): void;
  50549. /**
  50550. * Detaches the behavior from the mesh
  50551. */
  50552. detach(): void;
  50553. /**
  50554. * Triggers the mesh to begin fading in or out
  50555. * @param value if the object should fade in or out (true to fade in)
  50556. */
  50557. fadeIn(value: boolean): void;
  50558. private _update;
  50559. private _setAllVisibility;
  50560. }
  50561. }
  50562. declare module BABYLON {
  50563. /**
  50564. * Class containing a set of static utilities functions for managing Pivots
  50565. * @hidden
  50566. */
  50567. export class PivotTools {
  50568. private static _PivotCached;
  50569. private static _OldPivotPoint;
  50570. private static _PivotTranslation;
  50571. private static _PivotTmpVector;
  50572. private static _PivotPostMultiplyPivotMatrix;
  50573. /** @hidden */
  50574. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  50575. /** @hidden */
  50576. static _RestorePivotPoint(mesh: AbstractMesh): void;
  50577. }
  50578. }
  50579. declare module BABYLON {
  50580. /**
  50581. * Class containing static functions to help procedurally build meshes
  50582. */
  50583. export class PlaneBuilder {
  50584. /**
  50585. * Creates a plane mesh
  50586. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50587. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50588. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50590. * * 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
  50591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50592. * @param name defines the name of the mesh
  50593. * @param options defines the options used to create the mesh
  50594. * @param scene defines the hosting scene
  50595. * @returns the plane mesh
  50596. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50597. */
  50598. static CreatePlane(name: string, options: {
  50599. size?: number;
  50600. width?: number;
  50601. height?: number;
  50602. sideOrientation?: number;
  50603. frontUVs?: Vector4;
  50604. backUVs?: Vector4;
  50605. updatable?: boolean;
  50606. sourcePlane?: Plane;
  50607. }, scene?: Nullable<Scene>): Mesh;
  50608. }
  50609. }
  50610. declare module BABYLON {
  50611. /**
  50612. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  50613. */
  50614. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  50615. private static _AnyMouseID;
  50616. /**
  50617. * Abstract mesh the behavior is set on
  50618. */
  50619. attachedNode: AbstractMesh;
  50620. private _dragPlane;
  50621. private _scene;
  50622. private _pointerObserver;
  50623. private _beforeRenderObserver;
  50624. private static _planeScene;
  50625. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  50626. /**
  50627. * 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)
  50628. */
  50629. maxDragAngle: number;
  50630. /**
  50631. * @hidden
  50632. */
  50633. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  50634. /**
  50635. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50636. */
  50637. currentDraggingPointerID: number;
  50638. /**
  50639. * The last position where the pointer hit the drag plane in world space
  50640. */
  50641. lastDragPosition: Vector3;
  50642. /**
  50643. * If the behavior is currently in a dragging state
  50644. */
  50645. dragging: boolean;
  50646. /**
  50647. * 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)
  50648. */
  50649. dragDeltaRatio: number;
  50650. /**
  50651. * If the drag plane orientation should be updated during the dragging (Default: true)
  50652. */
  50653. updateDragPlane: boolean;
  50654. private _debugMode;
  50655. private _moving;
  50656. /**
  50657. * Fires each time the attached mesh is dragged with the pointer
  50658. * * delta between last drag position and current drag position in world space
  50659. * * dragDistance along the drag axis
  50660. * * dragPlaneNormal normal of the current drag plane used during the drag
  50661. * * dragPlanePoint in world space where the drag intersects the drag plane
  50662. */
  50663. onDragObservable: Observable<{
  50664. delta: Vector3;
  50665. dragPlanePoint: Vector3;
  50666. dragPlaneNormal: Vector3;
  50667. dragDistance: number;
  50668. pointerId: number;
  50669. }>;
  50670. /**
  50671. * Fires each time a drag begins (eg. mouse down on mesh)
  50672. */
  50673. onDragStartObservable: Observable<{
  50674. dragPlanePoint: Vector3;
  50675. pointerId: number;
  50676. }>;
  50677. /**
  50678. * Fires each time a drag ends (eg. mouse release after drag)
  50679. */
  50680. onDragEndObservable: Observable<{
  50681. dragPlanePoint: Vector3;
  50682. pointerId: number;
  50683. }>;
  50684. /**
  50685. * If the attached mesh should be moved when dragged
  50686. */
  50687. moveAttached: boolean;
  50688. /**
  50689. * If the drag behavior will react to drag events (Default: true)
  50690. */
  50691. enabled: boolean;
  50692. /**
  50693. * If pointer events should start and release the drag (Default: true)
  50694. */
  50695. startAndReleaseDragOnPointerEvents: boolean;
  50696. /**
  50697. * If camera controls should be detached during the drag
  50698. */
  50699. detachCameraControls: boolean;
  50700. /**
  50701. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50702. */
  50703. useObjectOrientationForDragging: boolean;
  50704. private _options;
  50705. /**
  50706. * Gets the options used by the behavior
  50707. */
  50708. get options(): {
  50709. dragAxis?: Vector3;
  50710. dragPlaneNormal?: Vector3;
  50711. };
  50712. /**
  50713. * Sets the options used by the behavior
  50714. */
  50715. set options(options: {
  50716. dragAxis?: Vector3;
  50717. dragPlaneNormal?: Vector3;
  50718. });
  50719. /**
  50720. * Creates a pointer drag behavior that can be attached to a mesh
  50721. * @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)
  50722. */
  50723. constructor(options?: {
  50724. dragAxis?: Vector3;
  50725. dragPlaneNormal?: Vector3;
  50726. });
  50727. /**
  50728. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50729. */
  50730. validateDrag: (targetPosition: Vector3) => boolean;
  50731. /**
  50732. * The name of the behavior
  50733. */
  50734. get name(): string;
  50735. /**
  50736. * Initializes the behavior
  50737. */
  50738. init(): void;
  50739. private _tmpVector;
  50740. private _alternatePickedPoint;
  50741. private _worldDragAxis;
  50742. private _targetPosition;
  50743. private _attachedToElement;
  50744. /**
  50745. * Attaches the drag behavior the passed in mesh
  50746. * @param ownerNode The mesh that will be dragged around once attached
  50747. * @param predicate Predicate to use for pick filtering
  50748. */
  50749. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50750. /**
  50751. * Force release the drag action by code.
  50752. */
  50753. releaseDrag(): void;
  50754. private _startDragRay;
  50755. private _lastPointerRay;
  50756. /**
  50757. * Simulates the start of a pointer drag event on the behavior
  50758. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50759. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50760. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50761. */
  50762. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50763. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50764. private _dragDelta;
  50765. protected _moveDrag(ray: Ray): void;
  50766. private _pickWithRayOnDragPlane;
  50767. private _pointA;
  50768. private _pointC;
  50769. private _localAxis;
  50770. private _lookAt;
  50771. private _updateDragPlanePosition;
  50772. /**
  50773. * Detaches the behavior from the mesh
  50774. */
  50775. detach(): void;
  50776. }
  50777. }
  50778. declare module BABYLON {
  50779. /**
  50780. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50781. */
  50782. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50783. private _dragBehaviorA;
  50784. private _dragBehaviorB;
  50785. private _startDistance;
  50786. private _initialScale;
  50787. private _targetScale;
  50788. private _ownerNode;
  50789. private _sceneRenderObserver;
  50790. /**
  50791. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50792. */
  50793. constructor();
  50794. /**
  50795. * The name of the behavior
  50796. */
  50797. get name(): string;
  50798. /**
  50799. * Initializes the behavior
  50800. */
  50801. init(): void;
  50802. private _getCurrentDistance;
  50803. /**
  50804. * Attaches the scale behavior the passed in mesh
  50805. * @param ownerNode The mesh that will be scaled around once attached
  50806. */
  50807. attach(ownerNode: Mesh): void;
  50808. /**
  50809. * Detaches the behavior from the mesh
  50810. */
  50811. detach(): void;
  50812. }
  50813. }
  50814. declare module BABYLON {
  50815. /**
  50816. * 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
  50817. */
  50818. export class SixDofDragBehavior implements Behavior<Mesh> {
  50819. private static _virtualScene;
  50820. private _ownerNode;
  50821. private _sceneRenderObserver;
  50822. private _scene;
  50823. private _targetPosition;
  50824. private _virtualOriginMesh;
  50825. private _virtualDragMesh;
  50826. private _pointerObserver;
  50827. private _moving;
  50828. private _startingOrientation;
  50829. private _attachedToElement;
  50830. /**
  50831. * 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)
  50832. */
  50833. private zDragFactor;
  50834. /**
  50835. * If the object should rotate to face the drag origin
  50836. */
  50837. rotateDraggedObject: boolean;
  50838. /**
  50839. * If the behavior is currently in a dragging state
  50840. */
  50841. dragging: boolean;
  50842. /**
  50843. * 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)
  50844. */
  50845. dragDeltaRatio: number;
  50846. /**
  50847. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50848. */
  50849. currentDraggingPointerID: number;
  50850. /**
  50851. * If camera controls should be detached during the drag
  50852. */
  50853. detachCameraControls: boolean;
  50854. /**
  50855. * Fires each time a drag starts
  50856. */
  50857. onDragStartObservable: Observable<{}>;
  50858. /**
  50859. * Fires each time a drag happens
  50860. */
  50861. onDragObservable: Observable<void>;
  50862. /**
  50863. * Fires each time a drag ends (eg. mouse release after drag)
  50864. */
  50865. onDragEndObservable: Observable<{}>;
  50866. /**
  50867. * 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
  50868. */
  50869. constructor();
  50870. /**
  50871. * The name of the behavior
  50872. */
  50873. get name(): string;
  50874. /**
  50875. * Initializes the behavior
  50876. */
  50877. init(): void;
  50878. /**
  50879. * In the case of multiple active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50880. */
  50881. private get _pointerCamera();
  50882. /**
  50883. * Attaches the scale behavior the passed in mesh
  50884. * @param ownerNode The mesh that will be scaled around once attached
  50885. */
  50886. attach(ownerNode: Mesh): void;
  50887. /**
  50888. * Detaches the behavior from the mesh
  50889. */
  50890. detach(): void;
  50891. }
  50892. }
  50893. declare module BABYLON {
  50894. /**
  50895. * Class used to apply inverse kinematics to bones
  50896. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50897. */
  50898. export class BoneIKController {
  50899. private static _tmpVecs;
  50900. private static _tmpQuat;
  50901. private static _tmpMats;
  50902. /**
  50903. * Gets or sets the target mesh
  50904. */
  50905. targetMesh: AbstractMesh;
  50906. /** Gets or sets the mesh used as pole */
  50907. poleTargetMesh: AbstractMesh;
  50908. /**
  50909. * Gets or sets the bone used as pole
  50910. */
  50911. poleTargetBone: Nullable<Bone>;
  50912. /**
  50913. * Gets or sets the target position
  50914. */
  50915. targetPosition: Vector3;
  50916. /**
  50917. * Gets or sets the pole target position
  50918. */
  50919. poleTargetPosition: Vector3;
  50920. /**
  50921. * Gets or sets the pole target local offset
  50922. */
  50923. poleTargetLocalOffset: Vector3;
  50924. /**
  50925. * Gets or sets the pole angle
  50926. */
  50927. poleAngle: number;
  50928. /**
  50929. * Gets or sets the mesh associated with the controller
  50930. */
  50931. mesh: AbstractMesh;
  50932. /**
  50933. * 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)
  50934. */
  50935. slerpAmount: number;
  50936. private _bone1Quat;
  50937. private _bone1Mat;
  50938. private _bone2Ang;
  50939. private _bone1;
  50940. private _bone2;
  50941. private _bone1Length;
  50942. private _bone2Length;
  50943. private _maxAngle;
  50944. private _maxReach;
  50945. private _rightHandedSystem;
  50946. private _bendAxis;
  50947. private _slerping;
  50948. private _adjustRoll;
  50949. /**
  50950. * Gets or sets maximum allowed angle
  50951. */
  50952. get maxAngle(): number;
  50953. set maxAngle(value: number);
  50954. /**
  50955. * Creates a new BoneIKController
  50956. * @param mesh defines the mesh to control
  50957. * @param bone defines the bone to control
  50958. * @param options defines options to set up the controller
  50959. */
  50960. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50961. targetMesh?: AbstractMesh;
  50962. poleTargetMesh?: AbstractMesh;
  50963. poleTargetBone?: Bone;
  50964. poleTargetLocalOffset?: Vector3;
  50965. poleAngle?: number;
  50966. bendAxis?: Vector3;
  50967. maxAngle?: number;
  50968. slerpAmount?: number;
  50969. });
  50970. private _setMaxAngle;
  50971. /**
  50972. * Force the controller to update the bones
  50973. */
  50974. update(): void;
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. /**
  50979. * Class used to make a bone look toward a point in space
  50980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50981. */
  50982. export class BoneLookController {
  50983. private static _tmpVecs;
  50984. private static _tmpQuat;
  50985. private static _tmpMats;
  50986. /**
  50987. * The target Vector3 that the bone will look at
  50988. */
  50989. target: Vector3;
  50990. /**
  50991. * The mesh that the bone is attached to
  50992. */
  50993. mesh: AbstractMesh;
  50994. /**
  50995. * The bone that will be looking to the target
  50996. */
  50997. bone: Bone;
  50998. /**
  50999. * The up axis of the coordinate system that is used when the bone is rotated
  51000. */
  51001. upAxis: Vector3;
  51002. /**
  51003. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  51004. */
  51005. upAxisSpace: Space;
  51006. /**
  51007. * Used to make an adjustment to the yaw of the bone
  51008. */
  51009. adjustYaw: number;
  51010. /**
  51011. * Used to make an adjustment to the pitch of the bone
  51012. */
  51013. adjustPitch: number;
  51014. /**
  51015. * Used to make an adjustment to the roll of the bone
  51016. */
  51017. adjustRoll: number;
  51018. /**
  51019. * 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)
  51020. */
  51021. slerpAmount: number;
  51022. private _minYaw;
  51023. private _maxYaw;
  51024. private _minPitch;
  51025. private _maxPitch;
  51026. private _minYawSin;
  51027. private _minYawCos;
  51028. private _maxYawSin;
  51029. private _maxYawCos;
  51030. private _midYawConstraint;
  51031. private _minPitchTan;
  51032. private _maxPitchTan;
  51033. private _boneQuat;
  51034. private _slerping;
  51035. private _transformYawPitch;
  51036. private _transformYawPitchInv;
  51037. private _firstFrameSkipped;
  51038. private _yawRange;
  51039. private _fowardAxis;
  51040. /**
  51041. * Gets or sets the minimum yaw angle that the bone can look to
  51042. */
  51043. get minYaw(): number;
  51044. set minYaw(value: number);
  51045. /**
  51046. * Gets or sets the maximum yaw angle that the bone can look to
  51047. */
  51048. get maxYaw(): number;
  51049. set maxYaw(value: number);
  51050. /**
  51051. * Gets or sets the minimum pitch angle that the bone can look to
  51052. */
  51053. get minPitch(): number;
  51054. set minPitch(value: number);
  51055. /**
  51056. * Gets or sets the maximum pitch angle that the bone can look to
  51057. */
  51058. get maxPitch(): number;
  51059. set maxPitch(value: number);
  51060. /**
  51061. * Create a BoneLookController
  51062. * @param mesh the mesh that the bone belongs to
  51063. * @param bone the bone that will be looking to the target
  51064. * @param target the target Vector3 to look at
  51065. * @param options optional settings:
  51066. * * maxYaw: the maximum angle the bone will yaw to
  51067. * * minYaw: the minimum angle the bone will yaw to
  51068. * * maxPitch: the maximum angle the bone will pitch to
  51069. * * minPitch: the minimum angle the bone will yaw to
  51070. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  51071. * * upAxis: the up axis of the coordinate system
  51072. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  51073. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  51074. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  51075. * * adjustYaw: used to make an adjustment to the yaw of the bone
  51076. * * adjustPitch: used to make an adjustment to the pitch of the bone
  51077. * * adjustRoll: used to make an adjustment to the roll of the bone
  51078. **/
  51079. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  51080. maxYaw?: number;
  51081. minYaw?: number;
  51082. maxPitch?: number;
  51083. minPitch?: number;
  51084. slerpAmount?: number;
  51085. upAxis?: Vector3;
  51086. upAxisSpace?: Space;
  51087. yawAxis?: Vector3;
  51088. pitchAxis?: Vector3;
  51089. adjustYaw?: number;
  51090. adjustPitch?: number;
  51091. adjustRoll?: number;
  51092. });
  51093. /**
  51094. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  51095. */
  51096. update(): void;
  51097. private _getAngleDiff;
  51098. private _getAngleBetween;
  51099. private _isAngleBetween;
  51100. }
  51101. }
  51102. declare module BABYLON {
  51103. /**
  51104. * Manage the gamepad inputs to control an arc rotate camera.
  51105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51106. */
  51107. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  51108. /**
  51109. * Defines the camera the input is attached to.
  51110. */
  51111. camera: ArcRotateCamera;
  51112. /**
  51113. * Defines the gamepad the input is gathering event from.
  51114. */
  51115. gamepad: Nullable<Gamepad>;
  51116. /**
  51117. * Defines the gamepad rotation sensiblity.
  51118. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51119. */
  51120. gamepadRotationSensibility: number;
  51121. /**
  51122. * Defines the gamepad move sensiblity.
  51123. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51124. */
  51125. gamepadMoveSensibility: number;
  51126. private _yAxisScale;
  51127. /**
  51128. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51129. */
  51130. get invertYAxis(): boolean;
  51131. set invertYAxis(value: boolean);
  51132. private _onGamepadConnectedObserver;
  51133. private _onGamepadDisconnectedObserver;
  51134. /**
  51135. * Attach the input controls to a specific dom element to get the input from.
  51136. */
  51137. attachControl(): void;
  51138. /**
  51139. * Detach the current controls from the specified dom element.
  51140. */
  51141. detachControl(): void;
  51142. /**
  51143. * Update the current camera state depending on the inputs that have been used this frame.
  51144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51145. */
  51146. checkInputs(): void;
  51147. /**
  51148. * Gets the class name of the current intput.
  51149. * @returns the class name
  51150. */
  51151. getClassName(): string;
  51152. /**
  51153. * Get the friendly name associated with the input class.
  51154. * @returns the input friendly name
  51155. */
  51156. getSimpleName(): string;
  51157. }
  51158. }
  51159. declare module BABYLON {
  51160. interface ArcRotateCameraInputsManager {
  51161. /**
  51162. * Add orientation input support to the input manager.
  51163. * @returns the current input manager
  51164. */
  51165. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  51166. }
  51167. /**
  51168. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  51169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51170. */
  51171. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  51172. /**
  51173. * Defines the camera the input is attached to.
  51174. */
  51175. camera: ArcRotateCamera;
  51176. /**
  51177. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  51178. */
  51179. alphaCorrection: number;
  51180. /**
  51181. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  51182. */
  51183. gammaCorrection: number;
  51184. private _alpha;
  51185. private _gamma;
  51186. private _dirty;
  51187. private _deviceOrientationHandler;
  51188. /**
  51189. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  51190. */
  51191. constructor();
  51192. /**
  51193. * Attach the input controls to a specific dom element to get the input from.
  51194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51195. */
  51196. attachControl(noPreventDefault?: boolean): void;
  51197. /** @hidden */
  51198. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  51199. /**
  51200. * Update the current camera state depending on the inputs that have been used this frame.
  51201. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51202. */
  51203. checkInputs(): void;
  51204. /**
  51205. * Detach the current controls from the specified dom element.
  51206. */
  51207. detachControl(): void;
  51208. /**
  51209. * Gets the class name of the current input.
  51210. * @returns the class name
  51211. */
  51212. getClassName(): string;
  51213. /**
  51214. * Get the friendly name associated with the input class.
  51215. * @returns the input friendly name
  51216. */
  51217. getSimpleName(): string;
  51218. }
  51219. }
  51220. declare module BABYLON {
  51221. /**
  51222. * Listen to mouse events to control the camera.
  51223. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51224. */
  51225. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  51226. /**
  51227. * Defines the camera the input is attached to.
  51228. */
  51229. camera: FlyCamera;
  51230. /**
  51231. * Defines if touch is enabled. (Default is true.)
  51232. */
  51233. touchEnabled: boolean;
  51234. /**
  51235. * Defines the buttons associated with the input to handle camera rotation.
  51236. */
  51237. buttons: number[];
  51238. /**
  51239. * Assign buttons for Yaw control.
  51240. */
  51241. buttonsYaw: number[];
  51242. /**
  51243. * Assign buttons for Pitch control.
  51244. */
  51245. buttonsPitch: number[];
  51246. /**
  51247. * Assign buttons for Roll control.
  51248. */
  51249. buttonsRoll: number[];
  51250. /**
  51251. * Detect if any button is being pressed while mouse is moved.
  51252. * -1 = Mouse locked.
  51253. * 0 = Left button.
  51254. * 1 = Middle Button.
  51255. * 2 = Right Button.
  51256. */
  51257. activeButton: number;
  51258. /**
  51259. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  51260. * Higher values reduce its sensitivity.
  51261. */
  51262. angularSensibility: number;
  51263. private _observer;
  51264. private _rollObserver;
  51265. private previousPosition;
  51266. private noPreventDefault;
  51267. private element;
  51268. /**
  51269. * Listen to mouse events to control the camera.
  51270. * @param touchEnabled Define if touch is enabled. (Default is true.)
  51271. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51272. */
  51273. constructor(touchEnabled?: boolean);
  51274. /**
  51275. * Attach the mouse control to the HTML DOM element.
  51276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  51277. */
  51278. attachControl(noPreventDefault?: boolean): void;
  51279. /**
  51280. * Detach the current controls from the specified dom element.
  51281. */
  51282. detachControl(): void;
  51283. /**
  51284. * Gets the class name of the current input.
  51285. * @returns the class name.
  51286. */
  51287. getClassName(): string;
  51288. /**
  51289. * Get the friendly name associated with the input class.
  51290. * @returns the input's friendly name.
  51291. */
  51292. getSimpleName(): string;
  51293. private _pointerInput;
  51294. private _onMouseMove;
  51295. /**
  51296. * Rotate camera by mouse offset.
  51297. */
  51298. private rotateCamera;
  51299. }
  51300. }
  51301. declare module BABYLON {
  51302. /**
  51303. * Default Inputs manager for the FlyCamera.
  51304. * It groups all the default supported inputs for ease of use.
  51305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51306. */
  51307. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  51308. /**
  51309. * Instantiates a new FlyCameraInputsManager.
  51310. * @param camera Defines the camera the inputs belong to.
  51311. */
  51312. constructor(camera: FlyCamera);
  51313. /**
  51314. * Add keyboard input support to the input manager.
  51315. * @returns the new FlyCameraKeyboardMoveInput().
  51316. */
  51317. addKeyboard(): FlyCameraInputsManager;
  51318. /**
  51319. * Add mouse input support to the input manager.
  51320. * @param touchEnabled Enable touch screen support.
  51321. * @returns the new FlyCameraMouseInput().
  51322. */
  51323. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  51324. }
  51325. }
  51326. declare module BABYLON {
  51327. /**
  51328. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51329. * such as in a 3D Space Shooter or a Flight Simulator.
  51330. */
  51331. export class FlyCamera extends TargetCamera {
  51332. /**
  51333. * Define the collision ellipsoid of the camera.
  51334. * This is helpful for simulating a camera body, like a player's body.
  51335. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  51336. */
  51337. ellipsoid: Vector3;
  51338. /**
  51339. * Define an offset for the position of the ellipsoid around the camera.
  51340. * This can be helpful if the camera is attached away from the player's body center,
  51341. * such as at its head.
  51342. */
  51343. ellipsoidOffset: Vector3;
  51344. /**
  51345. * Enable or disable collisions of the camera with the rest of the scene objects.
  51346. */
  51347. checkCollisions: boolean;
  51348. /**
  51349. * Enable or disable gravity on the camera.
  51350. */
  51351. applyGravity: boolean;
  51352. /**
  51353. * Define the current direction the camera is moving to.
  51354. */
  51355. cameraDirection: Vector3;
  51356. /**
  51357. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  51358. * This overrides and empties cameraRotation.
  51359. */
  51360. rotationQuaternion: Quaternion;
  51361. /**
  51362. * Track Roll to maintain the wanted Rolling when looking around.
  51363. */
  51364. _trackRoll: number;
  51365. /**
  51366. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  51367. */
  51368. rollCorrect: number;
  51369. /**
  51370. * Mimic a banked turn, Rolling the camera when Yawing.
  51371. * It's recommended to use rollCorrect = 10 for faster banking correction.
  51372. */
  51373. bankedTurn: boolean;
  51374. /**
  51375. * Limit in radians for how much Roll banking will add. (Default: 90°)
  51376. */
  51377. bankedTurnLimit: number;
  51378. /**
  51379. * Value of 0 disables the banked Roll.
  51380. * Value of 1 is equal to the Yaw angle in radians.
  51381. */
  51382. bankedTurnMultiplier: number;
  51383. /**
  51384. * The inputs manager loads all the input sources, such as keyboard and mouse.
  51385. */
  51386. inputs: FlyCameraInputsManager;
  51387. /**
  51388. * Gets the input sensibility for mouse input.
  51389. * Higher values reduce sensitivity.
  51390. */
  51391. get angularSensibility(): number;
  51392. /**
  51393. * Sets the input sensibility for a mouse input.
  51394. * Higher values reduce sensitivity.
  51395. */
  51396. set angularSensibility(value: number);
  51397. /**
  51398. * Get the keys for camera movement forward.
  51399. */
  51400. get keysForward(): number[];
  51401. /**
  51402. * Set the keys for camera movement forward.
  51403. */
  51404. set keysForward(value: number[]);
  51405. /**
  51406. * Get the keys for camera movement backward.
  51407. */
  51408. get keysBackward(): number[];
  51409. set keysBackward(value: number[]);
  51410. /**
  51411. * Get the keys for camera movement up.
  51412. */
  51413. get keysUp(): number[];
  51414. /**
  51415. * Set the keys for camera movement up.
  51416. */
  51417. set keysUp(value: number[]);
  51418. /**
  51419. * Get the keys for camera movement down.
  51420. */
  51421. get keysDown(): number[];
  51422. /**
  51423. * Set the keys for camera movement down.
  51424. */
  51425. set keysDown(value: number[]);
  51426. /**
  51427. * Get the keys for camera movement left.
  51428. */
  51429. get keysLeft(): number[];
  51430. /**
  51431. * Set the keys for camera movement left.
  51432. */
  51433. set keysLeft(value: number[]);
  51434. /**
  51435. * Set the keys for camera movement right.
  51436. */
  51437. get keysRight(): number[];
  51438. /**
  51439. * Set the keys for camera movement right.
  51440. */
  51441. set keysRight(value: number[]);
  51442. /**
  51443. * Event raised when the camera collides with a mesh in the scene.
  51444. */
  51445. onCollide: (collidedMesh: AbstractMesh) => void;
  51446. private _collider;
  51447. private _needMoveForGravity;
  51448. private _oldPosition;
  51449. private _diffPosition;
  51450. private _newPosition;
  51451. /** @hidden */
  51452. _localDirection: Vector3;
  51453. /** @hidden */
  51454. _transformedDirection: Vector3;
  51455. /**
  51456. * Instantiates a FlyCamera.
  51457. * This is a flying camera, designed for 3D movement and rotation in all directions,
  51458. * such as in a 3D Space Shooter or a Flight Simulator.
  51459. * @param name Define the name of the camera in the scene.
  51460. * @param position Define the starting position of the camera in the scene.
  51461. * @param scene Define the scene the camera belongs to.
  51462. * @param setActiveOnSceneIfNoneActive Defines whether the camera should be marked as active, if no other camera has been defined as active.
  51463. */
  51464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  51465. /**
  51466. * Attach the input controls to a specific dom element to get the input from.
  51467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51468. */
  51469. attachControl(noPreventDefault?: boolean): void;
  51470. /**
  51471. * Detach a control from the HTML DOM element.
  51472. * The camera will stop reacting to that input.
  51473. */
  51474. detachControl(): void;
  51475. private _collisionMask;
  51476. /**
  51477. * Get the mask that the camera ignores in collision events.
  51478. */
  51479. get collisionMask(): number;
  51480. /**
  51481. * Set the mask that the camera ignores in collision events.
  51482. */
  51483. set collisionMask(mask: number);
  51484. /** @hidden */
  51485. _collideWithWorld(displacement: Vector3): void;
  51486. /** @hidden */
  51487. private _onCollisionPositionChange;
  51488. /** @hidden */
  51489. _checkInputs(): void;
  51490. /** @hidden */
  51491. _decideIfNeedsToMove(): boolean;
  51492. /** @hidden */
  51493. _updatePosition(): void;
  51494. /**
  51495. * Restore the Roll to its target value at the rate specified.
  51496. * @param rate - Higher means slower restoring.
  51497. * @hidden
  51498. */
  51499. restoreRoll(rate: number): void;
  51500. /**
  51501. * Destroy the camera and release the current resources held by it.
  51502. */
  51503. dispose(): void;
  51504. /**
  51505. * Get the current object class name.
  51506. * @returns the class name.
  51507. */
  51508. getClassName(): string;
  51509. }
  51510. }
  51511. declare module BABYLON {
  51512. /**
  51513. * Listen to keyboard events to control the camera.
  51514. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51515. */
  51516. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  51517. /**
  51518. * Defines the camera the input is attached to.
  51519. */
  51520. camera: FlyCamera;
  51521. /**
  51522. * The list of keyboard keys used to control the forward move of the camera.
  51523. */
  51524. keysForward: number[];
  51525. /**
  51526. * The list of keyboard keys used to control the backward move of the camera.
  51527. */
  51528. keysBackward: number[];
  51529. /**
  51530. * The list of keyboard keys used to control the forward move of the camera.
  51531. */
  51532. keysUp: number[];
  51533. /**
  51534. * The list of keyboard keys used to control the backward move of the camera.
  51535. */
  51536. keysDown: number[];
  51537. /**
  51538. * The list of keyboard keys used to control the right strafe move of the camera.
  51539. */
  51540. keysRight: number[];
  51541. /**
  51542. * The list of keyboard keys used to control the left strafe move of the camera.
  51543. */
  51544. keysLeft: number[];
  51545. private _keys;
  51546. private _onCanvasBlurObserver;
  51547. private _onKeyboardObserver;
  51548. private _engine;
  51549. private _scene;
  51550. /**
  51551. * Attach the input controls to a specific dom element to get the input from.
  51552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51553. */
  51554. attachControl(noPreventDefault?: boolean): void;
  51555. /**
  51556. * Detach the current controls from the specified dom element.
  51557. */
  51558. detachControl(): void;
  51559. /**
  51560. * Gets the class name of the current intput.
  51561. * @returns the class name
  51562. */
  51563. getClassName(): string;
  51564. /** @hidden */
  51565. _onLostFocus(e: FocusEvent): void;
  51566. /**
  51567. * Get the friendly name associated with the input class.
  51568. * @returns the input friendly name
  51569. */
  51570. getSimpleName(): string;
  51571. /**
  51572. * Update the current camera state depending on the inputs that have been used this frame.
  51573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51574. */
  51575. checkInputs(): void;
  51576. }
  51577. }
  51578. declare module BABYLON {
  51579. /**
  51580. * Manage the mouse wheel inputs to control a follow camera.
  51581. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51582. */
  51583. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  51584. /**
  51585. * Defines the camera the input is attached to.
  51586. */
  51587. camera: FollowCamera;
  51588. /**
  51589. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  51590. */
  51591. axisControlRadius: boolean;
  51592. /**
  51593. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  51594. */
  51595. axisControlHeight: boolean;
  51596. /**
  51597. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  51598. */
  51599. axisControlRotation: boolean;
  51600. /**
  51601. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  51602. * relation to mouseWheel events.
  51603. */
  51604. wheelPrecision: number;
  51605. /**
  51606. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  51607. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  51608. */
  51609. wheelDeltaPercentage: number;
  51610. private _wheel;
  51611. private _observer;
  51612. /**
  51613. * Attach the input controls to a specific dom element to get the input from.
  51614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51615. */
  51616. attachControl(noPreventDefault?: boolean): void;
  51617. /**
  51618. * Detach the current controls from the specified dom element.
  51619. */
  51620. detachControl(): void;
  51621. /**
  51622. * Gets the class name of the current input.
  51623. * @returns the class name
  51624. */
  51625. getClassName(): string;
  51626. /**
  51627. * Get the friendly name associated with the input class.
  51628. * @returns the input friendly name
  51629. */
  51630. getSimpleName(): string;
  51631. }
  51632. }
  51633. declare module BABYLON {
  51634. /**
  51635. * Manage the pointers inputs to control an follow camera.
  51636. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51637. */
  51638. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  51639. /**
  51640. * Defines the camera the input is attached to.
  51641. */
  51642. camera: FollowCamera;
  51643. /**
  51644. * Gets the class name of the current input.
  51645. * @returns the class name
  51646. */
  51647. getClassName(): string;
  51648. /**
  51649. * Defines the pointer angular sensibility along the X axis or how fast is
  51650. * the camera rotating.
  51651. * A negative number will reverse the axis direction.
  51652. */
  51653. angularSensibilityX: number;
  51654. /**
  51655. * Defines the pointer angular sensibility along the Y axis or how fast is
  51656. * the camera rotating.
  51657. * A negative number will reverse the axis direction.
  51658. */
  51659. angularSensibilityY: number;
  51660. /**
  51661. * Defines the pointer pinch precision or how fast is the camera zooming.
  51662. * A negative number will reverse the axis direction.
  51663. */
  51664. pinchPrecision: number;
  51665. /**
  51666. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  51667. * from 0.
  51668. * It defines the percentage of current camera.radius to use as delta when
  51669. * pinch zoom is used.
  51670. */
  51671. pinchDeltaPercentage: number;
  51672. /**
  51673. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51674. */
  51675. axisXControlRadius: boolean;
  51676. /**
  51677. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51678. */
  51679. axisXControlHeight: boolean;
  51680. /**
  51681. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51682. */
  51683. axisXControlRotation: boolean;
  51684. /**
  51685. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51686. */
  51687. axisYControlRadius: boolean;
  51688. /**
  51689. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51690. */
  51691. axisYControlHeight: boolean;
  51692. /**
  51693. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51694. */
  51695. axisYControlRotation: boolean;
  51696. /**
  51697. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51698. */
  51699. axisPinchControlRadius: boolean;
  51700. /**
  51701. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51702. */
  51703. axisPinchControlHeight: boolean;
  51704. /**
  51705. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51706. */
  51707. axisPinchControlRotation: boolean;
  51708. /**
  51709. * Log error messages if basic misconfiguration has occurred.
  51710. */
  51711. warningEnable: boolean;
  51712. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51713. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51714. private _warningCounter;
  51715. private _warning;
  51716. }
  51717. }
  51718. declare module BABYLON {
  51719. /**
  51720. * Default Inputs manager for the FollowCamera.
  51721. * It groups all the default supported inputs for ease of use.
  51722. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51723. */
  51724. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51725. /**
  51726. * Instantiates a new FollowCameraInputsManager.
  51727. * @param camera Defines the camera the inputs belong to
  51728. */
  51729. constructor(camera: FollowCamera);
  51730. /**
  51731. * Add keyboard input support to the input manager.
  51732. * @returns the current input manager
  51733. */
  51734. addKeyboard(): FollowCameraInputsManager;
  51735. /**
  51736. * Add mouse wheel input support to the input manager.
  51737. * @returns the current input manager
  51738. */
  51739. addMouseWheel(): FollowCameraInputsManager;
  51740. /**
  51741. * Add pointers input support to the input manager.
  51742. * @returns the current input manager
  51743. */
  51744. addPointers(): FollowCameraInputsManager;
  51745. /**
  51746. * Add orientation input support to the input manager.
  51747. * @returns the current input manager
  51748. */
  51749. addVRDeviceOrientation(): FollowCameraInputsManager;
  51750. }
  51751. }
  51752. declare module BABYLON {
  51753. /**
  51754. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51755. * an arc rotate version arcFollowCamera are available.
  51756. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51757. */
  51758. export class FollowCamera extends TargetCamera {
  51759. /**
  51760. * Distance the follow camera should follow an object at
  51761. */
  51762. radius: number;
  51763. /**
  51764. * Minimum allowed distance of the camera to the axis of rotation
  51765. * (The camera can not get closer).
  51766. * This can help limiting how the Camera is able to move in the scene.
  51767. */
  51768. lowerRadiusLimit: Nullable<number>;
  51769. /**
  51770. * Maximum allowed distance of the camera to the axis of rotation
  51771. * (The camera can not get further).
  51772. * This can help limiting how the Camera is able to move in the scene.
  51773. */
  51774. upperRadiusLimit: Nullable<number>;
  51775. /**
  51776. * Define a rotation offset between the camera and the object it follows
  51777. */
  51778. rotationOffset: number;
  51779. /**
  51780. * Minimum allowed angle to camera position relative to target object.
  51781. * This can help limiting how the Camera is able to move in the scene.
  51782. */
  51783. lowerRotationOffsetLimit: Nullable<number>;
  51784. /**
  51785. * Maximum allowed angle to camera position relative to target object.
  51786. * This can help limiting how the Camera is able to move in the scene.
  51787. */
  51788. upperRotationOffsetLimit: Nullable<number>;
  51789. /**
  51790. * Define a height offset between the camera and the object it follows.
  51791. * It can help following an object from the top (like a car chasing a plane)
  51792. */
  51793. heightOffset: number;
  51794. /**
  51795. * Minimum allowed height of camera position relative to target object.
  51796. * This can help limiting how the Camera is able to move in the scene.
  51797. */
  51798. lowerHeightOffsetLimit: Nullable<number>;
  51799. /**
  51800. * Maximum allowed height of camera position relative to target object.
  51801. * This can help limiting how the Camera is able to move in the scene.
  51802. */
  51803. upperHeightOffsetLimit: Nullable<number>;
  51804. /**
  51805. * Define how fast the camera can accelerate to follow it s target.
  51806. */
  51807. cameraAcceleration: number;
  51808. /**
  51809. * Define the speed limit of the camera following an object.
  51810. */
  51811. maxCameraSpeed: number;
  51812. /**
  51813. * Define the target of the camera.
  51814. */
  51815. lockedTarget: Nullable<AbstractMesh>;
  51816. /**
  51817. * Defines the input associated with the camera.
  51818. */
  51819. inputs: FollowCameraInputsManager;
  51820. /**
  51821. * Instantiates the follow camera.
  51822. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51823. * @param name Define the name of the camera in the scene
  51824. * @param position Define the position of the camera
  51825. * @param scene Define the scene the camera belong to
  51826. * @param lockedTarget Define the target of the camera
  51827. */
  51828. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51829. private _follow;
  51830. /**
  51831. * Attach the input controls to a specific dom element to get the input from.
  51832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51833. */
  51834. attachControl(noPreventDefault?: boolean): void;
  51835. /**
  51836. * Detach the current controls from the specified dom element.
  51837. */
  51838. detachControl(): void;
  51839. /** @hidden */
  51840. _checkInputs(): void;
  51841. private _checkLimits;
  51842. /**
  51843. * Gets the camera class name.
  51844. * @returns the class name
  51845. */
  51846. getClassName(): string;
  51847. }
  51848. /**
  51849. * Arc Rotate version of the follow camera.
  51850. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51851. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51852. */
  51853. export class ArcFollowCamera extends TargetCamera {
  51854. /** The longitudinal angle of the camera */
  51855. alpha: number;
  51856. /** The latitudinal angle of the camera */
  51857. beta: number;
  51858. /** The radius of the camera from its target */
  51859. radius: number;
  51860. private _cartesianCoordinates;
  51861. /** Define the camera target (the mesh it should follow) */
  51862. private _meshTarget;
  51863. /**
  51864. * Instantiates a new ArcFollowCamera
  51865. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51866. * @param name Define the name of the camera
  51867. * @param alpha Define the rotation angle of the camera around the longitudinal axis
  51868. * @param beta Define the rotation angle of the camera around the elevation axis
  51869. * @param radius Define the radius of the camera from its target point
  51870. * @param target Define the target of the camera
  51871. * @param scene Define the scene the camera belongs to
  51872. */
  51873. constructor(name: string,
  51874. /** The longitudinal angle of the camera */
  51875. alpha: number,
  51876. /** The latitudinal angle of the camera */
  51877. beta: number,
  51878. /** The radius of the camera from its target */
  51879. radius: number,
  51880. /** Define the camera target (the mesh it should follow) */
  51881. target: Nullable<AbstractMesh>, scene: Scene);
  51882. private _follow;
  51883. /** @hidden */
  51884. _checkInputs(): void;
  51885. /**
  51886. * Returns the class name of the object.
  51887. * It is mostly used internally for serialization purposes.
  51888. */
  51889. getClassName(): string;
  51890. }
  51891. }
  51892. declare module BABYLON {
  51893. /**
  51894. * Manage the keyboard inputs to control the movement of a follow camera.
  51895. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51896. */
  51897. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51898. /**
  51899. * Defines the camera the input is attached to.
  51900. */
  51901. camera: FollowCamera;
  51902. /**
  51903. * Defines the list of key codes associated with the up action (increase heightOffset)
  51904. */
  51905. keysHeightOffsetIncr: number[];
  51906. /**
  51907. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51908. */
  51909. keysHeightOffsetDecr: number[];
  51910. /**
  51911. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51912. */
  51913. keysHeightOffsetModifierAlt: boolean;
  51914. /**
  51915. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51916. */
  51917. keysHeightOffsetModifierCtrl: boolean;
  51918. /**
  51919. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51920. */
  51921. keysHeightOffsetModifierShift: boolean;
  51922. /**
  51923. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51924. */
  51925. keysRotationOffsetIncr: number[];
  51926. /**
  51927. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51928. */
  51929. keysRotationOffsetDecr: number[];
  51930. /**
  51931. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51932. */
  51933. keysRotationOffsetModifierAlt: boolean;
  51934. /**
  51935. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51936. */
  51937. keysRotationOffsetModifierCtrl: boolean;
  51938. /**
  51939. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51940. */
  51941. keysRotationOffsetModifierShift: boolean;
  51942. /**
  51943. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51944. */
  51945. keysRadiusIncr: number[];
  51946. /**
  51947. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51948. */
  51949. keysRadiusDecr: number[];
  51950. /**
  51951. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51952. */
  51953. keysRadiusModifierAlt: boolean;
  51954. /**
  51955. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51956. */
  51957. keysRadiusModifierCtrl: boolean;
  51958. /**
  51959. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51960. */
  51961. keysRadiusModifierShift: boolean;
  51962. /**
  51963. * Defines the rate of change of heightOffset.
  51964. */
  51965. heightSensibility: number;
  51966. /**
  51967. * Defines the rate of change of rotationOffset.
  51968. */
  51969. rotationSensibility: number;
  51970. /**
  51971. * Defines the rate of change of radius.
  51972. */
  51973. radiusSensibility: number;
  51974. private _keys;
  51975. private _ctrlPressed;
  51976. private _altPressed;
  51977. private _shiftPressed;
  51978. private _onCanvasBlurObserver;
  51979. private _onKeyboardObserver;
  51980. private _engine;
  51981. private _scene;
  51982. /**
  51983. * Attach the input controls to a specific dom element to get the input from.
  51984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51985. */
  51986. attachControl(noPreventDefault?: boolean): void;
  51987. /**
  51988. * Detach the current controls from the specified dom element.
  51989. */
  51990. detachControl(): void;
  51991. /**
  51992. * Update the current camera state depending on the inputs that have been used this frame.
  51993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51994. */
  51995. checkInputs(): void;
  51996. /**
  51997. * Gets the class name of the current input.
  51998. * @returns the class name
  51999. */
  52000. getClassName(): string;
  52001. /**
  52002. * Get the friendly name associated with the input class.
  52003. * @returns the input friendly name
  52004. */
  52005. getSimpleName(): string;
  52006. /**
  52007. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52008. * allow modification of the heightOffset value.
  52009. */
  52010. private _modifierHeightOffset;
  52011. /**
  52012. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52013. * allow modification of the rotationOffset value.
  52014. */
  52015. private _modifierRotationOffset;
  52016. /**
  52017. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  52018. * allow modification of the radius value.
  52019. */
  52020. private _modifierRadius;
  52021. }
  52022. }
  52023. declare module BABYLON {
  52024. interface FreeCameraInputsManager {
  52025. /**
  52026. * @hidden
  52027. */
  52028. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  52029. /**
  52030. * Add orientation input support to the input manager.
  52031. * @returns the current input manager
  52032. */
  52033. addDeviceOrientation(): FreeCameraInputsManager;
  52034. }
  52035. /**
  52036. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  52037. * Screen rotation is taken into account.
  52038. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52039. */
  52040. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  52041. private _camera;
  52042. private _screenOrientationAngle;
  52043. private _constantTranform;
  52044. private _screenQuaternion;
  52045. private _alpha;
  52046. private _beta;
  52047. private _gamma;
  52048. /**
  52049. * Can be used to detect if a device orientation sensor is available on a device
  52050. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  52051. * @returns a promise that will resolve on orientation change
  52052. */
  52053. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  52054. /**
  52055. * @hidden
  52056. */
  52057. _onDeviceOrientationChangedObservable: Observable<void>;
  52058. /**
  52059. * Instantiates a new input
  52060. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52061. */
  52062. constructor();
  52063. /**
  52064. * Define the camera controlled by the input.
  52065. */
  52066. get camera(): FreeCamera;
  52067. set camera(camera: FreeCamera);
  52068. /**
  52069. * Attach the input controls to a specific dom element to get the input from.
  52070. */
  52071. attachControl(): void;
  52072. private _orientationChanged;
  52073. private _deviceOrientation;
  52074. /**
  52075. * Detach the current controls from the specified dom element.
  52076. */
  52077. detachControl(): void;
  52078. /**
  52079. * Update the current camera state depending on the inputs that have been used this frame.
  52080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52081. */
  52082. checkInputs(): void;
  52083. /**
  52084. * Gets the class name of the current input.
  52085. * @returns the class name
  52086. */
  52087. getClassName(): string;
  52088. /**
  52089. * Get the friendly name associated with the input class.
  52090. * @returns the input friendly name
  52091. */
  52092. getSimpleName(): string;
  52093. }
  52094. }
  52095. declare module BABYLON {
  52096. /**
  52097. * Manage the gamepad inputs to control a free camera.
  52098. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52099. */
  52100. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  52101. /**
  52102. * Define the camera the input is attached to.
  52103. */
  52104. camera: FreeCamera;
  52105. /**
  52106. * Define the Gamepad controlling the input
  52107. */
  52108. gamepad: Nullable<Gamepad>;
  52109. /**
  52110. * Defines the gamepad rotation sensiblity.
  52111. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52112. */
  52113. gamepadAngularSensibility: number;
  52114. /**
  52115. * Defines the gamepad move sensiblity.
  52116. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52117. */
  52118. gamepadMoveSensibility: number;
  52119. private _yAxisScale;
  52120. /**
  52121. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  52122. */
  52123. get invertYAxis(): boolean;
  52124. set invertYAxis(value: boolean);
  52125. private _onGamepadConnectedObserver;
  52126. private _onGamepadDisconnectedObserver;
  52127. private _cameraTransform;
  52128. private _deltaTransform;
  52129. private _vector3;
  52130. private _vector2;
  52131. /**
  52132. * Attach the input controls to a specific dom element to get the input from.
  52133. */
  52134. attachControl(): void;
  52135. /**
  52136. * Detach the current controls from the specified dom element.
  52137. */
  52138. detachControl(): void;
  52139. /**
  52140. * Update the current camera state depending on the inputs that have been used this frame.
  52141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52142. */
  52143. checkInputs(): void;
  52144. /**
  52145. * Gets the class name of the current input.
  52146. * @returns the class name
  52147. */
  52148. getClassName(): string;
  52149. /**
  52150. * Get the friendly name associated with the input class.
  52151. * @returns the input friendly name
  52152. */
  52153. getSimpleName(): string;
  52154. }
  52155. }
  52156. declare module BABYLON {
  52157. /**
  52158. * Defines the potential axis of a Joystick
  52159. */
  52160. export enum JoystickAxis {
  52161. /** X axis */
  52162. X = 0,
  52163. /** Y axis */
  52164. Y = 1,
  52165. /** Z axis */
  52166. Z = 2
  52167. }
  52168. /**
  52169. * Represents the different customization options available
  52170. * for VirtualJoystick
  52171. */
  52172. interface VirtualJoystickCustomizations {
  52173. /**
  52174. * Size of the joystick's puck
  52175. */
  52176. puckSize: number;
  52177. /**
  52178. * Size of the joystick's container
  52179. */
  52180. containerSize: number;
  52181. /**
  52182. * Color of the joystick && puck
  52183. */
  52184. color: string;
  52185. /**
  52186. * Image URL for the joystick's puck
  52187. */
  52188. puckImage?: string;
  52189. /**
  52190. * Image URL for the joystick's container
  52191. */
  52192. containerImage?: string;
  52193. /**
  52194. * Defines the unmoving position of the joystick container
  52195. */
  52196. position?: {
  52197. x: number;
  52198. y: number;
  52199. };
  52200. /**
  52201. * Defines whether or not the joystick container is always visible
  52202. */
  52203. alwaysVisible: boolean;
  52204. /**
  52205. * Defines whether or not to limit the movement of the puck to the joystick's container
  52206. */
  52207. limitToContainer: boolean;
  52208. }
  52209. /**
  52210. * Class used to define virtual joystick (used in touch mode)
  52211. */
  52212. export class VirtualJoystick {
  52213. /**
  52214. * Gets or sets a boolean indicating that left and right values must be inverted
  52215. */
  52216. reverseLeftRight: boolean;
  52217. /**
  52218. * Gets or sets a boolean indicating that up and down values must be inverted
  52219. */
  52220. reverseUpDown: boolean;
  52221. /**
  52222. * Gets the offset value for the position (ie. the change of the position value)
  52223. */
  52224. deltaPosition: Vector3;
  52225. /**
  52226. * Gets a boolean indicating if the virtual joystick was pressed
  52227. */
  52228. pressed: boolean;
  52229. /**
  52230. * Canvas the virtual joystick will render onto, default z-index of this is 5
  52231. */
  52232. static Canvas: Nullable<HTMLCanvasElement>;
  52233. /**
  52234. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  52235. */
  52236. limitToContainer: boolean;
  52237. private static _globalJoystickIndex;
  52238. private static _alwaysVisibleSticks;
  52239. private static vjCanvasContext;
  52240. private static vjCanvasWidth;
  52241. private static vjCanvasHeight;
  52242. private static halfWidth;
  52243. private static _GetDefaultOptions;
  52244. private _action;
  52245. private _axisTargetedByLeftAndRight;
  52246. private _axisTargetedByUpAndDown;
  52247. private _joystickSensibility;
  52248. private _inversedSensibility;
  52249. private _joystickPointerID;
  52250. private _joystickColor;
  52251. private _joystickPointerPos;
  52252. private _joystickPreviousPointerPos;
  52253. private _joystickPointerStartPos;
  52254. private _deltaJoystickVector;
  52255. private _leftJoystick;
  52256. private _touches;
  52257. private _joystickPosition;
  52258. private _alwaysVisible;
  52259. private _puckImage;
  52260. private _containerImage;
  52261. private _joystickPuckSize;
  52262. private _joystickContainerSize;
  52263. private _clearPuckSize;
  52264. private _clearContainerSize;
  52265. private _clearPuckSizeOffset;
  52266. private _clearContainerSizeOffset;
  52267. private _onPointerDownHandlerRef;
  52268. private _onPointerMoveHandlerRef;
  52269. private _onPointerUpHandlerRef;
  52270. private _onResize;
  52271. /**
  52272. * Creates a new virtual joystick
  52273. * @param leftJoystick defines that the joystick is for left hand (false by default)
  52274. * @param customizations Defines the options we want to customize the VirtualJoystick
  52275. */
  52276. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  52277. /**
  52278. * Defines joystick sensibility (ie. the ratio between a physical move and virtual joystick position change)
  52279. * @param newJoystickSensibility defines the new sensibility
  52280. */
  52281. setJoystickSensibility(newJoystickSensibility: number): void;
  52282. private _onPointerDown;
  52283. private _onPointerMove;
  52284. private _onPointerUp;
  52285. /**
  52286. * Change the color of the virtual joystick
  52287. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  52288. */
  52289. setJoystickColor(newColor: string): void;
  52290. /**
  52291. * Size of the joystick's container
  52292. */
  52293. set containerSize(newSize: number);
  52294. get containerSize(): number;
  52295. /**
  52296. * Size of the joystick's puck
  52297. */
  52298. set puckSize(newSize: number);
  52299. get puckSize(): number;
  52300. /**
  52301. * Clears the set position of the joystick
  52302. */
  52303. clearPosition(): void;
  52304. /**
  52305. * Defines whether or not the joystick container is always visible
  52306. */
  52307. set alwaysVisible(value: boolean);
  52308. get alwaysVisible(): boolean;
  52309. /**
  52310. * Sets the constant position of the Joystick container
  52311. * @param x X axis coordinate
  52312. * @param y Y axis coordinate
  52313. */
  52314. setPosition(x: number, y: number): void;
  52315. /**
  52316. * Defines a callback to call when the joystick is touched
  52317. * @param action defines the callback
  52318. */
  52319. setActionOnTouch(action: () => any): void;
  52320. /**
  52321. * Defines which axis you'd like to control for left & right
  52322. * @param axis defines the axis to use
  52323. */
  52324. setAxisForLeftRight(axis: JoystickAxis): void;
  52325. /**
  52326. * Defines which axis you'd like to control for up & down
  52327. * @param axis defines the axis to use
  52328. */
  52329. setAxisForUpDown(axis: JoystickAxis): void;
  52330. /**
  52331. * Clears the canvas from the previous puck / container draw
  52332. */
  52333. private _clearPreviousDraw;
  52334. /**
  52335. * Loads `urlPath` to be used for the container's image
  52336. * @param urlPath defines the urlPath of an image to use
  52337. */
  52338. setContainerImage(urlPath: string): void;
  52339. /**
  52340. * Loads `urlPath` to be used for the puck's image
  52341. * @param urlPath defines the urlPath of an image to use
  52342. */
  52343. setPuckImage(urlPath: string): void;
  52344. /**
  52345. * Draws the Virtual Joystick's container
  52346. */
  52347. private _drawContainer;
  52348. /**
  52349. * Draws the Virtual Joystick's puck
  52350. */
  52351. private _drawPuck;
  52352. private _drawVirtualJoystick;
  52353. /**
  52354. * Release internal HTML canvas
  52355. */
  52356. releaseCanvas(): void;
  52357. }
  52358. }
  52359. declare module BABYLON {
  52360. interface FreeCameraInputsManager {
  52361. /**
  52362. * Add virtual joystick input support to the input manager.
  52363. * @returns the current input manager
  52364. */
  52365. addVirtualJoystick(): FreeCameraInputsManager;
  52366. }
  52367. /**
  52368. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  52369. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  52370. */
  52371. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  52372. /**
  52373. * Defines the camera the input is attached to.
  52374. */
  52375. camera: FreeCamera;
  52376. private _leftjoystick;
  52377. private _rightjoystick;
  52378. /**
  52379. * Gets the left stick of the virtual joystick.
  52380. * @returns The virtual Joystick
  52381. */
  52382. getLeftJoystick(): VirtualJoystick;
  52383. /**
  52384. * Gets the right stick of the virtual joystick.
  52385. * @returns The virtual Joystick
  52386. */
  52387. getRightJoystick(): VirtualJoystick;
  52388. /**
  52389. * Update the current camera state depending on the inputs that have been used this frame.
  52390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  52391. */
  52392. checkInputs(): void;
  52393. /**
  52394. * Attach the input controls to a specific dom element to get the input from.
  52395. */
  52396. attachControl(): void;
  52397. /**
  52398. * Detach the current controls from the specified dom element.
  52399. */
  52400. detachControl(): void;
  52401. /**
  52402. * Gets the class name of the current input.
  52403. * @returns the class name
  52404. */
  52405. getClassName(): string;
  52406. /**
  52407. * Get the friendly name associated with the input class.
  52408. * @returns the input friendly name
  52409. */
  52410. getSimpleName(): string;
  52411. }
  52412. }
  52413. declare module BABYLON {
  52414. /**
  52415. * This represents a FPS type of camera controlled by touch.
  52416. * This is like a universal camera minus the Gamepad controls.
  52417. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52418. */
  52419. export class TouchCamera extends FreeCamera {
  52420. /**
  52421. * Defines the touch sensibility for rotation.
  52422. * The higher the faster.
  52423. */
  52424. get touchAngularSensibility(): number;
  52425. set touchAngularSensibility(value: number);
  52426. /**
  52427. * Defines the touch sensibility for move.
  52428. * The higher the faster.
  52429. */
  52430. get touchMoveSensibility(): number;
  52431. set touchMoveSensibility(value: number);
  52432. /**
  52433. * Instantiates a new touch camera.
  52434. * This represents a FPS type of camera controlled by touch.
  52435. * This is like a universal camera minus the Gamepad controls.
  52436. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52437. * @param name Define the name of the camera in the scene
  52438. * @param position Define the start position of the camera in the scene
  52439. * @param scene Define the scene the camera belongs to
  52440. */
  52441. constructor(name: string, position: Vector3, scene: Scene);
  52442. /**
  52443. * Gets the current object class name.
  52444. * @return the class name
  52445. */
  52446. getClassName(): string;
  52447. /** @hidden */
  52448. _setupInputs(): void;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /**
  52453. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  52454. * being tilted forward or back and left or right.
  52455. */
  52456. export class DeviceOrientationCamera extends FreeCamera {
  52457. private _initialQuaternion;
  52458. private _quaternionCache;
  52459. private _tmpDragQuaternion;
  52460. private _disablePointerInputWhenUsingDeviceOrientation;
  52461. /**
  52462. * Creates a new device orientation camera
  52463. * @param name The name of the camera
  52464. * @param position The start position camera
  52465. * @param scene The scene the camera belongs to
  52466. */
  52467. constructor(name: string, position: Vector3, scene: Scene);
  52468. /**
  52469. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  52470. */
  52471. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  52472. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  52473. private _dragFactor;
  52474. /**
  52475. * Enabled turning on the y axis when the orientation sensor is active
  52476. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  52477. */
  52478. enableHorizontalDragging(dragFactor?: number): void;
  52479. /**
  52480. * Gets the current instance class name ("DeviceOrientationCamera").
  52481. * This helps avoiding instanceof at run time.
  52482. * @returns the class name
  52483. */
  52484. getClassName(): string;
  52485. /**
  52486. * @hidden
  52487. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  52488. */
  52489. _checkInputs(): void;
  52490. /**
  52491. * Reset the camera to its default orientation on the specified axis only.
  52492. * @param axis The axis to reset
  52493. */
  52494. resetToCurrentRotation(axis?: Axis): void;
  52495. }
  52496. }
  52497. declare module BABYLON {
  52498. /**
  52499. * Defines supported buttons for XBox360 compatible gamepads
  52500. */
  52501. export enum Xbox360Button {
  52502. /** A */
  52503. A = 0,
  52504. /** B */
  52505. B = 1,
  52506. /** X */
  52507. X = 2,
  52508. /** Y */
  52509. Y = 3,
  52510. /** Left button */
  52511. LB = 4,
  52512. /** Right button */
  52513. RB = 5,
  52514. /** Back */
  52515. Back = 8,
  52516. /** Start */
  52517. Start = 9,
  52518. /** Left stick */
  52519. LeftStick = 10,
  52520. /** Right stick */
  52521. RightStick = 11
  52522. }
  52523. /** Defines values for XBox360 DPad */
  52524. export enum Xbox360Dpad {
  52525. /** Up */
  52526. Up = 12,
  52527. /** Down */
  52528. Down = 13,
  52529. /** Left */
  52530. Left = 14,
  52531. /** Right */
  52532. Right = 15
  52533. }
  52534. /**
  52535. * Defines a XBox360 gamepad
  52536. */
  52537. export class Xbox360Pad extends Gamepad {
  52538. private _leftTrigger;
  52539. private _rightTrigger;
  52540. private _onlefttriggerchanged;
  52541. private _onrighttriggerchanged;
  52542. private _onbuttondown;
  52543. private _onbuttonup;
  52544. private _ondpaddown;
  52545. private _ondpadup;
  52546. /** Observable raised when a button is pressed */
  52547. onButtonDownObservable: Observable<Xbox360Button>;
  52548. /** Observable raised when a button is released */
  52549. onButtonUpObservable: Observable<Xbox360Button>;
  52550. /** Observable raised when a pad is pressed */
  52551. onPadDownObservable: Observable<Xbox360Dpad>;
  52552. /** Observable raised when a pad is released */
  52553. onPadUpObservable: Observable<Xbox360Dpad>;
  52554. private _buttonA;
  52555. private _buttonB;
  52556. private _buttonX;
  52557. private _buttonY;
  52558. private _buttonBack;
  52559. private _buttonStart;
  52560. private _buttonLB;
  52561. private _buttonRB;
  52562. private _buttonLeftStick;
  52563. private _buttonRightStick;
  52564. private _dPadUp;
  52565. private _dPadDown;
  52566. private _dPadLeft;
  52567. private _dPadRight;
  52568. private _isXboxOnePad;
  52569. /**
  52570. * Creates a new XBox360 gamepad object
  52571. * @param id defines the id of this gamepad
  52572. * @param index defines its index
  52573. * @param gamepad defines the internal HTML gamepad object
  52574. * @param xboxOne defines if it is a XBox One gamepad
  52575. */
  52576. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  52577. /**
  52578. * Defines the callback to call when left trigger is pressed
  52579. * @param callback defines the callback to use
  52580. */
  52581. onlefttriggerchanged(callback: (value: number) => void): void;
  52582. /**
  52583. * Defines the callback to call when right trigger is pressed
  52584. * @param callback defines the callback to use
  52585. */
  52586. onrighttriggerchanged(callback: (value: number) => void): void;
  52587. /**
  52588. * Gets the left trigger value
  52589. */
  52590. get leftTrigger(): number;
  52591. /**
  52592. * Sets the left trigger value
  52593. */
  52594. set leftTrigger(newValue: number);
  52595. /**
  52596. * Gets the right trigger value
  52597. */
  52598. get rightTrigger(): number;
  52599. /**
  52600. * Sets the right trigger value
  52601. */
  52602. set rightTrigger(newValue: number);
  52603. /**
  52604. * Defines the callback to call when a button is pressed
  52605. * @param callback defines the callback to use
  52606. */
  52607. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  52608. /**
  52609. * Defines the callback to call when a button is released
  52610. * @param callback defines the callback to use
  52611. */
  52612. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  52613. /**
  52614. * Defines the callback to call when a pad is pressed
  52615. * @param callback defines the callback to use
  52616. */
  52617. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  52618. /**
  52619. * Defines the callback to call when a pad is released
  52620. * @param callback defines the callback to use
  52621. */
  52622. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  52623. private _setButtonValue;
  52624. private _setDPadValue;
  52625. /**
  52626. * Gets the value of the `A` button
  52627. */
  52628. get buttonA(): number;
  52629. /**
  52630. * Sets the value of the `A` button
  52631. */
  52632. set buttonA(value: number);
  52633. /**
  52634. * Gets the value of the `B` button
  52635. */
  52636. get buttonB(): number;
  52637. /**
  52638. * Sets the value of the `B` button
  52639. */
  52640. set buttonB(value: number);
  52641. /**
  52642. * Gets the value of the `X` button
  52643. */
  52644. get buttonX(): number;
  52645. /**
  52646. * Sets the value of the `X` button
  52647. */
  52648. set buttonX(value: number);
  52649. /**
  52650. * Gets the value of the `Y` button
  52651. */
  52652. get buttonY(): number;
  52653. /**
  52654. * Sets the value of the `Y` button
  52655. */
  52656. set buttonY(value: number);
  52657. /**
  52658. * Gets the value of the `Start` button
  52659. */
  52660. get buttonStart(): number;
  52661. /**
  52662. * Sets the value of the `Start` button
  52663. */
  52664. set buttonStart(value: number);
  52665. /**
  52666. * Gets the value of the `Back` button
  52667. */
  52668. get buttonBack(): number;
  52669. /**
  52670. * Sets the value of the `Back` button
  52671. */
  52672. set buttonBack(value: number);
  52673. /**
  52674. * Gets the value of the `Left` button
  52675. */
  52676. get buttonLB(): number;
  52677. /**
  52678. * Sets the value of the `Left` button
  52679. */
  52680. set buttonLB(value: number);
  52681. /**
  52682. * Gets the value of the `Right` button
  52683. */
  52684. get buttonRB(): number;
  52685. /**
  52686. * Sets the value of the `Right` button
  52687. */
  52688. set buttonRB(value: number);
  52689. /**
  52690. * Gets the value of the Left joystick
  52691. */
  52692. get buttonLeftStick(): number;
  52693. /**
  52694. * Sets the value of the Left joystick
  52695. */
  52696. set buttonLeftStick(value: number);
  52697. /**
  52698. * Gets the value of the Right joystick
  52699. */
  52700. get buttonRightStick(): number;
  52701. /**
  52702. * Sets the value of the Right joystick
  52703. */
  52704. set buttonRightStick(value: number);
  52705. /**
  52706. * Gets the value of D-pad up
  52707. */
  52708. get dPadUp(): number;
  52709. /**
  52710. * Sets the value of D-pad up
  52711. */
  52712. set dPadUp(value: number);
  52713. /**
  52714. * Gets the value of D-pad down
  52715. */
  52716. get dPadDown(): number;
  52717. /**
  52718. * Sets the value of D-pad down
  52719. */
  52720. set dPadDown(value: number);
  52721. /**
  52722. * Gets the value of D-pad left
  52723. */
  52724. get dPadLeft(): number;
  52725. /**
  52726. * Sets the value of D-pad left
  52727. */
  52728. set dPadLeft(value: number);
  52729. /**
  52730. * Gets the value of D-pad right
  52731. */
  52732. get dPadRight(): number;
  52733. /**
  52734. * Sets the value of D-pad right
  52735. */
  52736. set dPadRight(value: number);
  52737. /**
  52738. * Force the gamepad to synchronize with device values
  52739. */
  52740. update(): void;
  52741. /**
  52742. * Disposes the gamepad
  52743. */
  52744. dispose(): void;
  52745. }
  52746. }
  52747. declare module BABYLON {
  52748. /**
  52749. * Defines supported buttons for DualShock compatible gamepads
  52750. */
  52751. export enum DualShockButton {
  52752. /** Cross */
  52753. Cross = 0,
  52754. /** Circle */
  52755. Circle = 1,
  52756. /** Square */
  52757. Square = 2,
  52758. /** Triangle */
  52759. Triangle = 3,
  52760. /** L1 */
  52761. L1 = 4,
  52762. /** R1 */
  52763. R1 = 5,
  52764. /** Share */
  52765. Share = 8,
  52766. /** Options */
  52767. Options = 9,
  52768. /** Left stick */
  52769. LeftStick = 10,
  52770. /** Right stick */
  52771. RightStick = 11
  52772. }
  52773. /** Defines values for DualShock DPad */
  52774. export enum DualShockDpad {
  52775. /** Up */
  52776. Up = 12,
  52777. /** Down */
  52778. Down = 13,
  52779. /** Left */
  52780. Left = 14,
  52781. /** Right */
  52782. Right = 15
  52783. }
  52784. /**
  52785. * Defines a DualShock gamepad
  52786. */
  52787. export class DualShockPad extends Gamepad {
  52788. private _leftTrigger;
  52789. private _rightTrigger;
  52790. private _onlefttriggerchanged;
  52791. private _onrighttriggerchanged;
  52792. private _onbuttondown;
  52793. private _onbuttonup;
  52794. private _ondpaddown;
  52795. private _ondpadup;
  52796. /** Observable raised when a button is pressed */
  52797. onButtonDownObservable: Observable<DualShockButton>;
  52798. /** Observable raised when a button is released */
  52799. onButtonUpObservable: Observable<DualShockButton>;
  52800. /** Observable raised when a pad is pressed */
  52801. onPadDownObservable: Observable<DualShockDpad>;
  52802. /** Observable raised when a pad is released */
  52803. onPadUpObservable: Observable<DualShockDpad>;
  52804. private _buttonCross;
  52805. private _buttonCircle;
  52806. private _buttonSquare;
  52807. private _buttonTriangle;
  52808. private _buttonShare;
  52809. private _buttonOptions;
  52810. private _buttonL1;
  52811. private _buttonR1;
  52812. private _buttonLeftStick;
  52813. private _buttonRightStick;
  52814. private _dPadUp;
  52815. private _dPadDown;
  52816. private _dPadLeft;
  52817. private _dPadRight;
  52818. /**
  52819. * Creates a new DualShock gamepad object
  52820. * @param id defines the id of this gamepad
  52821. * @param index defines its index
  52822. * @param gamepad defines the internal HTML gamepad object
  52823. */
  52824. constructor(id: string, index: number, gamepad: any);
  52825. /**
  52826. * Defines the callback to call when left trigger is pressed
  52827. * @param callback defines the callback to use
  52828. */
  52829. onlefttriggerchanged(callback: (value: number) => void): void;
  52830. /**
  52831. * Defines the callback to call when right trigger is pressed
  52832. * @param callback defines the callback to use
  52833. */
  52834. onrighttriggerchanged(callback: (value: number) => void): void;
  52835. /**
  52836. * Gets the left trigger value
  52837. */
  52838. get leftTrigger(): number;
  52839. /**
  52840. * Sets the left trigger value
  52841. */
  52842. set leftTrigger(newValue: number);
  52843. /**
  52844. * Gets the right trigger value
  52845. */
  52846. get rightTrigger(): number;
  52847. /**
  52848. * Sets the right trigger value
  52849. */
  52850. set rightTrigger(newValue: number);
  52851. /**
  52852. * Defines the callback to call when a button is pressed
  52853. * @param callback defines the callback to use
  52854. */
  52855. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52856. /**
  52857. * Defines the callback to call when a button is released
  52858. * @param callback defines the callback to use
  52859. */
  52860. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52861. /**
  52862. * Defines the callback to call when a pad is pressed
  52863. * @param callback defines the callback to use
  52864. */
  52865. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52866. /**
  52867. * Defines the callback to call when a pad is released
  52868. * @param callback defines the callback to use
  52869. */
  52870. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52871. private _setButtonValue;
  52872. private _setDPadValue;
  52873. /**
  52874. * Gets the value of the `Cross` button
  52875. */
  52876. get buttonCross(): number;
  52877. /**
  52878. * Sets the value of the `Cross` button
  52879. */
  52880. set buttonCross(value: number);
  52881. /**
  52882. * Gets the value of the `Circle` button
  52883. */
  52884. get buttonCircle(): number;
  52885. /**
  52886. * Sets the value of the `Circle` button
  52887. */
  52888. set buttonCircle(value: number);
  52889. /**
  52890. * Gets the value of the `Square` button
  52891. */
  52892. get buttonSquare(): number;
  52893. /**
  52894. * Sets the value of the `Square` button
  52895. */
  52896. set buttonSquare(value: number);
  52897. /**
  52898. * Gets the value of the `Triangle` button
  52899. */
  52900. get buttonTriangle(): number;
  52901. /**
  52902. * Sets the value of the `Triangle` button
  52903. */
  52904. set buttonTriangle(value: number);
  52905. /**
  52906. * Gets the value of the `Options` button
  52907. */
  52908. get buttonOptions(): number;
  52909. /**
  52910. * Sets the value of the `Options` button
  52911. */
  52912. set buttonOptions(value: number);
  52913. /**
  52914. * Gets the value of the `Share` button
  52915. */
  52916. get buttonShare(): number;
  52917. /**
  52918. * Sets the value of the `Share` button
  52919. */
  52920. set buttonShare(value: number);
  52921. /**
  52922. * Gets the value of the `L1` button
  52923. */
  52924. get buttonL1(): number;
  52925. /**
  52926. * Sets the value of the `L1` button
  52927. */
  52928. set buttonL1(value: number);
  52929. /**
  52930. * Gets the value of the `R1` button
  52931. */
  52932. get buttonR1(): number;
  52933. /**
  52934. * Sets the value of the `R1` button
  52935. */
  52936. set buttonR1(value: number);
  52937. /**
  52938. * Gets the value of the Left joystick
  52939. */
  52940. get buttonLeftStick(): number;
  52941. /**
  52942. * Sets the value of the Left joystick
  52943. */
  52944. set buttonLeftStick(value: number);
  52945. /**
  52946. * Gets the value of the Right joystick
  52947. */
  52948. get buttonRightStick(): number;
  52949. /**
  52950. * Sets the value of the Right joystick
  52951. */
  52952. set buttonRightStick(value: number);
  52953. /**
  52954. * Gets the value of D-pad up
  52955. */
  52956. get dPadUp(): number;
  52957. /**
  52958. * Sets the value of D-pad up
  52959. */
  52960. set dPadUp(value: number);
  52961. /**
  52962. * Gets the value of D-pad down
  52963. */
  52964. get dPadDown(): number;
  52965. /**
  52966. * Sets the value of D-pad down
  52967. */
  52968. set dPadDown(value: number);
  52969. /**
  52970. * Gets the value of D-pad left
  52971. */
  52972. get dPadLeft(): number;
  52973. /**
  52974. * Sets the value of D-pad left
  52975. */
  52976. set dPadLeft(value: number);
  52977. /**
  52978. * Gets the value of D-pad right
  52979. */
  52980. get dPadRight(): number;
  52981. /**
  52982. * Sets the value of D-pad right
  52983. */
  52984. set dPadRight(value: number);
  52985. /**
  52986. * Force the gamepad to synchronize with device values
  52987. */
  52988. update(): void;
  52989. /**
  52990. * Disposes the gamepad
  52991. */
  52992. dispose(): void;
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * Manager for handling gamepads
  52998. */
  52999. export class GamepadManager {
  53000. private _scene?;
  53001. private _babylonGamepads;
  53002. private _oneGamepadConnected;
  53003. /** @hidden */
  53004. _isMonitoring: boolean;
  53005. private _gamepadEventSupported;
  53006. private _gamepadSupport?;
  53007. /**
  53008. * observable to be triggered when the gamepad controller has been connected
  53009. */
  53010. onGamepadConnectedObservable: Observable<Gamepad>;
  53011. /**
  53012. * observable to be triggered when the gamepad controller has been disconnected
  53013. */
  53014. onGamepadDisconnectedObservable: Observable<Gamepad>;
  53015. private _onGamepadConnectedEvent;
  53016. private _onGamepadDisconnectedEvent;
  53017. /**
  53018. * Initializes the gamepad manager
  53019. * @param _scene BabylonJS scene
  53020. */
  53021. constructor(_scene?: Scene | undefined);
  53022. /**
  53023. * The gamepads in the game pad manager
  53024. */
  53025. get gamepads(): Gamepad[];
  53026. /**
  53027. * Get the gamepad controllers based on type
  53028. * @param type The type of gamepad controller
  53029. * @returns Nullable gamepad
  53030. */
  53031. getGamepadByType(type?: number): Nullable<Gamepad>;
  53032. /**
  53033. * Disposes the gamepad manager
  53034. */
  53035. dispose(): void;
  53036. private _addNewGamepad;
  53037. private _startMonitoringGamepads;
  53038. private _stopMonitoringGamepads;
  53039. /** @hidden */
  53040. _checkGamepadsStatus(): void;
  53041. private _updateGamepadObjects;
  53042. }
  53043. }
  53044. declare module BABYLON {
  53045. interface Scene {
  53046. /** @hidden */
  53047. _gamepadManager: Nullable<GamepadManager>;
  53048. /**
  53049. * Gets the gamepad manager associated with the scene
  53050. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  53051. */
  53052. gamepadManager: GamepadManager;
  53053. }
  53054. /**
  53055. * Interface representing a free camera inputs manager
  53056. */
  53057. interface FreeCameraInputsManager {
  53058. /**
  53059. * Adds gamepad input support to the FreeCameraInputsManager.
  53060. * @returns the FreeCameraInputsManager
  53061. */
  53062. addGamepad(): FreeCameraInputsManager;
  53063. }
  53064. /**
  53065. * Interface representing an arc rotate camera inputs manager
  53066. */
  53067. interface ArcRotateCameraInputsManager {
  53068. /**
  53069. * Adds gamepad input support to the ArcRotateCamera InputManager.
  53070. * @returns the camera inputs manager
  53071. */
  53072. addGamepad(): ArcRotateCameraInputsManager;
  53073. }
  53074. /**
  53075. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  53076. */
  53077. export class GamepadSystemSceneComponent implements ISceneComponent {
  53078. /**
  53079. * The component name helpfull to identify the component in the list of scene components.
  53080. */
  53081. readonly name: string;
  53082. /**
  53083. * The scene the component belongs to.
  53084. */
  53085. scene: Scene;
  53086. /**
  53087. * Creates a new instance of the component for the given scene
  53088. * @param scene Defines the scene to register the component in
  53089. */
  53090. constructor(scene: Scene);
  53091. /**
  53092. * Registers the component in a given scene
  53093. */
  53094. register(): void;
  53095. /**
  53096. * Rebuilds the elements related to this component in case of
  53097. * context lost for instance.
  53098. */
  53099. rebuild(): void;
  53100. /**
  53101. * Disposes the component and the associated ressources
  53102. */
  53103. dispose(): void;
  53104. private _beforeCameraUpdate;
  53105. }
  53106. }
  53107. declare module BABYLON {
  53108. /**
  53109. * 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,
  53110. * which still works and will still be found in many Playgrounds.
  53111. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53112. */
  53113. export class UniversalCamera extends TouchCamera {
  53114. /**
  53115. * Defines the gamepad rotation sensiblity.
  53116. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  53117. */
  53118. get gamepadAngularSensibility(): number;
  53119. set gamepadAngularSensibility(value: number);
  53120. /**
  53121. * Defines the gamepad move sensiblity.
  53122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  53123. */
  53124. get gamepadMoveSensibility(): number;
  53125. set gamepadMoveSensibility(value: number);
  53126. /**
  53127. * 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,
  53128. * which still works and will still be found in many Playgrounds.
  53129. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53130. * @param name Define the name of the camera in the scene
  53131. * @param position Define the start position of the camera in the scene
  53132. * @param scene Define the scene the camera belongs to
  53133. */
  53134. constructor(name: string, position: Vector3, scene: Scene);
  53135. /**
  53136. * Gets the current object class name.
  53137. * @return the class name
  53138. */
  53139. getClassName(): string;
  53140. }
  53141. }
  53142. declare module BABYLON {
  53143. /**
  53144. * This represents a FPS type of camera. This is only here for back compat purpose.
  53145. * Please use the UniversalCamera instead as both are identical.
  53146. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53147. */
  53148. export class GamepadCamera extends UniversalCamera {
  53149. /**
  53150. * Instantiates a new Gamepad Camera
  53151. * This represents a FPS type of camera. This is only here for back compat purpose.
  53152. * Please use the UniversalCamera instead as both are identical.
  53153. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  53154. * @param name Define the name of the camera in the scene
  53155. * @param position Define the start position of the camera in the scene
  53156. * @param scene Define the scene the camera belongs to
  53157. */
  53158. constructor(name: string, position: Vector3, scene: Scene);
  53159. /**
  53160. * Gets the current object class name.
  53161. * @return the class name
  53162. */
  53163. getClassName(): string;
  53164. }
  53165. }
  53166. declare module BABYLON {
  53167. /** @hidden */
  53168. export var anaglyphPixelShader: {
  53169. name: string;
  53170. shader: string;
  53171. };
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Postprocess used to generate anaglyphic rendering
  53176. */
  53177. export class AnaglyphPostProcess extends PostProcess {
  53178. private _passedProcess;
  53179. /**
  53180. * Gets a string identifying the name of the class
  53181. * @returns "AnaglyphPostProcess" string
  53182. */
  53183. getClassName(): string;
  53184. /**
  53185. * Creates a new AnaglyphPostProcess
  53186. * @param name defines postprocess name
  53187. * @param options defines creation options or target ratio scale
  53188. * @param rigCameras defines cameras using this postprocess
  53189. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  53190. * @param engine defines hosting engine
  53191. * @param reusable defines if the postprocess will be reused multiple times per frame
  53192. */
  53193. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  53194. }
  53195. }
  53196. declare module BABYLON {
  53197. /**
  53198. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  53199. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53200. */
  53201. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  53202. /**
  53203. * Creates a new AnaglyphArcRotateCamera
  53204. * @param name defines camera name
  53205. * @param alpha defines alpha angle (in radians)
  53206. * @param beta defines beta angle (in radians)
  53207. * @param radius defines radius
  53208. * @param target defines camera target
  53209. * @param interaxialDistance defines distance between each color axis
  53210. * @param scene defines the hosting scene
  53211. */
  53212. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  53213. /**
  53214. * Gets camera class name
  53215. * @returns AnaglyphArcRotateCamera
  53216. */
  53217. getClassName(): string;
  53218. }
  53219. }
  53220. declare module BABYLON {
  53221. /**
  53222. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  53223. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53224. */
  53225. export class AnaglyphFreeCamera extends FreeCamera {
  53226. /**
  53227. * Creates a new AnaglyphFreeCamera
  53228. * @param name defines camera name
  53229. * @param position defines initial position
  53230. * @param interaxialDistance defines distance between each color axis
  53231. * @param scene defines the hosting scene
  53232. */
  53233. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53234. /**
  53235. * Gets camera class name
  53236. * @returns AnaglyphFreeCamera
  53237. */
  53238. getClassName(): string;
  53239. }
  53240. }
  53241. declare module BABYLON {
  53242. /**
  53243. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  53244. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53245. */
  53246. export class AnaglyphGamepadCamera extends GamepadCamera {
  53247. /**
  53248. * Creates a new AnaglyphGamepadCamera
  53249. * @param name defines camera name
  53250. * @param position defines initial position
  53251. * @param interaxialDistance defines distance between each color axis
  53252. * @param scene defines the hosting scene
  53253. */
  53254. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53255. /**
  53256. * Gets camera class name
  53257. * @returns AnaglyphGamepadCamera
  53258. */
  53259. getClassName(): string;
  53260. }
  53261. }
  53262. declare module BABYLON {
  53263. /**
  53264. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  53265. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  53266. */
  53267. export class AnaglyphUniversalCamera extends UniversalCamera {
  53268. /**
  53269. * Creates a new AnaglyphUniversalCamera
  53270. * @param name defines camera name
  53271. * @param position defines initial position
  53272. * @param interaxialDistance defines distance between each color axis
  53273. * @param scene defines the hosting scene
  53274. */
  53275. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  53276. /**
  53277. * Gets camera class name
  53278. * @returns AnaglyphUniversalCamera
  53279. */
  53280. getClassName(): string;
  53281. }
  53282. }
  53283. declare module BABYLON {
  53284. /** @hidden */
  53285. export var stereoscopicInterlacePixelShader: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module BABYLON {
  53291. /**
  53292. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  53293. */
  53294. export class StereoscopicInterlacePostProcessI extends PostProcess {
  53295. private _stepSize;
  53296. private _passedProcess;
  53297. /**
  53298. * Gets a string identifying the name of the class
  53299. * @returns "StereoscopicInterlacePostProcessI" string
  53300. */
  53301. getClassName(): string;
  53302. /**
  53303. * Initializes a StereoscopicInterlacePostProcessI
  53304. * @param name The name of the effect.
  53305. * @param rigCameras The rig cameras to be applied to the post process
  53306. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53307. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  53308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53309. * @param engine The engine which the post process will be applied. (default: current engine)
  53310. * @param reusable If the post process can be reused on the same frame. (default: false)
  53311. */
  53312. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53313. }
  53314. /**
  53315. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  53316. */
  53317. export class StereoscopicInterlacePostProcess extends PostProcess {
  53318. private _stepSize;
  53319. private _passedProcess;
  53320. /**
  53321. * Gets a string identifying the name of the class
  53322. * @returns "StereoscopicInterlacePostProcess" string
  53323. */
  53324. getClassName(): string;
  53325. /**
  53326. * Initializes a StereoscopicInterlacePostProcess
  53327. * @param name The name of the effect.
  53328. * @param rigCameras The rig cameras to be applied to the post process
  53329. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  53330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53331. * @param engine The engine which the post process will be applied. (default: current engine)
  53332. * @param reusable If the post process can be reused on the same frame. (default: false)
  53333. */
  53334. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53335. }
  53336. }
  53337. declare module BABYLON {
  53338. /**
  53339. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  53340. * @see https://doc.babylonjs.com/features/cameras
  53341. */
  53342. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  53343. /**
  53344. * Creates a new StereoscopicArcRotateCamera
  53345. * @param name defines camera name
  53346. * @param alpha defines alpha angle (in radians)
  53347. * @param beta defines beta angle (in radians)
  53348. * @param radius defines radius
  53349. * @param target defines camera target
  53350. * @param interaxialDistance defines distance between each color axis
  53351. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53352. * @param scene defines the hosting scene
  53353. */
  53354. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53355. /**
  53356. * Gets camera class name
  53357. * @returns StereoscopicArcRotateCamera
  53358. */
  53359. getClassName(): string;
  53360. }
  53361. }
  53362. declare module BABYLON {
  53363. /**
  53364. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  53365. * @see https://doc.babylonjs.com/features/cameras
  53366. */
  53367. export class StereoscopicFreeCamera extends FreeCamera {
  53368. /**
  53369. * Creates a new StereoscopicFreeCamera
  53370. * @param name defines camera name
  53371. * @param position defines initial position
  53372. * @param interaxialDistance defines distance between each color axis
  53373. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53374. * @param scene defines the hosting scene
  53375. */
  53376. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53377. /**
  53378. * Gets camera class name
  53379. * @returns StereoscopicFreeCamera
  53380. */
  53381. getClassName(): string;
  53382. }
  53383. }
  53384. declare module BABYLON {
  53385. /**
  53386. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  53387. * @see https://doc.babylonjs.com/features/cameras
  53388. */
  53389. export class StereoscopicGamepadCamera extends GamepadCamera {
  53390. /**
  53391. * Creates a new StereoscopicGamepadCamera
  53392. * @param name defines camera name
  53393. * @param position defines initial position
  53394. * @param interaxialDistance defines distance between each color axis
  53395. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53396. * @param scene defines the hosting scene
  53397. */
  53398. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53399. /**
  53400. * Gets camera class name
  53401. * @returns StereoscopicGamepadCamera
  53402. */
  53403. getClassName(): string;
  53404. }
  53405. }
  53406. declare module BABYLON {
  53407. /**
  53408. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  53409. * @see https://doc.babylonjs.com/features/cameras
  53410. */
  53411. export class StereoscopicUniversalCamera extends UniversalCamera {
  53412. /**
  53413. * Creates a new StereoscopicUniversalCamera
  53414. * @param name defines camera name
  53415. * @param position defines initial position
  53416. * @param interaxialDistance defines distance between each color axis
  53417. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  53418. * @param scene defines the hosting scene
  53419. */
  53420. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  53421. /**
  53422. * Gets camera class name
  53423. * @returns StereoscopicUniversalCamera
  53424. */
  53425. getClassName(): string;
  53426. }
  53427. }
  53428. declare module BABYLON {
  53429. /**
  53430. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  53431. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53432. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53433. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53434. */
  53435. export class VirtualJoysticksCamera extends FreeCamera {
  53436. /**
  53437. * Instantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  53438. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  53439. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  53440. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  53441. * @param name Define the name of the camera in the scene
  53442. * @param position Define the start position of the camera in the scene
  53443. * @param scene Define the scene the camera belongs to
  53444. */
  53445. constructor(name: string, position: Vector3, scene: Scene);
  53446. /**
  53447. * Gets the current object class name.
  53448. * @return the class name
  53449. */
  53450. getClassName(): string;
  53451. }
  53452. }
  53453. declare module BABYLON {
  53454. /**
  53455. * This represents all the required metrics to create a VR camera.
  53456. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  53457. */
  53458. export class VRCameraMetrics {
  53459. /**
  53460. * Define the horizontal resolution off the screen.
  53461. */
  53462. hResolution: number;
  53463. /**
  53464. * Define the vertical resolution off the screen.
  53465. */
  53466. vResolution: number;
  53467. /**
  53468. * Define the horizontal screen size.
  53469. */
  53470. hScreenSize: number;
  53471. /**
  53472. * Define the vertical screen size.
  53473. */
  53474. vScreenSize: number;
  53475. /**
  53476. * Define the vertical screen center position.
  53477. */
  53478. vScreenCenter: number;
  53479. /**
  53480. * Define the distance of the eyes to the screen.
  53481. */
  53482. eyeToScreenDistance: number;
  53483. /**
  53484. * Define the distance between both lenses
  53485. */
  53486. lensSeparationDistance: number;
  53487. /**
  53488. * Define the distance between both viewer's eyes.
  53489. */
  53490. interpupillaryDistance: number;
  53491. /**
  53492. * Define the distortion factor of the VR postprocess.
  53493. * Please, touch with care.
  53494. */
  53495. distortionK: number[];
  53496. /**
  53497. * Define the chromatic aberration correction factors for the VR post process.
  53498. */
  53499. chromaAbCorrection: number[];
  53500. /**
  53501. * Define the scale factor of the post process.
  53502. * The smaller the better but the slower.
  53503. */
  53504. postProcessScaleFactor: number;
  53505. /**
  53506. * Define an offset for the lens center.
  53507. */
  53508. lensCenterOffset: number;
  53509. /**
  53510. * Define if the current vr camera should compensate the distortion of the lens or not.
  53511. */
  53512. compensateDistortion: boolean;
  53513. /**
  53514. * Defines if multiview should be enabled when rendering (Default: false)
  53515. */
  53516. multiviewEnabled: boolean;
  53517. /**
  53518. * Gets the rendering aspect ratio based on the provided resolutions.
  53519. */
  53520. get aspectRatio(): number;
  53521. /**
  53522. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  53523. */
  53524. get aspectRatioFov(): number;
  53525. /**
  53526. * @hidden
  53527. */
  53528. get leftHMatrix(): Matrix;
  53529. /**
  53530. * @hidden
  53531. */
  53532. get rightHMatrix(): Matrix;
  53533. /**
  53534. * @hidden
  53535. */
  53536. get leftPreViewMatrix(): Matrix;
  53537. /**
  53538. * @hidden
  53539. */
  53540. get rightPreViewMatrix(): Matrix;
  53541. /**
  53542. * Get the default VRMetrics based on the most generic setup.
  53543. * @returns the default vr metrics
  53544. */
  53545. static GetDefault(): VRCameraMetrics;
  53546. }
  53547. }
  53548. declare module BABYLON {
  53549. /** @hidden */
  53550. export var vrDistortionCorrectionPixelShader: {
  53551. name: string;
  53552. shader: string;
  53553. };
  53554. }
  53555. declare module BABYLON {
  53556. /**
  53557. * VRDistortionCorrectionPostProcess used for mobile VR
  53558. */
  53559. export class VRDistortionCorrectionPostProcess extends PostProcess {
  53560. private _isRightEye;
  53561. private _distortionFactors;
  53562. private _postProcessScaleFactor;
  53563. private _lensCenterOffset;
  53564. private _scaleIn;
  53565. private _scaleFactor;
  53566. private _lensCenter;
  53567. /**
  53568. * Gets a string identifying the name of the class
  53569. * @returns "VRDistortionCorrectionPostProcess" string
  53570. */
  53571. getClassName(): string;
  53572. /**
  53573. * Initializes the VRDistortionCorrectionPostProcess
  53574. * @param name The name of the effect.
  53575. * @param camera The camera to apply the render pass to.
  53576. * @param isRightEye If this is for the right eye distortion
  53577. * @param vrMetrics All the required metrics for the VR camera
  53578. */
  53579. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  53580. }
  53581. }
  53582. declare module BABYLON {
  53583. /**
  53584. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  53585. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53586. */
  53587. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  53588. /**
  53589. * Creates a new VRDeviceOrientationArcRotateCamera
  53590. * @param name defines camera name
  53591. * @param alpha defines the camera rotation along the longitudinal axis
  53592. * @param beta defines the camera rotation along the latitudinal axis
  53593. * @param radius defines the camera distance from its target
  53594. * @param target defines the camera target
  53595. * @param scene defines the scene the camera belongs to
  53596. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53597. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53598. */
  53599. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53600. /**
  53601. * Gets camera class name
  53602. * @returns VRDeviceOrientationArcRotateCamera
  53603. */
  53604. getClassName(): string;
  53605. }
  53606. }
  53607. declare module BABYLON {
  53608. /**
  53609. * Camera used to simulate VR rendering (based on FreeCamera)
  53610. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53611. */
  53612. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  53613. /**
  53614. * Creates a new VRDeviceOrientationFreeCamera
  53615. * @param name defines camera name
  53616. * @param position defines the start position of the camera
  53617. * @param scene defines the scene the camera belongs to
  53618. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53619. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53620. */
  53621. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53622. /**
  53623. * Gets camera class name
  53624. * @returns VRDeviceOrientationFreeCamera
  53625. */
  53626. getClassName(): string;
  53627. }
  53628. }
  53629. declare module BABYLON {
  53630. /**
  53631. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  53632. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  53633. */
  53634. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  53635. /**
  53636. * Creates a new VRDeviceOrientationGamepadCamera
  53637. * @param name defines camera name
  53638. * @param position defines the start position of the camera
  53639. * @param scene defines the scene the camera belongs to
  53640. * @param compensateDistortion defines if the camera needs to compensate the lens distortion
  53641. * @param vrCameraMetrics defines the vr metrics associated to the camera
  53642. */
  53643. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  53644. /**
  53645. * Gets camera class name
  53646. * @returns VRDeviceOrientationGamepadCamera
  53647. */
  53648. getClassName(): string;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /**
  53653. * A class extending Texture allowing drawing on a texture
  53654. * @see https://doc.babylonjs.com/how_to/dynamictexture
  53655. */
  53656. export class DynamicTexture extends Texture {
  53657. private _generateMipMaps;
  53658. private _canvas;
  53659. private _context;
  53660. /**
  53661. * Creates a DynamicTexture
  53662. * @param name defines the name of the texture
  53663. * @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
  53664. * @param scene defines the scene where you want the texture
  53665. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  53666. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53667. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  53668. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  53669. */
  53670. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53671. /**
  53672. * Get the current class name of the texture useful for serialization or dynamic coding.
  53673. * @returns "DynamicTexture"
  53674. */
  53675. getClassName(): string;
  53676. /**
  53677. * Gets the current state of canRescale
  53678. */
  53679. get canRescale(): boolean;
  53680. private _recreate;
  53681. /**
  53682. * Scales the texture
  53683. * @param ratio the scale factor to apply to both width and height
  53684. */
  53685. scale(ratio: number): void;
  53686. /**
  53687. * Resizes the texture
  53688. * @param width the new width
  53689. * @param height the new height
  53690. */
  53691. scaleTo(width: number, height: number): void;
  53692. /**
  53693. * Gets the context of the canvas used by the texture
  53694. * @returns the canvas context of the dynamic texture
  53695. */
  53696. getContext(): CanvasRenderingContext2D;
  53697. /**
  53698. * Clears the texture
  53699. */
  53700. clear(): void;
  53701. /**
  53702. * Updates the texture
  53703. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53704. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53705. */
  53706. update(invertY?: boolean, premulAlpha?: boolean): void;
  53707. /**
  53708. * Draws text onto the texture
  53709. * @param text defines the text to be drawn
  53710. * @param x defines the placement of the text from the left
  53711. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53712. * @param font defines the font to be used with font-style, font-size, font-name
  53713. * @param color defines the color used for the text
  53714. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53715. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53716. * @param update defines whether texture is immediately update (default is true)
  53717. */
  53718. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53719. /**
  53720. * Clones the texture
  53721. * @returns the clone of the texture.
  53722. */
  53723. clone(): DynamicTexture;
  53724. /**
  53725. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53726. * @returns a serialized dynamic texture object
  53727. */
  53728. serialize(): any;
  53729. private _IsCanvasElement;
  53730. /** @hidden */
  53731. _rebuild(): void;
  53732. }
  53733. }
  53734. declare module BABYLON {
  53735. /**
  53736. * Class containing static functions to help procedurally build meshes
  53737. */
  53738. export class GroundBuilder {
  53739. /**
  53740. * Creates a ground mesh
  53741. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53742. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53744. * @param name defines the name of the mesh
  53745. * @param options defines the options used to create the mesh
  53746. * @param scene defines the hosting scene
  53747. * @returns the ground mesh
  53748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53749. */
  53750. static CreateGround(name: string, options: {
  53751. width?: number;
  53752. height?: number;
  53753. subdivisions?: number;
  53754. subdivisionsX?: number;
  53755. subdivisionsY?: number;
  53756. updatable?: boolean;
  53757. }, scene: any): Mesh;
  53758. /**
  53759. * Creates a tiled ground mesh
  53760. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53761. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53762. * * 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
  53763. * * 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
  53764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53765. * @param name defines the name of the mesh
  53766. * @param options defines the options used to create the mesh
  53767. * @param scene defines the hosting scene
  53768. * @returns the tiled ground mesh
  53769. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53770. */
  53771. static CreateTiledGround(name: string, options: {
  53772. xmin: number;
  53773. zmin: number;
  53774. xmax: number;
  53775. zmax: number;
  53776. subdivisions?: {
  53777. w: number;
  53778. h: number;
  53779. };
  53780. precision?: {
  53781. w: number;
  53782. h: number;
  53783. };
  53784. updatable?: boolean;
  53785. }, scene?: Nullable<Scene>): Mesh;
  53786. /**
  53787. * Creates a ground mesh from a height map
  53788. * * The parameter `url` sets the URL of the height map image resource.
  53789. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53790. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53791. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53792. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53793. * * 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.
  53794. * * 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).
  53795. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53797. * @param name defines the name of the mesh
  53798. * @param url defines the url to the height map
  53799. * @param options defines the options used to create the mesh
  53800. * @param scene defines the hosting scene
  53801. * @returns the ground mesh
  53802. * @see https://doc.babylonjs.com/babylon101/height_map
  53803. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53804. */
  53805. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53806. width?: number;
  53807. height?: number;
  53808. subdivisions?: number;
  53809. minHeight?: number;
  53810. maxHeight?: number;
  53811. colorFilter?: Color3;
  53812. alphaFilter?: number;
  53813. updatable?: boolean;
  53814. onReady?: (mesh: GroundMesh) => void;
  53815. }, scene?: Nullable<Scene>): GroundMesh;
  53816. }
  53817. }
  53818. declare module BABYLON {
  53819. /**
  53820. * Class containing static functions to help procedurally build meshes
  53821. */
  53822. export class TorusBuilder {
  53823. /**
  53824. * Creates a torus mesh
  53825. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53826. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53827. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  53828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53829. * * 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
  53830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53831. * @param name defines the name of the mesh
  53832. * @param options defines the options used to create the mesh
  53833. * @param scene defines the hosting scene
  53834. * @returns the torus mesh
  53835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53836. */
  53837. static CreateTorus(name: string, options: {
  53838. diameter?: number;
  53839. thickness?: number;
  53840. tessellation?: number;
  53841. updatable?: boolean;
  53842. sideOrientation?: number;
  53843. frontUVs?: Vector4;
  53844. backUVs?: Vector4;
  53845. }, scene: any): Mesh;
  53846. }
  53847. }
  53848. declare module BABYLON {
  53849. /**
  53850. * Class containing static functions to help procedurally build meshes
  53851. */
  53852. export class CylinderBuilder {
  53853. /**
  53854. * Creates a cylinder or a cone mesh
  53855. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53856. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53857. * * 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.
  53858. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53859. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53860. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53861. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53862. * * 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).
  53863. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53864. * * 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).
  53865. * * 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
  53866. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53867. * * 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
  53868. * * 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.
  53869. * * If `enclose` is false, a ring surface is one element.
  53870. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53871. * * 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
  53872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53873. * * 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
  53874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53875. * @param name defines the name of the mesh
  53876. * @param options defines the options used to create the mesh
  53877. * @param scene defines the hosting scene
  53878. * @returns the cylinder mesh
  53879. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53880. */
  53881. static CreateCylinder(name: string, options: {
  53882. height?: number;
  53883. diameterTop?: number;
  53884. diameterBottom?: number;
  53885. diameter?: number;
  53886. tessellation?: number;
  53887. subdivisions?: number;
  53888. arc?: number;
  53889. faceColors?: Color4[];
  53890. faceUV?: Vector4[];
  53891. updatable?: boolean;
  53892. hasRings?: boolean;
  53893. enclose?: boolean;
  53894. cap?: number;
  53895. sideOrientation?: number;
  53896. frontUVs?: Vector4;
  53897. backUVs?: Vector4;
  53898. }, scene: any): Mesh;
  53899. }
  53900. }
  53901. declare module BABYLON {
  53902. /**
  53903. * States of the webXR experience
  53904. */
  53905. export enum WebXRState {
  53906. /**
  53907. * Transitioning to being in XR mode
  53908. */
  53909. ENTERING_XR = 0,
  53910. /**
  53911. * Transitioning to non XR mode
  53912. */
  53913. EXITING_XR = 1,
  53914. /**
  53915. * In XR mode and presenting
  53916. */
  53917. IN_XR = 2,
  53918. /**
  53919. * Not entered XR mode
  53920. */
  53921. NOT_IN_XR = 3
  53922. }
  53923. /**
  53924. * The state of the XR camera's tracking
  53925. */
  53926. export enum WebXRTrackingState {
  53927. /**
  53928. * No transformation received, device is not being tracked
  53929. */
  53930. NOT_TRACKING = 0,
  53931. /**
  53932. * Tracking lost - using emulated position
  53933. */
  53934. TRACKING_LOST = 1,
  53935. /**
  53936. * Transformation tracking works normally
  53937. */
  53938. TRACKING = 2
  53939. }
  53940. /**
  53941. * Abstraction of the XR render target
  53942. */
  53943. export interface WebXRRenderTarget extends IDisposable {
  53944. /**
  53945. * xrpresent context of the canvas which can be used to display/mirror xr content
  53946. */
  53947. canvasContext: WebGLRenderingContext;
  53948. /**
  53949. * xr layer for the canvas
  53950. */
  53951. xrLayer: Nullable<XRWebGLLayer>;
  53952. /**
  53953. * Initializes the xr layer for the session
  53954. * @param xrSession xr session
  53955. * @returns a promise that will resolve once the XR Layer has been created
  53956. */
  53957. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53958. }
  53959. }
  53960. declare module BABYLON {
  53961. /**
  53962. * Configuration object for WebXR output canvas
  53963. */
  53964. export class WebXRManagedOutputCanvasOptions {
  53965. /**
  53966. * An optional canvas in case you wish to create it yourself and provide it here.
  53967. * If not provided, a new canvas will be created
  53968. */
  53969. canvasElement?: HTMLCanvasElement;
  53970. /**
  53971. * Options for this XR Layer output
  53972. */
  53973. canvasOptions?: XRWebGLLayerInit;
  53974. /**
  53975. * CSS styling for a newly created canvas (if not provided)
  53976. */
  53977. newCanvasCssStyle?: string;
  53978. /**
  53979. * Get the default values of the configuration object
  53980. * @param engine defines the engine to use (can be null)
  53981. * @returns default values of this configuration object
  53982. */
  53983. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53984. }
  53985. /**
  53986. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53987. */
  53988. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53989. private _options;
  53990. private _canvas;
  53991. private _engine;
  53992. private _originalCanvasSize;
  53993. /**
  53994. * Rendering context of the canvas which can be used to display/mirror xr content
  53995. */
  53996. canvasContext: WebGLRenderingContext;
  53997. /**
  53998. * xr layer for the canvas
  53999. */
  54000. xrLayer: Nullable<XRWebGLLayer>;
  54001. /**
  54002. * Observers registered here will be triggered when the xr layer was initialized
  54003. */
  54004. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  54005. /**
  54006. * Initializes the canvas to be added/removed upon entering/exiting xr
  54007. * @param _xrSessionManager The XR Session manager
  54008. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  54009. */
  54010. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  54011. /**
  54012. * Disposes of the object
  54013. */
  54014. dispose(): void;
  54015. /**
  54016. * Initializes the xr layer for the session
  54017. * @param xrSession xr session
  54018. * @returns a promise that will resolve once the XR Layer has been created
  54019. */
  54020. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  54021. private _addCanvas;
  54022. private _removeCanvas;
  54023. private _setCanvasSize;
  54024. private _setManagedOutputCanvas;
  54025. }
  54026. }
  54027. declare module BABYLON {
  54028. /**
  54029. * Manages an XRSession to work with Babylon's engine
  54030. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  54031. */
  54032. export class WebXRSessionManager implements IDisposable {
  54033. /** The scene which the session should be created for */
  54034. scene: Scene;
  54035. private _referenceSpace;
  54036. private _rttProvider;
  54037. private _sessionEnded;
  54038. private _xrNavigator;
  54039. private baseLayer;
  54040. /**
  54041. * The base reference space from which the session started. good if you want to reset your
  54042. * reference space
  54043. */
  54044. baseReferenceSpace: XRReferenceSpace;
  54045. /**
  54046. * Current XR frame
  54047. */
  54048. currentFrame: Nullable<XRFrame>;
  54049. /** WebXR timestamp updated every frame */
  54050. currentTimestamp: number;
  54051. /**
  54052. * Used just in case of a failure to initialize an immersive session.
  54053. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  54054. */
  54055. defaultHeightCompensation: number;
  54056. /**
  54057. * Fires every time a new xrFrame arrives which can be used to update the camera
  54058. */
  54059. onXRFrameObservable: Observable<XRFrame>;
  54060. /**
  54061. * Fires when the reference space changed
  54062. */
  54063. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  54064. /**
  54065. * Fires when the xr session is ended either by the device or manually done
  54066. */
  54067. onXRSessionEnded: Observable<any>;
  54068. /**
  54069. * Fires when the xr session is ended either by the device or manually done
  54070. */
  54071. onXRSessionInit: Observable<XRSession>;
  54072. /**
  54073. * Underlying xr session
  54074. */
  54075. session: XRSession;
  54076. /**
  54077. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  54078. * or get the offset the player is currently at.
  54079. */
  54080. viewerReferenceSpace: XRReferenceSpace;
  54081. /**
  54082. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  54083. * @param scene The scene which the session should be created for
  54084. */
  54085. constructor(
  54086. /** The scene which the session should be created for */
  54087. scene: Scene);
  54088. /**
  54089. * The current reference space used in this session. This reference space can constantly change!
  54090. * It is mainly used to offset the camera's position.
  54091. */
  54092. get referenceSpace(): XRReferenceSpace;
  54093. /**
  54094. * Set a new reference space and triggers the observable
  54095. */
  54096. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  54097. /**
  54098. * Disposes of the session manager
  54099. */
  54100. dispose(): void;
  54101. /**
  54102. * Stops the xrSession and restores the render loop
  54103. * @returns Promise which resolves after it exits XR
  54104. */
  54105. exitXRAsync(): Promise<void>;
  54106. /**
  54107. * Gets the correct render target texture to be rendered this frame for this eye
  54108. * @param eye the eye for which to get the render target
  54109. * @returns the render target for the specified eye
  54110. */
  54111. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  54112. /**
  54113. * Creates a WebXRRenderTarget object for the XR session
  54114. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  54115. * @param options optional options to provide when creating a new render target
  54116. * @returns a WebXR render target to which the session can render
  54117. */
  54118. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  54119. /**
  54120. * Initializes the manager
  54121. * After initialization enterXR can be called to start an XR session
  54122. * @returns Promise which resolves after it is initialized
  54123. */
  54124. initializeAsync(): Promise<void>;
  54125. /**
  54126. * Initializes an xr session
  54127. * @param xrSessionMode mode to initialize
  54128. * @param xrSessionInit defines optional and required values to pass to the session builder
  54129. * @returns a promise which will resolve once the session has been initialized
  54130. */
  54131. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  54132. /**
  54133. * Checks if a session would be supported for the creation options specified
  54134. * @param sessionMode session mode to check if supported eg. immersive-vr
  54135. * @returns A Promise that resolves to true if supported and false if not
  54136. */
  54137. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54138. /**
  54139. * Resets the reference space to the one started the session
  54140. */
  54141. resetReferenceSpace(): void;
  54142. /**
  54143. * Starts rendering to the xr layer
  54144. */
  54145. runXRRenderLoop(): void;
  54146. /**
  54147. * Sets the reference space on the xr session
  54148. * @param referenceSpaceType space to set
  54149. * @returns a promise that will resolve once the reference space has been set
  54150. */
  54151. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  54152. /**
  54153. * Updates the render state of the session
  54154. * @param state state to set
  54155. * @returns a promise that resolves once the render state has been updated
  54156. */
  54157. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  54158. /**
  54159. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  54160. * @param sessionMode defines the session to test
  54161. * @returns a promise with boolean as final value
  54162. */
  54163. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  54164. /**
  54165. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  54166. */
  54167. get isNative(): boolean;
  54168. private _createRenderTargetTexture;
  54169. }
  54170. }
  54171. declare module BABYLON {
  54172. /**
  54173. * WebXR Camera which holds the views for the xrSession
  54174. * @see https://doc.babylonjs.com/how_to/webxr_camera
  54175. */
  54176. export class WebXRCamera extends FreeCamera {
  54177. private _xrSessionManager;
  54178. private _firstFrame;
  54179. private _referenceQuaternion;
  54180. private _referencedPosition;
  54181. private _xrInvPositionCache;
  54182. private _xrInvQuaternionCache;
  54183. private _trackingState;
  54184. /**
  54185. * Observable raised before camera teleportation
  54186. */
  54187. onBeforeCameraTeleport: Observable<Vector3>;
  54188. /**
  54189. * Observable raised after camera teleportation
  54190. */
  54191. onAfterCameraTeleport: Observable<Vector3>;
  54192. /**
  54193. * Notifies when the camera's tracking state has changed.
  54194. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  54195. */
  54196. onTrackingStateChanged: Observable<WebXRTrackingState>;
  54197. /**
  54198. * Should position compensation execute on first frame.
  54199. * This is used when copying the position from a native (non XR) camera
  54200. */
  54201. compensateOnFirstFrame: boolean;
  54202. /**
  54203. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  54204. * @param name the name of the camera
  54205. * @param scene the scene to add the camera to
  54206. * @param _xrSessionManager a constructed xr session manager
  54207. */
  54208. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  54209. /**
  54210. * Get the current XR tracking state of the camera
  54211. */
  54212. get trackingState(): WebXRTrackingState;
  54213. private _setTrackingState;
  54214. /**
  54215. * Return the user's height, unrelated to the current ground.
  54216. * This will be the y position of this camera, when ground level is 0.
  54217. */
  54218. get realWorldHeight(): number;
  54219. /** @hidden */
  54220. _updateForDualEyeDebugging(): void;
  54221. /**
  54222. * Sets this camera's transformation based on a non-vr camera
  54223. * @param otherCamera the non-vr camera to copy the transformation from
  54224. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  54225. */
  54226. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  54227. /**
  54228. * Gets the current instance class name ("WebXRCamera").
  54229. * @returns the class name
  54230. */
  54231. getClassName(): string;
  54232. private _rotate180;
  54233. private _updateFromXRSession;
  54234. private _updateNumberOfRigCameras;
  54235. private _updateReferenceSpace;
  54236. private _updateReferenceSpaceOffset;
  54237. }
  54238. }
  54239. declare module BABYLON {
  54240. /**
  54241. * Defining the interface required for a (webxr) feature
  54242. */
  54243. export interface IWebXRFeature extends IDisposable {
  54244. /**
  54245. * Is this feature attached
  54246. */
  54247. attached: boolean;
  54248. /**
  54249. * Should auto-attach be disabled?
  54250. */
  54251. disableAutoAttach: boolean;
  54252. /**
  54253. * Attach the feature to the session
  54254. * Will usually be called by the features manager
  54255. *
  54256. * @param force should attachment be forced (even when already attached)
  54257. * @returns true if successful.
  54258. */
  54259. attach(force?: boolean): boolean;
  54260. /**
  54261. * Detach the feature from the session
  54262. * Will usually be called by the features manager
  54263. *
  54264. * @returns true if successful.
  54265. */
  54266. detach(): boolean;
  54267. /**
  54268. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54269. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54270. *
  54271. * @returns whether or not the feature is compatible in this environment
  54272. */
  54273. isCompatible(): boolean;
  54274. /**
  54275. * Was this feature disposed;
  54276. */
  54277. isDisposed: boolean;
  54278. /**
  54279. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  54280. */
  54281. xrNativeFeatureName?: string;
  54282. /**
  54283. * A list of (Babylon WebXR) features this feature depends on
  54284. */
  54285. dependsOn?: string[];
  54286. /**
  54287. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  54288. */
  54289. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  54290. }
  54291. /**
  54292. * A list of the currently available features without referencing them
  54293. */
  54294. export class WebXRFeatureName {
  54295. /**
  54296. * The name of the anchor system feature
  54297. */
  54298. static readonly ANCHOR_SYSTEM: string;
  54299. /**
  54300. * The name of the background remover feature
  54301. */
  54302. static readonly BACKGROUND_REMOVER: string;
  54303. /**
  54304. * The name of the hit test feature
  54305. */
  54306. static readonly HIT_TEST: string;
  54307. /**
  54308. * The name of the mesh detection feature
  54309. */
  54310. static readonly MESH_DETECTION: string;
  54311. /**
  54312. * physics impostors for xr controllers feature
  54313. */
  54314. static readonly PHYSICS_CONTROLLERS: string;
  54315. /**
  54316. * The name of the plane detection feature
  54317. */
  54318. static readonly PLANE_DETECTION: string;
  54319. /**
  54320. * The name of the pointer selection feature
  54321. */
  54322. static readonly POINTER_SELECTION: string;
  54323. /**
  54324. * The name of the teleportation feature
  54325. */
  54326. static readonly TELEPORTATION: string;
  54327. /**
  54328. * The name of the feature points feature.
  54329. */
  54330. static readonly FEATURE_POINTS: string;
  54331. /**
  54332. * The name of the hand tracking feature.
  54333. */
  54334. static readonly HAND_TRACKING: string;
  54335. /**
  54336. * The name of the image tracking feature
  54337. */
  54338. static readonly IMAGE_TRACKING: string;
  54339. }
  54340. /**
  54341. * Defining the constructor of a feature. Used to register the modules.
  54342. */
  54343. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  54344. /**
  54345. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  54346. * It is mainly used in AR sessions.
  54347. *
  54348. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  54349. */
  54350. export class WebXRFeaturesManager implements IDisposable {
  54351. private _xrSessionManager;
  54352. private static readonly _AvailableFeatures;
  54353. private _features;
  54354. /**
  54355. * constructs a new features manages.
  54356. *
  54357. * @param _xrSessionManager an instance of WebXRSessionManager
  54358. */
  54359. constructor(_xrSessionManager: WebXRSessionManager);
  54360. /**
  54361. * Used to register a module. After calling this function a developer can use this feature in the scene.
  54362. * Mainly used internally.
  54363. *
  54364. * @param featureName the name of the feature to register
  54365. * @param constructorFunction the function used to construct the module
  54366. * @param version the (babylon) version of the module
  54367. * @param stable is that a stable version of this module
  54368. */
  54369. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  54370. /**
  54371. * Returns a constructor of a specific feature.
  54372. *
  54373. * @param featureName the name of the feature to construct
  54374. * @param version the version of the feature to load
  54375. * @param xrSessionManager the xrSessionManager. Used to construct the module
  54376. * @param options optional options provided to the module.
  54377. * @returns a function that, when called, will return a new instance of this feature
  54378. */
  54379. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  54380. /**
  54381. * Can be used to return the list of features currently registered
  54382. *
  54383. * @returns an Array of available features
  54384. */
  54385. static GetAvailableFeatures(): string[];
  54386. /**
  54387. * Gets the versions available for a specific feature
  54388. * @param featureName the name of the feature
  54389. * @returns an array with the available versions
  54390. */
  54391. static GetAvailableVersions(featureName: string): string[];
  54392. /**
  54393. * Return the latest unstable version of this feature
  54394. * @param featureName the name of the feature to search
  54395. * @returns the version number. if not found will return -1
  54396. */
  54397. static GetLatestVersionOfFeature(featureName: string): number;
  54398. /**
  54399. * Return the latest stable version of this feature
  54400. * @param featureName the name of the feature to search
  54401. * @returns the version number. if not found will return -1
  54402. */
  54403. static GetStableVersionOfFeature(featureName: string): number;
  54404. /**
  54405. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  54406. * Can be used during a session to start a feature
  54407. * @param featureName the name of feature to attach
  54408. */
  54409. attachFeature(featureName: string): void;
  54410. /**
  54411. * Can be used inside a session or when the session ends to detach a specific feature
  54412. * @param featureName the name of the feature to detach
  54413. */
  54414. detachFeature(featureName: string): void;
  54415. /**
  54416. * Used to disable an already-enabled feature
  54417. * The feature will be disposed and will be recreated once enabled.
  54418. * @param featureName the feature to disable
  54419. * @returns true if disable was successful
  54420. */
  54421. disableFeature(featureName: string | {
  54422. Name: string;
  54423. }): boolean;
  54424. /**
  54425. * dispose this features manager
  54426. */
  54427. dispose(): void;
  54428. /**
  54429. * 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.
  54430. * 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.
  54431. *
  54432. * @param featureName the name of the feature to load or the class of the feature
  54433. * @param version optional version to load. if not provided the latest version will be enabled
  54434. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  54435. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  54436. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  54437. * @returns a new constructed feature or throws an error if feature not found.
  54438. */
  54439. enableFeature(featureName: string | {
  54440. Name: string;
  54441. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  54442. /**
  54443. * get the implementation of an enabled feature.
  54444. * @param featureName the name of the feature to load
  54445. * @returns the feature class, if found
  54446. */
  54447. getEnabledFeature(featureName: string): IWebXRFeature;
  54448. /**
  54449. * Get the list of enabled features
  54450. * @returns an array of enabled features
  54451. */
  54452. getEnabledFeatures(): string[];
  54453. /**
  54454. * This function will extend the session creation configuration object with enabled features.
  54455. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  54456. * according to the defined "required" variable, provided during enableFeature call
  54457. * @param xrSessionInit the xr Session init object to extend
  54458. *
  54459. * @returns an extended XRSessionInit object
  54460. */
  54461. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  54462. }
  54463. }
  54464. declare module BABYLON {
  54465. /**
  54466. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  54467. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  54468. */
  54469. export class WebXRExperienceHelper implements IDisposable {
  54470. private scene;
  54471. private _nonVRCamera;
  54472. private _originalSceneAutoClear;
  54473. private _supported;
  54474. /**
  54475. * Camera used to render xr content
  54476. */
  54477. camera: WebXRCamera;
  54478. /** A features manager for this xr session */
  54479. featuresManager: WebXRFeaturesManager;
  54480. /**
  54481. * Observers registered here will be triggered after the camera's initial transformation is set
  54482. * This can be used to set a different ground level or an extra rotation.
  54483. *
  54484. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  54485. * to the position set after this observable is done executing.
  54486. */
  54487. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  54488. /**
  54489. * Fires when the state of the experience helper has changed
  54490. */
  54491. onStateChangedObservable: Observable<WebXRState>;
  54492. /** Session manager used to keep track of xr session */
  54493. sessionManager: WebXRSessionManager;
  54494. /**
  54495. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  54496. */
  54497. state: WebXRState;
  54498. /**
  54499. * Creates a WebXRExperienceHelper
  54500. * @param scene The scene the helper should be created in
  54501. */
  54502. private constructor();
  54503. /**
  54504. * Creates the experience helper
  54505. * @param scene the scene to attach the experience helper to
  54506. * @returns a promise for the experience helper
  54507. */
  54508. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  54509. /**
  54510. * Disposes of the experience helper
  54511. */
  54512. dispose(): void;
  54513. /**
  54514. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  54515. * @param sessionMode options for the XR session
  54516. * @param referenceSpaceType frame of reference of the XR session
  54517. * @param renderTarget the output canvas that will be used to enter XR mode
  54518. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  54519. * @returns promise that resolves after xr mode has entered
  54520. */
  54521. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  54522. /**
  54523. * Exits XR mode and returns the scene to its original state
  54524. * @returns promise that resolves after xr mode has exited
  54525. */
  54526. exitXRAsync(): Promise<void>;
  54527. private _nonXRToXRCamera;
  54528. private _setState;
  54529. }
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * X-Y values for axes in WebXR
  54534. */
  54535. export interface IWebXRMotionControllerAxesValue {
  54536. /**
  54537. * The value of the x axis
  54538. */
  54539. x: number;
  54540. /**
  54541. * The value of the y-axis
  54542. */
  54543. y: number;
  54544. }
  54545. /**
  54546. * changed / previous values for the values of this component
  54547. */
  54548. export interface IWebXRMotionControllerComponentChangesValues<T> {
  54549. /**
  54550. * current (this frame) value
  54551. */
  54552. current: T;
  54553. /**
  54554. * previous (last change) value
  54555. */
  54556. previous: T;
  54557. }
  54558. /**
  54559. * Represents changes in the component between current frame and last values recorded
  54560. */
  54561. export interface IWebXRMotionControllerComponentChanges {
  54562. /**
  54563. * will be populated with previous and current values if axes changed
  54564. */
  54565. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  54566. /**
  54567. * will be populated with previous and current values if pressed changed
  54568. */
  54569. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54570. /**
  54571. * will be populated with previous and current values if touched changed
  54572. */
  54573. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  54574. /**
  54575. * will be populated with previous and current values if value changed
  54576. */
  54577. value?: IWebXRMotionControllerComponentChangesValues<number>;
  54578. }
  54579. /**
  54580. * This class represents a single component (for example button or thumbstick) of a motion controller
  54581. */
  54582. export class WebXRControllerComponent implements IDisposable {
  54583. /**
  54584. * the id of this component
  54585. */
  54586. id: string;
  54587. /**
  54588. * the type of the component
  54589. */
  54590. type: MotionControllerComponentType;
  54591. private _buttonIndex;
  54592. private _axesIndices;
  54593. private _axes;
  54594. private _changes;
  54595. private _currentValue;
  54596. private _hasChanges;
  54597. private _pressed;
  54598. private _touched;
  54599. /**
  54600. * button component type
  54601. */
  54602. static BUTTON_TYPE: MotionControllerComponentType;
  54603. /**
  54604. * squeeze component type
  54605. */
  54606. static SQUEEZE_TYPE: MotionControllerComponentType;
  54607. /**
  54608. * Thumbstick component type
  54609. */
  54610. static THUMBSTICK_TYPE: MotionControllerComponentType;
  54611. /**
  54612. * Touchpad component type
  54613. */
  54614. static TOUCHPAD_TYPE: MotionControllerComponentType;
  54615. /**
  54616. * trigger component type
  54617. */
  54618. static TRIGGER_TYPE: MotionControllerComponentType;
  54619. /**
  54620. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  54621. * the axes data changes
  54622. */
  54623. onAxisValueChangedObservable: Observable<{
  54624. x: number;
  54625. y: number;
  54626. }>;
  54627. /**
  54628. * Observers registered here will be triggered when the state of a button changes
  54629. * State change is either pressed / touched / value
  54630. */
  54631. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  54632. /**
  54633. * Creates a new component for a motion controller.
  54634. * It is created by the motion controller itself
  54635. *
  54636. * @param id the id of this component
  54637. * @param type the type of the component
  54638. * @param _buttonIndex index in the buttons array of the gamepad
  54639. * @param _axesIndices indices of the values in the axes array of the gamepad
  54640. */
  54641. constructor(
  54642. /**
  54643. * the id of this component
  54644. */
  54645. id: string,
  54646. /**
  54647. * the type of the component
  54648. */
  54649. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  54650. /**
  54651. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  54652. */
  54653. get axes(): IWebXRMotionControllerAxesValue;
  54654. /**
  54655. * Get the changes. Elements will be populated only if they changed with their previous and current value
  54656. */
  54657. get changes(): IWebXRMotionControllerComponentChanges;
  54658. /**
  54659. * Return whether or not the component changed the last frame
  54660. */
  54661. get hasChanges(): boolean;
  54662. /**
  54663. * is the button currently pressed
  54664. */
  54665. get pressed(): boolean;
  54666. /**
  54667. * is the button currently touched
  54668. */
  54669. get touched(): boolean;
  54670. /**
  54671. * Get the current value of this component
  54672. */
  54673. get value(): number;
  54674. /**
  54675. * Dispose this component
  54676. */
  54677. dispose(): void;
  54678. /**
  54679. * Are there axes correlating to this component
  54680. * @return true is axes data is available
  54681. */
  54682. isAxes(): boolean;
  54683. /**
  54684. * Is this component a button (hence - pressable)
  54685. * @returns true if can be pressed
  54686. */
  54687. isButton(): boolean;
  54688. /**
  54689. * update this component using the gamepad object it is in. Called on every frame
  54690. * @param nativeController the native gamepad controller object
  54691. */
  54692. update(nativeController: IMinimalMotionControllerObject): void;
  54693. }
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * Type used for the success callback of ImportMesh
  54698. */
  54699. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54700. /**
  54701. * Interface used for the result of ImportMeshAsync
  54702. */
  54703. export interface ISceneLoaderAsyncResult {
  54704. /**
  54705. * The array of loaded meshes
  54706. */
  54707. readonly meshes: AbstractMesh[];
  54708. /**
  54709. * The array of loaded particle systems
  54710. */
  54711. readonly particleSystems: IParticleSystem[];
  54712. /**
  54713. * The array of loaded skeletons
  54714. */
  54715. readonly skeletons: Skeleton[];
  54716. /**
  54717. * The array of loaded animation groups
  54718. */
  54719. readonly animationGroups: AnimationGroup[];
  54720. /**
  54721. * The array of loaded transform nodes
  54722. */
  54723. readonly transformNodes: TransformNode[];
  54724. /**
  54725. * The array of loaded geometries
  54726. */
  54727. readonly geometries: Geometry[];
  54728. /**
  54729. * The array of loaded lights
  54730. */
  54731. readonly lights: Light[];
  54732. }
  54733. /**
  54734. * Interface used to represent data loading progression
  54735. */
  54736. export interface ISceneLoaderProgressEvent {
  54737. /**
  54738. * Defines if data length to load can be evaluated
  54739. */
  54740. readonly lengthComputable: boolean;
  54741. /**
  54742. * Defines the loaded data length
  54743. */
  54744. readonly loaded: number;
  54745. /**
  54746. * Defines the data length to load
  54747. */
  54748. readonly total: number;
  54749. }
  54750. /**
  54751. * Interface used by SceneLoader plugins to define supported file extensions
  54752. */
  54753. export interface ISceneLoaderPluginExtensions {
  54754. /**
  54755. * Defines the list of supported extensions
  54756. */
  54757. [extension: string]: {
  54758. isBinary: boolean;
  54759. };
  54760. }
  54761. /**
  54762. * Interface used by SceneLoader plugin factory
  54763. */
  54764. export interface ISceneLoaderPluginFactory {
  54765. /**
  54766. * Defines the name of the factory
  54767. */
  54768. name: string;
  54769. /**
  54770. * Function called to create a new plugin
  54771. * @return the new plugin
  54772. */
  54773. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54774. /**
  54775. * The callback that returns true if the data can be directly loaded.
  54776. * @param data string containing the file data
  54777. * @returns if the data can be loaded directly
  54778. */
  54779. canDirectLoad?(data: string): boolean;
  54780. }
  54781. /**
  54782. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54783. */
  54784. export interface ISceneLoaderPluginBase {
  54785. /**
  54786. * The friendly name of this plugin.
  54787. */
  54788. name: string;
  54789. /**
  54790. * The file extensions supported by this plugin.
  54791. */
  54792. extensions: string | ISceneLoaderPluginExtensions;
  54793. /**
  54794. * The callback called when loading from a url.
  54795. * @param scene scene loading this url
  54796. * @param url url to load
  54797. * @param onSuccess callback called when the file successfully loads
  54798. * @param onProgress callback called while file is loading (if the server supports this mode)
  54799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54800. * @param onError callback called when the file fails to load
  54801. * @returns a file request object
  54802. */
  54803. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54804. /**
  54805. * The callback called when loading from a file object.
  54806. * @param scene scene loading this file
  54807. * @param file defines the file to load
  54808. * @param onSuccess defines the callback to call when data is loaded
  54809. * @param onProgress defines the callback to call during loading process
  54810. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54811. * @param onError defines the callback to call when an error occurs
  54812. * @returns a file request object
  54813. */
  54814. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54815. /**
  54816. * The callback that returns true if the data can be directly loaded.
  54817. * @param data string containing the file data
  54818. * @returns if the data can be loaded directly
  54819. */
  54820. canDirectLoad?(data: string): boolean;
  54821. /**
  54822. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54823. * @param scene scene loading this data
  54824. * @param data string containing the data
  54825. * @returns data to pass to the plugin
  54826. */
  54827. directLoad?(scene: Scene, data: string): any;
  54828. /**
  54829. * The callback that allows custom handling of the root url based on the response url.
  54830. * @param rootUrl the original root url
  54831. * @param responseURL the response url if available
  54832. * @returns the new root url
  54833. */
  54834. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54835. }
  54836. /**
  54837. * Interface used to define a SceneLoader plugin
  54838. */
  54839. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54840. /**
  54841. * Import meshes into a scene.
  54842. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54843. * @param scene The scene to import into
  54844. * @param data The data to import
  54845. * @param rootUrl The root url for scene and resources
  54846. * @param meshes The meshes array to import into
  54847. * @param particleSystems The particle systems array to import into
  54848. * @param skeletons The skeletons array to import into
  54849. * @param onError The callback when import fails
  54850. * @returns True if successful or false otherwise
  54851. */
  54852. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54853. /**
  54854. * Load into a scene.
  54855. * @param scene The scene to load into
  54856. * @param data The data to import
  54857. * @param rootUrl The root url for scene and resources
  54858. * @param onError The callback when import fails
  54859. * @returns True if successful or false otherwise
  54860. */
  54861. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54862. /**
  54863. * Load into an asset container.
  54864. * @param scene The scene to load into
  54865. * @param data The data to import
  54866. * @param rootUrl The root url for scene and resources
  54867. * @param onError The callback when import fails
  54868. * @returns The loaded asset container
  54869. */
  54870. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54871. }
  54872. /**
  54873. * Interface used to define an async SceneLoader plugin
  54874. */
  54875. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54876. /**
  54877. * Import meshes into a scene.
  54878. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54879. * @param scene The scene to import into
  54880. * @param data The data to import
  54881. * @param rootUrl The root url for scene and resources
  54882. * @param onProgress The callback when the load progresses
  54883. * @param fileName Defines the name of the file to load
  54884. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54885. */
  54886. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54887. /**
  54888. * Load into a scene.
  54889. * @param scene The scene to load into
  54890. * @param data The data to import
  54891. * @param rootUrl The root url for scene and resources
  54892. * @param onProgress The callback when the load progresses
  54893. * @param fileName Defines the name of the file to load
  54894. * @returns Nothing
  54895. */
  54896. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54897. /**
  54898. * Load into an asset container.
  54899. * @param scene The scene to load into
  54900. * @param data The data to import
  54901. * @param rootUrl The root url for scene and resources
  54902. * @param onProgress The callback when the load progresses
  54903. * @param fileName Defines the name of the file to load
  54904. * @returns The loaded asset container
  54905. */
  54906. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54907. }
  54908. /**
  54909. * Mode that determines how to handle old animation groups before loading new ones.
  54910. */
  54911. export enum SceneLoaderAnimationGroupLoadingMode {
  54912. /**
  54913. * Reset all old animations to initial state then dispose them.
  54914. */
  54915. Clean = 0,
  54916. /**
  54917. * Stop all old animations.
  54918. */
  54919. Stop = 1,
  54920. /**
  54921. * Restart old animations from first frame.
  54922. */
  54923. Sync = 2,
  54924. /**
  54925. * Old animations remains untouched.
  54926. */
  54927. NoSync = 3
  54928. }
  54929. /**
  54930. * Defines a plugin registered by the SceneLoader
  54931. */
  54932. interface IRegisteredPlugin {
  54933. /**
  54934. * Defines the plugin to use
  54935. */
  54936. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54937. /**
  54938. * Defines if the plugin supports binary data
  54939. */
  54940. isBinary: boolean;
  54941. }
  54942. /**
  54943. * Class used to load scene from various file formats using registered plugins
  54944. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54945. */
  54946. export class SceneLoader {
  54947. /**
  54948. * No logging while loading
  54949. */
  54950. static readonly NO_LOGGING: number;
  54951. /**
  54952. * Minimal logging while loading
  54953. */
  54954. static readonly MINIMAL_LOGGING: number;
  54955. /**
  54956. * Summary logging while loading
  54957. */
  54958. static readonly SUMMARY_LOGGING: number;
  54959. /**
  54960. * Detailed logging while loading
  54961. */
  54962. static readonly DETAILED_LOGGING: number;
  54963. /**
  54964. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54965. */
  54966. static get ForceFullSceneLoadingForIncremental(): boolean;
  54967. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54968. /**
  54969. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54970. */
  54971. static get ShowLoadingScreen(): boolean;
  54972. static set ShowLoadingScreen(value: boolean);
  54973. /**
  54974. * Defines the current logging level (while loading the scene)
  54975. * @ignorenaming
  54976. */
  54977. static get loggingLevel(): number;
  54978. static set loggingLevel(value: number);
  54979. /**
  54980. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54981. */
  54982. static get CleanBoneMatrixWeights(): boolean;
  54983. static set CleanBoneMatrixWeights(value: boolean);
  54984. /**
  54985. * Event raised when a plugin is used to load a scene
  54986. */
  54987. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54988. private static _registeredPlugins;
  54989. private static _showingLoadingScreen;
  54990. /**
  54991. * Gets the default plugin (used to load Babylon files)
  54992. * @returns the .babylon plugin
  54993. */
  54994. static GetDefaultPlugin(): IRegisteredPlugin;
  54995. private static _GetPluginForExtension;
  54996. private static _GetPluginForDirectLoad;
  54997. private static _GetPluginForFilename;
  54998. private static _GetDirectLoad;
  54999. private static _LoadData;
  55000. private static _GetFileInfo;
  55001. /**
  55002. * Gets a plugin that can load the given extension
  55003. * @param extension defines the extension to load
  55004. * @returns a plugin or null if none works
  55005. */
  55006. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  55007. /**
  55008. * Gets a boolean indicating that the given extension can be loaded
  55009. * @param extension defines the extension to load
  55010. * @returns true if the extension is supported
  55011. */
  55012. static IsPluginForExtensionAvailable(extension: string): boolean;
  55013. /**
  55014. * Adds a new plugin to the list of registered plugins
  55015. * @param plugin defines the plugin to add
  55016. */
  55017. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  55018. /**
  55019. * Import meshes into a scene
  55020. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55021. * @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)
  55022. * @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)
  55023. * @param scene the instance of BABYLON.Scene to append to
  55024. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  55025. * @param onProgress a callback with a progress event for each file being loaded
  55026. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55027. * @param pluginExtension the extension used to determine the plugin
  55028. * @returns The loaded plugin
  55029. */
  55030. 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>;
  55031. /**
  55032. * Import meshes into a scene
  55033. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  55034. * @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)
  55035. * @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)
  55036. * @param scene the instance of BABYLON.Scene to append to
  55037. * @param onProgress a callback with a progress event for each file being loaded
  55038. * @param pluginExtension the extension used to determine the plugin
  55039. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  55040. */
  55041. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  55042. /**
  55043. * Load a scene
  55044. * @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)
  55045. * @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)
  55046. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55047. * @param onSuccess a callback with the scene when import succeeds
  55048. * @param onProgress a callback with a progress event for each file being loaded
  55049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55050. * @param pluginExtension the extension used to determine the plugin
  55051. * @returns The loaded plugin
  55052. */
  55053. 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>;
  55054. /**
  55055. * Load a scene
  55056. * @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)
  55057. * @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)
  55058. * @param engine is the instance of BABYLON.Engine to use to create the scene
  55059. * @param onProgress a callback with a progress event for each file being loaded
  55060. * @param pluginExtension the extension used to determine the plugin
  55061. * @returns The loaded scene
  55062. */
  55063. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55064. /**
  55065. * Append a scene
  55066. * @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)
  55067. * @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)
  55068. * @param scene is the instance of BABYLON.Scene to append to
  55069. * @param onSuccess a callback with the scene when import succeeds
  55070. * @param onProgress a callback with a progress event for each file being loaded
  55071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55072. * @param pluginExtension the extension used to determine the plugin
  55073. * @returns The loaded plugin
  55074. */
  55075. 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>;
  55076. /**
  55077. * Append a scene
  55078. * @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)
  55079. * @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)
  55080. * @param scene is the instance of BABYLON.Scene to append to
  55081. * @param onProgress a callback with a progress event for each file being loaded
  55082. * @param pluginExtension the extension used to determine the plugin
  55083. * @returns The given scene
  55084. */
  55085. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  55086. /**
  55087. * Load a scene into an asset container
  55088. * @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)
  55089. * @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)
  55090. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55091. * @param onSuccess a callback with the scene when import succeeds
  55092. * @param onProgress a callback with a progress event for each file being loaded
  55093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55094. * @param pluginExtension the extension used to determine the plugin
  55095. * @returns The loaded plugin
  55096. */
  55097. 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>;
  55098. /**
  55099. * Load a scene into an asset container
  55100. * @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)
  55101. * @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)
  55102. * @param scene is the instance of Scene to append to
  55103. * @param onProgress a callback with a progress event for each file being loaded
  55104. * @param pluginExtension the extension used to determine the plugin
  55105. * @returns The loaded asset container
  55106. */
  55107. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  55108. /**
  55109. * Import animations from a file into a scene
  55110. * @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)
  55111. * @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)
  55112. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55113. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55114. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55115. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55116. * @param onSuccess a callback with the scene when import succeeds
  55117. * @param onProgress a callback with a progress event for each file being loaded
  55118. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55119. * @param pluginExtension the extension used to determine the plugin
  55120. */
  55121. 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;
  55122. /**
  55123. * Import animations from a file into a scene
  55124. * @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)
  55125. * @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)
  55126. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  55127. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  55128. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  55129. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  55130. * @param onSuccess a callback with the scene when import succeeds
  55131. * @param onProgress a callback with a progress event for each file being loaded
  55132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  55133. * @param pluginExtension the extension used to determine the plugin
  55134. * @returns the updated scene with imported animations
  55135. */
  55136. 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>;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /**
  55141. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  55142. */
  55143. export type MotionControllerHandedness = "none" | "left" | "right";
  55144. /**
  55145. * The type of components available in motion controllers.
  55146. * This is not the name of the component.
  55147. */
  55148. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  55149. /**
  55150. * The state of a controller component
  55151. */
  55152. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  55153. /**
  55154. * The schema of motion controller layout.
  55155. * No object will be initialized using this interface
  55156. * This is used just to define the profile.
  55157. */
  55158. export interface IMotionControllerLayout {
  55159. /**
  55160. * Path to load the assets. Usually relative to the base path
  55161. */
  55162. assetPath: string;
  55163. /**
  55164. * Available components (unsorted)
  55165. */
  55166. components: {
  55167. /**
  55168. * A map of component Ids
  55169. */
  55170. [componentId: string]: {
  55171. /**
  55172. * The type of input the component outputs
  55173. */
  55174. type: MotionControllerComponentType;
  55175. /**
  55176. * The indices of this component in the gamepad object
  55177. */
  55178. gamepadIndices: {
  55179. /**
  55180. * Index of button
  55181. */
  55182. button?: number;
  55183. /**
  55184. * If available, index of x-axis
  55185. */
  55186. xAxis?: number;
  55187. /**
  55188. * If available, index of y-axis
  55189. */
  55190. yAxis?: number;
  55191. };
  55192. /**
  55193. * The mesh's root node name
  55194. */
  55195. rootNodeName: string;
  55196. /**
  55197. * Animation definitions for this model
  55198. */
  55199. visualResponses: {
  55200. [stateKey: string]: {
  55201. /**
  55202. * What property will be animated
  55203. */
  55204. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  55205. /**
  55206. * What states influence this visual response
  55207. */
  55208. states: MotionControllerComponentStateType[];
  55209. /**
  55210. * Type of animation - movement or visibility
  55211. */
  55212. valueNodeProperty: "transform" | "visibility";
  55213. /**
  55214. * Base node name to move. Its position will be calculated according to the min and max nodes
  55215. */
  55216. valueNodeName?: string;
  55217. /**
  55218. * Minimum movement node
  55219. */
  55220. minNodeName?: string;
  55221. /**
  55222. * Max movement node
  55223. */
  55224. maxNodeName?: string;
  55225. };
  55226. };
  55227. /**
  55228. * If touch enabled, what is the name of node to display user feedback
  55229. */
  55230. touchPointNodeName?: string;
  55231. };
  55232. };
  55233. /**
  55234. * Is it xr standard mapping or not
  55235. */
  55236. gamepadMapping: "" | "xr-standard";
  55237. /**
  55238. * Base root node of this entire model
  55239. */
  55240. rootNodeName: string;
  55241. /**
  55242. * Defines the main button component id
  55243. */
  55244. selectComponentId: string;
  55245. }
  55246. /**
  55247. * A definition for the layout map in the input profile
  55248. */
  55249. export interface IMotionControllerLayoutMap {
  55250. /**
  55251. * Layouts with handedness type as a key
  55252. */
  55253. [handedness: string]: IMotionControllerLayout;
  55254. }
  55255. /**
  55256. * The XR Input profile schema
  55257. * Profiles can be found here:
  55258. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  55259. */
  55260. export interface IMotionControllerProfile {
  55261. /**
  55262. * fallback profiles for this profileId
  55263. */
  55264. fallbackProfileIds: string[];
  55265. /**
  55266. * The layout map, with handedness as key
  55267. */
  55268. layouts: IMotionControllerLayoutMap;
  55269. /**
  55270. * The id of this profile
  55271. * correlates to the profile(s) in the xrInput.profiles array
  55272. */
  55273. profileId: string;
  55274. }
  55275. /**
  55276. * A helper-interface for the 3 meshes needed for controller button animation
  55277. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  55278. */
  55279. export interface IMotionControllerButtonMeshMap {
  55280. /**
  55281. * the mesh that defines the pressed value mesh position.
  55282. * This is used to find the max-position of this button
  55283. */
  55284. pressedMesh: AbstractMesh;
  55285. /**
  55286. * the mesh that defines the unpressed value mesh position.
  55287. * This is used to find the min (or initial) position of this button
  55288. */
  55289. unpressedMesh: AbstractMesh;
  55290. /**
  55291. * The mesh that will be changed when value changes
  55292. */
  55293. valueMesh: AbstractMesh;
  55294. }
  55295. /**
  55296. * A helper-interface for the 3 meshes needed for controller axis animation.
  55297. * This will be expanded when touchpad animations are fully supported
  55298. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  55299. */
  55300. export interface IMotionControllerMeshMap {
  55301. /**
  55302. * the mesh that defines the maximum value mesh position.
  55303. */
  55304. maxMesh?: AbstractMesh;
  55305. /**
  55306. * the mesh that defines the minimum value mesh position.
  55307. */
  55308. minMesh?: AbstractMesh;
  55309. /**
  55310. * The mesh that will be changed when axis value changes
  55311. */
  55312. valueMesh?: AbstractMesh;
  55313. }
  55314. /**
  55315. * The elements needed for change-detection of the gamepad objects in motion controllers
  55316. */
  55317. export interface IMinimalMotionControllerObject {
  55318. /**
  55319. * Available axes of this controller
  55320. */
  55321. axes: number[];
  55322. /**
  55323. * An array of available buttons
  55324. */
  55325. buttons: Array<{
  55326. /**
  55327. * Value of the button/trigger
  55328. */
  55329. value: number;
  55330. /**
  55331. * If the button/trigger is currently touched
  55332. */
  55333. touched: boolean;
  55334. /**
  55335. * If the button/trigger is currently pressed
  55336. */
  55337. pressed: boolean;
  55338. }>;
  55339. /**
  55340. * EXPERIMENTAL haptic support.
  55341. */
  55342. hapticActuators?: Array<{
  55343. pulse: (value: number, duration: number) => Promise<boolean>;
  55344. }>;
  55345. }
  55346. /**
  55347. * An Abstract Motion controller
  55348. * This class receives an xrInput and a profile layout and uses those to initialize the components
  55349. * Each component has an observable to check for changes in value and state
  55350. */
  55351. export abstract class WebXRAbstractMotionController implements IDisposable {
  55352. protected scene: Scene;
  55353. protected layout: IMotionControllerLayout;
  55354. /**
  55355. * The gamepad object correlating to this controller
  55356. */
  55357. gamepadObject: IMinimalMotionControllerObject;
  55358. /**
  55359. * handedness (left/right/none) of this controller
  55360. */
  55361. handedness: MotionControllerHandedness;
  55362. private _initComponent;
  55363. private _modelReady;
  55364. /**
  55365. * A map of components (WebXRControllerComponent) in this motion controller
  55366. * Components have a ComponentType and can also have both button and axis definitions
  55367. */
  55368. readonly components: {
  55369. [id: string]: WebXRControllerComponent;
  55370. };
  55371. /**
  55372. * Disable the model's animation. Can be set at any time.
  55373. */
  55374. disableAnimation: boolean;
  55375. /**
  55376. * Observers registered here will be triggered when the model of this controller is done loading
  55377. */
  55378. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  55379. /**
  55380. * The profile id of this motion controller
  55381. */
  55382. abstract profileId: string;
  55383. /**
  55384. * The root mesh of the model. It is null if the model was not yet initialized
  55385. */
  55386. rootMesh: Nullable<AbstractMesh>;
  55387. /**
  55388. * constructs a new abstract motion controller
  55389. * @param scene the scene to which the model of the controller will be added
  55390. * @param layout The profile layout to load
  55391. * @param gamepadObject The gamepad object correlating to this controller
  55392. * @param handedness handedness (left/right/none) of this controller
  55393. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  55394. */
  55395. constructor(scene: Scene, layout: IMotionControllerLayout,
  55396. /**
  55397. * The gamepad object correlating to this controller
  55398. */
  55399. gamepadObject: IMinimalMotionControllerObject,
  55400. /**
  55401. * handedness (left/right/none) of this controller
  55402. */
  55403. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  55404. /**
  55405. * Dispose this controller, the model mesh and all its components
  55406. */
  55407. dispose(): void;
  55408. /**
  55409. * Returns all components of specific type
  55410. * @param type the type to search for
  55411. * @return an array of components with this type
  55412. */
  55413. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  55414. /**
  55415. * get a component based an its component id as defined in layout.components
  55416. * @param id the id of the component
  55417. * @returns the component correlates to the id or undefined if not found
  55418. */
  55419. getComponent(id: string): WebXRControllerComponent;
  55420. /**
  55421. * Get the list of components available in this motion controller
  55422. * @returns an array of strings correlating to available components
  55423. */
  55424. getComponentIds(): string[];
  55425. /**
  55426. * Get the first component of specific type
  55427. * @param type type of component to find
  55428. * @return a controller component or null if not found
  55429. */
  55430. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  55431. /**
  55432. * Get the main (Select) component of this controller as defined in the layout
  55433. * @returns the main component of this controller
  55434. */
  55435. getMainComponent(): WebXRControllerComponent;
  55436. /**
  55437. * Loads the model correlating to this controller
  55438. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  55439. * @returns A promise fulfilled with the result of the model loading
  55440. */
  55441. loadModel(): Promise<boolean>;
  55442. /**
  55443. * Update this model using the current XRFrame
  55444. * @param xrFrame the current xr frame to use and update the model
  55445. */
  55446. updateFromXRFrame(xrFrame: XRFrame): void;
  55447. /**
  55448. * Backwards compatibility due to a deeply-integrated typo
  55449. */
  55450. get handness(): XREye;
  55451. /**
  55452. * Pulse (vibrate) this controller
  55453. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  55454. * Consecutive calls to this function will cancel the last pulse call
  55455. *
  55456. * @param value the strength of the pulse in 0.0...1.0 range
  55457. * @param duration Duration of the pulse in milliseconds
  55458. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  55459. * @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
  55460. */
  55461. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  55462. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55463. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  55464. /**
  55465. * Moves the axis on the controller mesh based on its current state
  55466. * @param axis the index of the axis
  55467. * @param axisValue the value of the axis which determines the meshes new position
  55468. * @hidden
  55469. */
  55470. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  55471. /**
  55472. * Update the model itself with the current frame data
  55473. * @param xrFrame the frame to use for updating the model mesh
  55474. */
  55475. protected updateModel(xrFrame: XRFrame): void;
  55476. /**
  55477. * Get the filename and path for this controller's model
  55478. * @returns a map of filename and path
  55479. */
  55480. protected abstract _getFilenameAndPath(): {
  55481. filename: string;
  55482. path: string;
  55483. };
  55484. /**
  55485. * This function is called before the mesh is loaded. It checks for loading constraints.
  55486. * For example, this function can check if the GLB loader is available
  55487. * If this function returns false, the generic controller will be loaded instead
  55488. * @returns Is the client ready to load the mesh
  55489. */
  55490. protected abstract _getModelLoadingConstraints(): boolean;
  55491. /**
  55492. * This function will be called after the model was successfully loaded and can be used
  55493. * for mesh transformations before it is available for the user
  55494. * @param meshes the loaded meshes
  55495. */
  55496. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  55497. /**
  55498. * Set the root mesh for this controller. Important for the WebXR controller class
  55499. * @param meshes the loaded meshes
  55500. */
  55501. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  55502. /**
  55503. * A function executed each frame that updates the mesh (if needed)
  55504. * @param xrFrame the current xrFrame
  55505. */
  55506. protected abstract _updateModel(xrFrame: XRFrame): void;
  55507. private _getGenericFilenameAndPath;
  55508. private _getGenericParentMesh;
  55509. }
  55510. }
  55511. declare module BABYLON {
  55512. /**
  55513. * A generic trigger-only motion controller for WebXR
  55514. */
  55515. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  55516. /**
  55517. * Static version of the profile id of this controller
  55518. */
  55519. static ProfileId: string;
  55520. profileId: string;
  55521. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  55522. protected _getFilenameAndPath(): {
  55523. filename: string;
  55524. path: string;
  55525. };
  55526. protected _getModelLoadingConstraints(): boolean;
  55527. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  55528. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55529. protected _updateModel(): void;
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Class containing static functions to help procedurally build meshes
  55535. */
  55536. export class SphereBuilder {
  55537. /**
  55538. * Creates a sphere mesh
  55539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55540. * * 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`)
  55541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55542. * * 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
  55543. * * 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)
  55544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55545. * * 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
  55546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55547. * @param name defines the name of the mesh
  55548. * @param options defines the options used to create the mesh
  55549. * @param scene defines the hosting scene
  55550. * @returns the sphere mesh
  55551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55552. */
  55553. static CreateSphere(name: string, options: {
  55554. segments?: number;
  55555. diameter?: number;
  55556. diameterX?: number;
  55557. diameterY?: number;
  55558. diameterZ?: number;
  55559. arc?: number;
  55560. slice?: number;
  55561. sideOrientation?: number;
  55562. frontUVs?: Vector4;
  55563. backUVs?: Vector4;
  55564. updatable?: boolean;
  55565. }, scene?: Nullable<Scene>): Mesh;
  55566. }
  55567. }
  55568. declare module BABYLON {
  55569. /**
  55570. * A profiled motion controller has its profile loaded from an online repository.
  55571. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  55572. */
  55573. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  55574. private _repositoryUrl;
  55575. private _buttonMeshMapping;
  55576. private _touchDots;
  55577. /**
  55578. * The profile ID of this controller. Will be populated when the controller initializes.
  55579. */
  55580. profileId: string;
  55581. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  55582. dispose(): void;
  55583. protected _getFilenameAndPath(): {
  55584. filename: string;
  55585. path: string;
  55586. };
  55587. protected _getModelLoadingConstraints(): boolean;
  55588. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  55589. protected _setRootMesh(meshes: AbstractMesh[]): void;
  55590. protected _updateModel(_xrFrame: XRFrame): void;
  55591. }
  55592. }
  55593. declare module BABYLON {
  55594. /**
  55595. * A construction function type to create a new controller based on an xrInput object
  55596. */
  55597. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  55598. /**
  55599. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  55600. *
  55601. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  55602. * it should be replaced with auto-loaded controllers.
  55603. *
  55604. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  55605. */
  55606. export class WebXRMotionControllerManager {
  55607. private static _AvailableControllers;
  55608. private static _Fallbacks;
  55609. private static _ProfileLoadingPromises;
  55610. private static _ProfilesList;
  55611. /**
  55612. * The base URL of the online controller repository. Can be changed at any time.
  55613. */
  55614. static BaseRepositoryUrl: string;
  55615. /**
  55616. * Which repository gets priority - local or online
  55617. */
  55618. static PrioritizeOnlineRepository: boolean;
  55619. /**
  55620. * Use the online repository, or use only locally-defined controllers
  55621. */
  55622. static UseOnlineRepository: boolean;
  55623. /**
  55624. * Clear the cache used for profile loading and reload when requested again
  55625. */
  55626. static ClearProfilesCache(): void;
  55627. /**
  55628. * Register the default fallbacks.
  55629. * This function is called automatically when this file is imported.
  55630. */
  55631. static DefaultFallbacks(): void;
  55632. /**
  55633. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  55634. * @param profileId the profile to which a fallback needs to be found
  55635. * @return an array with corresponding fallback profiles
  55636. */
  55637. static FindFallbackWithProfileId(profileId: string): string[];
  55638. /**
  55639. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  55640. * The order of search:
  55641. *
  55642. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  55643. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  55644. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55645. * 4) return the generic trigger controller if none were found
  55646. *
  55647. * @param xrInput the xrInput to which a new controller is initialized
  55648. * @param scene the scene to which the model will be added
  55649. * @param forceProfile force a certain profile for this controller
  55650. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  55651. */
  55652. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  55653. /**
  55654. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  55655. *
  55656. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  55657. *
  55658. * @param type the profile type to register
  55659. * @param constructFunction the function to be called when loading this profile
  55660. */
  55661. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  55662. /**
  55663. * Register a fallback to a specific profile.
  55664. * @param profileId the profileId that will receive the fallbacks
  55665. * @param fallbacks A list of fallback profiles
  55666. */
  55667. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  55668. /**
  55669. * Will update the list of profiles available in the repository
  55670. * @return a promise that resolves to a map of profiles available online
  55671. */
  55672. static UpdateProfilesList(): Promise<{
  55673. [profile: string]: string;
  55674. }>;
  55675. private static _LoadProfileFromRepository;
  55676. private static _LoadProfilesFromAvailableControllers;
  55677. }
  55678. }
  55679. declare module BABYLON {
  55680. /**
  55681. * Configuration options for the WebXR controller creation
  55682. */
  55683. export interface IWebXRControllerOptions {
  55684. /**
  55685. * Should the controller mesh be animated when a user interacts with it
  55686. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55687. */
  55688. disableMotionControllerAnimation?: boolean;
  55689. /**
  55690. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55691. */
  55692. doNotLoadControllerMesh?: boolean;
  55693. /**
  55694. * Force a specific controller type for this controller.
  55695. * This can be used when creating your own profile or when testing different controllers
  55696. */
  55697. forceControllerProfile?: string;
  55698. /**
  55699. * Defines a rendering group ID for meshes that will be loaded.
  55700. * This is for the default controllers only.
  55701. */
  55702. renderingGroupId?: number;
  55703. }
  55704. /**
  55705. * Represents an XR controller
  55706. */
  55707. export class WebXRInputSource {
  55708. private _scene;
  55709. /** The underlying input source for the controller */
  55710. inputSource: XRInputSource;
  55711. private _options;
  55712. private _tmpVector;
  55713. private _uniqueId;
  55714. private _disposed;
  55715. /**
  55716. * 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
  55717. */
  55718. grip?: AbstractMesh;
  55719. /**
  55720. * If available, this is the gamepad object related to this controller.
  55721. * Using this object it is possible to get click events and trackpad changes of the
  55722. * webxr controller that is currently being used.
  55723. */
  55724. motionController?: WebXRAbstractMotionController;
  55725. /**
  55726. * Event that fires when the controller is removed/disposed.
  55727. * The object provided as event data is this controller, after associated assets were disposed.
  55728. * uniqueId is still available.
  55729. */
  55730. onDisposeObservable: Observable<WebXRInputSource>;
  55731. /**
  55732. * Will be triggered when the mesh associated with the motion controller is done loading.
  55733. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55734. * A shortened version of controller -> motion controller -> on mesh loaded.
  55735. */
  55736. onMeshLoadedObservable: Observable<AbstractMesh>;
  55737. /**
  55738. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55739. */
  55740. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55741. /**
  55742. * Pointer which can be used to select objects or attach a visible laser to
  55743. */
  55744. pointer: AbstractMesh;
  55745. /**
  55746. * Creates the input source object
  55747. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55748. * @param _scene the scene which the controller should be associated to
  55749. * @param inputSource the underlying input source for the controller
  55750. * @param _options options for this controller creation
  55751. */
  55752. constructor(_scene: Scene,
  55753. /** The underlying input source for the controller */
  55754. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55755. /**
  55756. * Get this controllers unique id
  55757. */
  55758. get uniqueId(): string;
  55759. /**
  55760. * Disposes of the object
  55761. */
  55762. dispose(): void;
  55763. /**
  55764. * Gets a world space ray coming from the pointer or grip
  55765. * @param result the resulting ray
  55766. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55767. */
  55768. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55769. /**
  55770. * Updates the controller pose based on the given XRFrame
  55771. * @param xrFrame xr frame to update the pose with
  55772. * @param referenceSpace reference space to use
  55773. */
  55774. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55775. }
  55776. }
  55777. declare module BABYLON {
  55778. /**
  55779. * The schema for initialization options of the XR Input class
  55780. */
  55781. export interface IWebXRInputOptions {
  55782. /**
  55783. * If set to true no model will be automatically loaded
  55784. */
  55785. doNotLoadControllerMeshes?: boolean;
  55786. /**
  55787. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55788. * If not found, the xr input profile data will be used.
  55789. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55790. */
  55791. forceInputProfile?: string;
  55792. /**
  55793. * Do not send a request to the controller repository to load the profile.
  55794. *
  55795. * Instead, use the controllers available in babylon itself.
  55796. */
  55797. disableOnlineControllerRepository?: boolean;
  55798. /**
  55799. * A custom URL for the controllers repository
  55800. */
  55801. customControllersRepositoryURL?: string;
  55802. /**
  55803. * Should the controller model's components not move according to the user input
  55804. */
  55805. disableControllerAnimation?: boolean;
  55806. /**
  55807. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55808. */
  55809. controllerOptions?: IWebXRControllerOptions;
  55810. }
  55811. /**
  55812. * XR input used to track XR inputs such as controllers/rays
  55813. */
  55814. export class WebXRInput implements IDisposable {
  55815. /**
  55816. * the xr session manager for this session
  55817. */
  55818. xrSessionManager: WebXRSessionManager;
  55819. /**
  55820. * the WebXR camera for this session. Mainly used for teleportation
  55821. */
  55822. xrCamera: WebXRCamera;
  55823. private readonly options;
  55824. /**
  55825. * XR controllers being tracked
  55826. */
  55827. controllers: Array<WebXRInputSource>;
  55828. private _frameObserver;
  55829. private _sessionEndedObserver;
  55830. private _sessionInitObserver;
  55831. /**
  55832. * Event when a controller has been connected/added
  55833. */
  55834. onControllerAddedObservable: Observable<WebXRInputSource>;
  55835. /**
  55836. * Event when a controller has been removed/disconnected
  55837. */
  55838. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55839. /**
  55840. * Initializes the WebXRInput
  55841. * @param xrSessionManager the xr session manager for this session
  55842. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55843. * @param options = initialization options for this xr input
  55844. */
  55845. constructor(
  55846. /**
  55847. * the xr session manager for this session
  55848. */
  55849. xrSessionManager: WebXRSessionManager,
  55850. /**
  55851. * the WebXR camera for this session. Mainly used for teleportation
  55852. */
  55853. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55854. private _onInputSourcesChange;
  55855. private _addAndRemoveControllers;
  55856. /**
  55857. * Disposes of the object
  55858. */
  55859. dispose(): void;
  55860. }
  55861. }
  55862. declare module BABYLON {
  55863. /**
  55864. * This is the base class for all WebXR features.
  55865. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55866. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55867. */
  55868. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55869. protected _xrSessionManager: WebXRSessionManager;
  55870. private _attached;
  55871. private _removeOnDetach;
  55872. /**
  55873. * Is this feature disposed?
  55874. */
  55875. isDisposed: boolean;
  55876. /**
  55877. * Should auto-attach be disabled?
  55878. */
  55879. disableAutoAttach: boolean;
  55880. /**
  55881. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55882. */
  55883. xrNativeFeatureName: string;
  55884. /**
  55885. * Construct a new (abstract) WebXR feature
  55886. * @param _xrSessionManager the xr session manager for this feature
  55887. */
  55888. constructor(_xrSessionManager: WebXRSessionManager);
  55889. /**
  55890. * Is this feature attached
  55891. */
  55892. get attached(): boolean;
  55893. /**
  55894. * attach this feature
  55895. *
  55896. * @param force should attachment be forced (even when already attached)
  55897. * @returns true if successful, false is failed or already attached
  55898. */
  55899. attach(force?: boolean): boolean;
  55900. /**
  55901. * detach this feature.
  55902. *
  55903. * @returns true if successful, false if failed or already detached
  55904. */
  55905. detach(): boolean;
  55906. /**
  55907. * Dispose this feature and all of the resources attached
  55908. */
  55909. dispose(): void;
  55910. /**
  55911. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55912. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55913. *
  55914. * @returns whether or not the feature is compatible in this environment
  55915. */
  55916. isCompatible(): boolean;
  55917. /**
  55918. * This is used to register callbacks that will automatically be removed when detach is called.
  55919. * @param observable the observable to which the observer will be attached
  55920. * @param callback the callback to register
  55921. */
  55922. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55923. /**
  55924. * Code in this function will be executed on each xrFrame received from the browser.
  55925. * This function will not execute after the feature is detached.
  55926. * @param _xrFrame the current frame
  55927. */
  55928. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55929. }
  55930. }
  55931. declare module BABYLON {
  55932. /**
  55933. * Renders a layer on top of an existing scene
  55934. */
  55935. export class UtilityLayerRenderer implements IDisposable {
  55936. /** the original scene that will be rendered on top of */
  55937. originalScene: Scene;
  55938. private _pointerCaptures;
  55939. private _lastPointerEvents;
  55940. private static _DefaultUtilityLayer;
  55941. private static _DefaultKeepDepthUtilityLayer;
  55942. private _sharedGizmoLight;
  55943. private _renderCamera;
  55944. /**
  55945. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55946. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55947. * @returns the camera that is used when rendering the utility layer
  55948. */
  55949. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55950. /**
  55951. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55952. * @param cam the camera that should be used when rendering the utility layer
  55953. */
  55954. setRenderCamera(cam: Nullable<Camera>): void;
  55955. /**
  55956. * @hidden
  55957. * Light which used by gizmos to get light shading
  55958. */
  55959. _getSharedGizmoLight(): HemisphericLight;
  55960. /**
  55961. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55962. */
  55963. pickUtilitySceneFirst: boolean;
  55964. /**
  55965. * 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)
  55966. */
  55967. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55968. /**
  55969. * 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)
  55970. */
  55971. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55972. /**
  55973. * The scene that is rendered on top of the original scene
  55974. */
  55975. utilityLayerScene: Scene;
  55976. /**
  55977. * If the utility layer should automatically be rendered on top of existing scene
  55978. */
  55979. shouldRender: boolean;
  55980. /**
  55981. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55982. */
  55983. onlyCheckPointerDownEvents: boolean;
  55984. /**
  55985. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55986. */
  55987. processAllEvents: boolean;
  55988. /**
  55989. * Observable raised when the pointer move from the utility layer scene to the main scene
  55990. */
  55991. onPointerOutObservable: Observable<number>;
  55992. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55993. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55994. private _afterRenderObserver;
  55995. private _sceneDisposeObserver;
  55996. private _originalPointerObserver;
  55997. /**
  55998. * Instantiates a UtilityLayerRenderer
  55999. * @param originalScene the original scene that will be rendered on top of
  56000. * @param handleEvents boolean indicating if the utility layer should handle events
  56001. */
  56002. constructor(
  56003. /** the original scene that will be rendered on top of */
  56004. originalScene: Scene, handleEvents?: boolean);
  56005. private _notifyObservers;
  56006. /**
  56007. * Renders the utility layers scene on top of the original scene
  56008. */
  56009. render(): void;
  56010. /**
  56011. * Disposes of the renderer
  56012. */
  56013. dispose(): void;
  56014. private _updateCamera;
  56015. }
  56016. }
  56017. declare module BABYLON {
  56018. /**
  56019. * Options interface for the pointer selection module
  56020. */
  56021. export interface IWebXRControllerPointerSelectionOptions {
  56022. /**
  56023. * if provided, this scene will be used to render meshes.
  56024. */
  56025. customUtilityLayerScene?: Scene;
  56026. /**
  56027. * 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)
  56028. * If not disabled, the last picked point will be used to execute a pointer up event
  56029. * If disabled, pointer up event will be triggered right after the pointer down event.
  56030. * Used in screen and gaze target ray mode only
  56031. */
  56032. disablePointerUpOnTouchOut: boolean;
  56033. /**
  56034. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  56035. */
  56036. forceGazeMode: boolean;
  56037. /**
  56038. * 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
  56039. * to start a new countdown to the pointer down event.
  56040. * Defaults to 1.
  56041. */
  56042. gazeModePointerMovedFactor?: number;
  56043. /**
  56044. * Different button type to use instead of the main component
  56045. */
  56046. overrideButtonId?: string;
  56047. /**
  56048. * use this rendering group id for the meshes (optional)
  56049. */
  56050. renderingGroupId?: number;
  56051. /**
  56052. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  56053. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  56054. * 3000 means 3 seconds between pointing at something and selecting it
  56055. */
  56056. timeToSelect?: number;
  56057. /**
  56058. * Should meshes created here be added to a utility layer or the main scene
  56059. */
  56060. useUtilityLayer?: boolean;
  56061. /**
  56062. * Optional WebXR camera to be used for gaze selection
  56063. */
  56064. gazeCamera?: WebXRCamera;
  56065. /**
  56066. * the xr input to use with this pointer selection
  56067. */
  56068. xrInput: WebXRInput;
  56069. /**
  56070. * Should the scene pointerX and pointerY update be disabled
  56071. * This is required for fullscreen AR GUI, but might slow down other experiences.
  56072. * Disable in VR, if not needed.
  56073. * The first rig camera (left eye) will be used to calculate the projection
  56074. */
  56075. disableScenePointerVectorUpdate: boolean;
  56076. /**
  56077. * Enable pointer selection on all controllers instead of switching between them
  56078. */
  56079. enablePointerSelectionOnAllControllers?: boolean;
  56080. /**
  56081. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  56082. * If switch is enabled, it will still allow the user to switch between the different controllers
  56083. */
  56084. preferredHandedness?: XRHandedness;
  56085. /**
  56086. * Disable switching the pointer selection from one controller to the other.
  56087. * 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
  56088. */
  56089. disableSwitchOnClick?: boolean;
  56090. /**
  56091. * The maximum distance of the pointer selection feature. Defaults to 100.
  56092. */
  56093. maxPointerDistance?: number;
  56094. }
  56095. /**
  56096. * A module that will enable pointer selection for motion controllers of XR Input Sources
  56097. */
  56098. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  56099. private readonly _options;
  56100. private static _idCounter;
  56101. private _attachController;
  56102. private _controllers;
  56103. private _scene;
  56104. private _tmpVectorForPickCompare;
  56105. private _attachedController;
  56106. /**
  56107. * The module's name
  56108. */
  56109. static readonly Name: string;
  56110. /**
  56111. * The (Babylon) version of this module.
  56112. * This is an integer representing the implementation version.
  56113. * This number does not correspond to the WebXR specs version
  56114. */
  56115. static readonly Version: number;
  56116. /**
  56117. * Disable lighting on the laser pointer (so it will always be visible)
  56118. */
  56119. disablePointerLighting: boolean;
  56120. /**
  56121. * Disable lighting on the selection mesh (so it will always be visible)
  56122. */
  56123. disableSelectionMeshLighting: boolean;
  56124. /**
  56125. * Should the laser pointer be displayed
  56126. */
  56127. displayLaserPointer: boolean;
  56128. /**
  56129. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  56130. */
  56131. displaySelectionMesh: boolean;
  56132. /**
  56133. * This color will be set to the laser pointer when selection is triggered
  56134. */
  56135. laserPointerPickedColor: Color3;
  56136. /**
  56137. * Default color of the laser pointer
  56138. */
  56139. laserPointerDefaultColor: Color3;
  56140. /**
  56141. * default color of the selection ring
  56142. */
  56143. selectionMeshDefaultColor: Color3;
  56144. /**
  56145. * This color will be applied to the selection ring when selection is triggered
  56146. */
  56147. selectionMeshPickedColor: Color3;
  56148. /**
  56149. * Optional filter to be used for ray selection. This predicate shares behavior with
  56150. * scene.pointerMovePredicate which takes priority if it is also assigned.
  56151. */
  56152. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56153. /**
  56154. * constructs a new background remover module
  56155. * @param _xrSessionManager the session manager for this module
  56156. * @param _options read-only options to be used in this module
  56157. */
  56158. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  56159. /**
  56160. * attach this feature
  56161. * Will usually be called by the features manager
  56162. *
  56163. * @returns true if successful.
  56164. */
  56165. attach(): boolean;
  56166. /**
  56167. * detach this feature.
  56168. * Will usually be called by the features manager
  56169. *
  56170. * @returns true if successful.
  56171. */
  56172. detach(): boolean;
  56173. /**
  56174. * Will get the mesh under a specific pointer.
  56175. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  56176. * @param controllerId the controllerId to check
  56177. * @returns The mesh under pointer or null if no mesh is under the pointer
  56178. */
  56179. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  56180. /**
  56181. * Get the xr controller that correlates to the pointer id in the pointer event
  56182. *
  56183. * @param id the pointer id to search for
  56184. * @returns the controller that correlates to this id or null if not found
  56185. */
  56186. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  56187. private _identityMatrix;
  56188. private _screenCoordinatesRef;
  56189. private _viewportRef;
  56190. protected _onXRFrame(_xrFrame: XRFrame): void;
  56191. private _attachGazeMode;
  56192. private _attachScreenRayMode;
  56193. private _attachTrackedPointerRayMode;
  56194. private _convertNormalToDirectionOfRay;
  56195. private _detachController;
  56196. private _generateNewMeshPair;
  56197. private _pickingMoved;
  56198. private _updatePointerDistance;
  56199. /** @hidden */
  56200. get lasterPointerDefaultColor(): Color3;
  56201. }
  56202. }
  56203. declare module BABYLON {
  56204. /**
  56205. * Button which can be used to enter a different mode of XR
  56206. */
  56207. export class WebXREnterExitUIButton {
  56208. /** button element */
  56209. element: HTMLElement;
  56210. /** XR initialization options for the button */
  56211. sessionMode: XRSessionMode;
  56212. /** Reference space type */
  56213. referenceSpaceType: XRReferenceSpaceType;
  56214. /**
  56215. * Creates a WebXREnterExitUIButton
  56216. * @param element button element
  56217. * @param sessionMode XR initialization session mode
  56218. * @param referenceSpaceType the type of reference space to be used
  56219. */
  56220. constructor(
  56221. /** button element */
  56222. element: HTMLElement,
  56223. /** XR initialization options for the button */
  56224. sessionMode: XRSessionMode,
  56225. /** Reference space type */
  56226. referenceSpaceType: XRReferenceSpaceType);
  56227. /**
  56228. * Extendable function which can be used to update the button's visuals when the state changes
  56229. * @param activeButton the current active button in the UI
  56230. */
  56231. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  56232. }
  56233. /**
  56234. * Options to create the webXR UI
  56235. */
  56236. export class WebXREnterExitUIOptions {
  56237. /**
  56238. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  56239. */
  56240. customButtons?: Array<WebXREnterExitUIButton>;
  56241. /**
  56242. * A reference space type to use when creating the default button.
  56243. * Default is local-floor
  56244. */
  56245. referenceSpaceType?: XRReferenceSpaceType;
  56246. /**
  56247. * Context to enter xr with
  56248. */
  56249. renderTarget?: Nullable<WebXRRenderTarget>;
  56250. /**
  56251. * A session mode to use when creating the default button.
  56252. * Default is immersive-vr
  56253. */
  56254. sessionMode?: XRSessionMode;
  56255. /**
  56256. * A list of optional features to init the session with
  56257. */
  56258. optionalFeatures?: string[];
  56259. /**
  56260. * A list of optional features to init the session with
  56261. */
  56262. requiredFeatures?: string[];
  56263. /**
  56264. * If defined, this function will be executed if the UI encounters an error when entering XR
  56265. */
  56266. onError?: (error: any) => void;
  56267. }
  56268. /**
  56269. * UI to allow the user to enter/exit XR mode
  56270. */
  56271. export class WebXREnterExitUI implements IDisposable {
  56272. private scene;
  56273. /** version of the options passed to this UI */
  56274. options: WebXREnterExitUIOptions;
  56275. private _activeButton;
  56276. private _buttons;
  56277. /**
  56278. * The HTML Div Element to which buttons are added.
  56279. */
  56280. readonly overlay: HTMLDivElement;
  56281. /**
  56282. * Fired every time the active button is changed.
  56283. *
  56284. * When xr is entered via a button that launches xr that button will be the callback parameter
  56285. *
  56286. * When exiting xr the callback parameter will be null)
  56287. */
  56288. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  56289. /**
  56290. *
  56291. * @param scene babylon scene object to use
  56292. * @param options (read-only) version of the options passed to this UI
  56293. */
  56294. private constructor();
  56295. /**
  56296. * Creates UI to allow the user to enter/exit XR mode
  56297. * @param scene the scene to add the ui to
  56298. * @param helper the xr experience helper to enter/exit xr with
  56299. * @param options options to configure the UI
  56300. * @returns the created ui
  56301. */
  56302. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  56303. /**
  56304. * Disposes of the XR UI component
  56305. */
  56306. dispose(): void;
  56307. private _updateButtons;
  56308. }
  56309. }
  56310. declare module BABYLON {
  56311. /**
  56312. * Class containing static functions to help procedurally build meshes
  56313. */
  56314. export class LinesBuilder {
  56315. /**
  56316. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56317. * * 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
  56318. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56319. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56320. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56321. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56322. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56323. * * 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
  56324. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56327. * @param name defines the name of the new line system
  56328. * @param options defines the options used to create the line system
  56329. * @param scene defines the hosting scene
  56330. * @returns a new line system mesh
  56331. */
  56332. static CreateLineSystem(name: string, options: {
  56333. lines: Vector3[][];
  56334. updatable?: boolean;
  56335. instance?: Nullable<LinesMesh>;
  56336. colors?: Nullable<Color4[][]>;
  56337. useVertexAlpha?: boolean;
  56338. }, scene: Nullable<Scene>): LinesMesh;
  56339. /**
  56340. * Creates a line mesh
  56341. * 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
  56342. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56343. * * The parameter `points` is an array successive Vector3
  56344. * * 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
  56345. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56346. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56347. * * When updating an instance, remember that only point positions can change, not the number of points
  56348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56350. * @param name defines the name of the new line system
  56351. * @param options defines the options used to create the line system
  56352. * @param scene defines the hosting scene
  56353. * @returns a new line mesh
  56354. */
  56355. static CreateLines(name: string, options: {
  56356. points: Vector3[];
  56357. updatable?: boolean;
  56358. instance?: Nullable<LinesMesh>;
  56359. colors?: Color4[];
  56360. useVertexAlpha?: boolean;
  56361. }, scene?: Nullable<Scene>): LinesMesh;
  56362. /**
  56363. * Creates a dashed line mesh
  56364. * * 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
  56365. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56366. * * The parameter `points` is an array successive Vector3
  56367. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56368. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56369. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56370. * * 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
  56371. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56372. * * When updating an instance, remember that only point positions can change, not the number of points
  56373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56374. * @param name defines the name of the mesh
  56375. * @param options defines the options used to create the mesh
  56376. * @param scene defines the hosting scene
  56377. * @returns the dashed line mesh
  56378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56379. */
  56380. static CreateDashedLines(name: string, options: {
  56381. points: Vector3[];
  56382. dashSize?: number;
  56383. gapSize?: number;
  56384. dashNb?: number;
  56385. updatable?: boolean;
  56386. instance?: LinesMesh;
  56387. useVertexAlpha?: boolean;
  56388. }, scene?: Nullable<Scene>): LinesMesh;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * Construction options for a timer
  56394. */
  56395. export interface ITimerOptions<T> {
  56396. /**
  56397. * Time-to-end
  56398. */
  56399. timeout: number;
  56400. /**
  56401. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  56402. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  56403. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  56404. */
  56405. contextObservable: Observable<T>;
  56406. /**
  56407. * Optional parameters when adding an observer to the observable
  56408. */
  56409. observableParameters?: {
  56410. mask?: number;
  56411. insertFirst?: boolean;
  56412. scope?: any;
  56413. };
  56414. /**
  56415. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  56416. */
  56417. breakCondition?: (data?: ITimerData<T>) => boolean;
  56418. /**
  56419. * Will be triggered when the time condition has met
  56420. */
  56421. onEnded?: (data: ITimerData<any>) => void;
  56422. /**
  56423. * Will be triggered when the break condition has met (prematurely ended)
  56424. */
  56425. onAborted?: (data: ITimerData<any>) => void;
  56426. /**
  56427. * Optional function to execute on each tick (or count)
  56428. */
  56429. onTick?: (data: ITimerData<any>) => void;
  56430. }
  56431. /**
  56432. * An interface defining the data sent by the timer
  56433. */
  56434. export interface ITimerData<T> {
  56435. /**
  56436. * When did it start
  56437. */
  56438. startTime: number;
  56439. /**
  56440. * Time now
  56441. */
  56442. currentTime: number;
  56443. /**
  56444. * Time passed since started
  56445. */
  56446. deltaTime: number;
  56447. /**
  56448. * How much is completed, in [0.0...1.0].
  56449. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  56450. */
  56451. completeRate: number;
  56452. /**
  56453. * What the registered observable sent in the last count
  56454. */
  56455. payload: T;
  56456. }
  56457. /**
  56458. * The current state of the timer
  56459. */
  56460. export enum TimerState {
  56461. /**
  56462. * Timer initialized, not yet started
  56463. */
  56464. INIT = 0,
  56465. /**
  56466. * Timer started and counting
  56467. */
  56468. STARTED = 1,
  56469. /**
  56470. * Timer ended (whether aborted or time reached)
  56471. */
  56472. ENDED = 2
  56473. }
  56474. /**
  56475. * A simple version of the timer. Will take options and start the timer immediately after calling it
  56476. *
  56477. * @param options options with which to initialize this timer
  56478. */
  56479. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  56480. /**
  56481. * An advanced implementation of a timer class
  56482. */
  56483. export class AdvancedTimer<T = any> implements IDisposable {
  56484. /**
  56485. * Will notify each time the timer calculates the remaining time
  56486. */
  56487. onEachCountObservable: Observable<ITimerData<T>>;
  56488. /**
  56489. * Will trigger when the timer was aborted due to the break condition
  56490. */
  56491. onTimerAbortedObservable: Observable<ITimerData<T>>;
  56492. /**
  56493. * Will trigger when the timer ended successfully
  56494. */
  56495. onTimerEndedObservable: Observable<ITimerData<T>>;
  56496. /**
  56497. * Will trigger when the timer state has changed
  56498. */
  56499. onStateChangedObservable: Observable<TimerState>;
  56500. private _observer;
  56501. private _contextObservable;
  56502. private _observableParameters;
  56503. private _startTime;
  56504. private _timer;
  56505. private _state;
  56506. private _breakCondition;
  56507. private _timeToEnd;
  56508. private _breakOnNextTick;
  56509. /**
  56510. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  56511. * @param options construction options for this advanced timer
  56512. */
  56513. constructor(options: ITimerOptions<T>);
  56514. /**
  56515. * set a breaking condition for this timer. Default is to never break during count
  56516. * @param predicate the new break condition. Returns true to break, false otherwise
  56517. */
  56518. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  56519. /**
  56520. * Reset ALL associated observables in this advanced timer
  56521. */
  56522. clearObservables(): void;
  56523. /**
  56524. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  56525. *
  56526. * @param timeToEnd how much time to measure until timer ended
  56527. */
  56528. start(timeToEnd?: number): void;
  56529. /**
  56530. * Will force a stop on the next tick.
  56531. */
  56532. stop(): void;
  56533. /**
  56534. * Dispose this timer, clearing all resources
  56535. */
  56536. dispose(): void;
  56537. private _setState;
  56538. private _tick;
  56539. private _stop;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /**
  56544. * The options container for the teleportation module
  56545. */
  56546. export interface IWebXRTeleportationOptions {
  56547. /**
  56548. * if provided, this scene will be used to render meshes.
  56549. */
  56550. customUtilityLayerScene?: Scene;
  56551. /**
  56552. * Values to configure the default target mesh
  56553. */
  56554. defaultTargetMeshOptions?: {
  56555. /**
  56556. * Fill color of the teleportation area
  56557. */
  56558. teleportationFillColor?: string;
  56559. /**
  56560. * Border color for the teleportation area
  56561. */
  56562. teleportationBorderColor?: string;
  56563. /**
  56564. * Disable the mesh's animation sequence
  56565. */
  56566. disableAnimation?: boolean;
  56567. /**
  56568. * Disable lighting on the material or the ring and arrow
  56569. */
  56570. disableLighting?: boolean;
  56571. /**
  56572. * Override the default material of the torus and arrow
  56573. */
  56574. torusArrowMaterial?: Material;
  56575. };
  56576. /**
  56577. * A list of meshes to use as floor meshes.
  56578. * Meshes can be added and removed after initializing the feature using the
  56579. * addFloorMesh and removeFloorMesh functions
  56580. * If empty, rotation will still work
  56581. */
  56582. floorMeshes?: AbstractMesh[];
  56583. /**
  56584. * use this rendering group id for the meshes (optional)
  56585. */
  56586. renderingGroupId?: number;
  56587. /**
  56588. * Should teleportation move only to snap points
  56589. */
  56590. snapPointsOnly?: boolean;
  56591. /**
  56592. * An array of points to which the teleportation will snap to.
  56593. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  56594. */
  56595. snapPositions?: Vector3[];
  56596. /**
  56597. * How close should the teleportation ray be in order to snap to position.
  56598. * Default to 0.8 units (meters)
  56599. */
  56600. snapToPositionRadius?: number;
  56601. /**
  56602. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  56603. * If you want to support rotation, make sure your mesh has a direction indicator.
  56604. *
  56605. * When left untouched, the default mesh will be initialized.
  56606. */
  56607. teleportationTargetMesh?: AbstractMesh;
  56608. /**
  56609. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  56610. */
  56611. timeToTeleport?: number;
  56612. /**
  56613. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  56614. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  56615. */
  56616. useMainComponentOnly?: boolean;
  56617. /**
  56618. * Should meshes created here be added to a utility layer or the main scene
  56619. */
  56620. useUtilityLayer?: boolean;
  56621. /**
  56622. * Babylon XR Input class for controller
  56623. */
  56624. xrInput: WebXRInput;
  56625. /**
  56626. * Meshes that the teleportation ray cannot go through
  56627. */
  56628. pickBlockerMeshes?: AbstractMesh[];
  56629. /**
  56630. * Should teleport work only on a specific hand?
  56631. */
  56632. forceHandedness?: XRHandedness;
  56633. /**
  56634. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  56635. */
  56636. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  56637. }
  56638. /**
  56639. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  56640. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  56641. * the input of the attached controllers.
  56642. */
  56643. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  56644. private _options;
  56645. private _controllers;
  56646. private _currentTeleportationControllerId;
  56647. private _floorMeshes;
  56648. private _quadraticBezierCurve;
  56649. private _selectionFeature;
  56650. private _snapToPositions;
  56651. private _snappedToPoint;
  56652. private _teleportationRingMaterial?;
  56653. private _tmpRay;
  56654. private _tmpVector;
  56655. private _tmpQuaternion;
  56656. /**
  56657. * The module's name
  56658. */
  56659. static readonly Name: string;
  56660. /**
  56661. * The (Babylon) version of this module.
  56662. * This is an integer representing the implementation version.
  56663. * This number does not correspond to the webxr specs version
  56664. */
  56665. static readonly Version: number;
  56666. /**
  56667. * Is movement backwards enabled
  56668. */
  56669. backwardsMovementEnabled: boolean;
  56670. /**
  56671. * Distance to travel when moving backwards
  56672. */
  56673. backwardsTeleportationDistance: number;
  56674. /**
  56675. * The distance from the user to the inspection point in the direction of the controller
  56676. * A higher number will allow the user to move further
  56677. * defaults to 5 (meters, in xr units)
  56678. */
  56679. parabolicCheckRadius: number;
  56680. /**
  56681. * Should the module support parabolic ray on top of direct ray
  56682. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56683. * Very helpful when moving between floors / different heights
  56684. */
  56685. parabolicRayEnabled: boolean;
  56686. /**
  56687. * The second type of ray - straight line.
  56688. * Should it be enabled or should the parabolic line be the only one.
  56689. */
  56690. straightRayEnabled: boolean;
  56691. /**
  56692. * How much rotation should be applied when rotating right and left
  56693. */
  56694. rotationAngle: number;
  56695. private _rotationEnabled;
  56696. /**
  56697. * Is rotation enabled when moving forward?
  56698. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56699. */
  56700. get rotationEnabled(): boolean;
  56701. /**
  56702. * Sets whether rotation is enabled or not
  56703. * @param enabled is rotation enabled when teleportation is shown
  56704. */
  56705. set rotationEnabled(enabled: boolean);
  56706. /**
  56707. * Exposes the currently set teleportation target mesh.
  56708. */
  56709. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56710. /**
  56711. * constructs a new anchor system
  56712. * @param _xrSessionManager an instance of WebXRSessionManager
  56713. * @param _options configuration object for this feature
  56714. */
  56715. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56716. /**
  56717. * Get the snapPointsOnly flag
  56718. */
  56719. get snapPointsOnly(): boolean;
  56720. /**
  56721. * Sets the snapPointsOnly flag
  56722. * @param snapToPoints should teleportation be exclusively to snap points
  56723. */
  56724. set snapPointsOnly(snapToPoints: boolean);
  56725. /**
  56726. * Add a new mesh to the floor meshes array
  56727. * @param mesh the mesh to use as floor mesh
  56728. */
  56729. addFloorMesh(mesh: AbstractMesh): void;
  56730. /**
  56731. * Add a new snap-to point to fix teleportation to this position
  56732. * @param newSnapPoint The new Snap-To point
  56733. */
  56734. addSnapPoint(newSnapPoint: Vector3): void;
  56735. attach(): boolean;
  56736. detach(): boolean;
  56737. dispose(): void;
  56738. /**
  56739. * Remove a mesh from the floor meshes array
  56740. * @param mesh the mesh to remove
  56741. */
  56742. removeFloorMesh(mesh: AbstractMesh): void;
  56743. /**
  56744. * Remove a mesh from the floor meshes array using its name
  56745. * @param name the mesh name to remove
  56746. */
  56747. removeFloorMeshByName(name: string): void;
  56748. /**
  56749. * 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
  56750. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56751. * @returns was the point found and removed or not
  56752. */
  56753. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56754. /**
  56755. * This function sets a selection feature that will be disabled when
  56756. * the forward ray is shown and will be reattached when hidden.
  56757. * This is used to remove the selection rays when moving.
  56758. * @param selectionFeature the feature to disable when forward movement is enabled
  56759. */
  56760. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56761. protected _onXRFrame(_xrFrame: XRFrame): void;
  56762. private _attachController;
  56763. private _createDefaultTargetMesh;
  56764. private _detachController;
  56765. private _findClosestSnapPointWithRadius;
  56766. private _setTargetMeshPosition;
  56767. private _setTargetMeshVisibility;
  56768. private _showParabolicPath;
  56769. private _teleportForward;
  56770. }
  56771. }
  56772. declare module BABYLON {
  56773. /**
  56774. * Options for the default xr helper
  56775. */
  56776. export class WebXRDefaultExperienceOptions {
  56777. /**
  56778. * Enable or disable default UI to enter XR
  56779. */
  56780. disableDefaultUI?: boolean;
  56781. /**
  56782. * Should teleportation not initialize. defaults to false.
  56783. */
  56784. disableTeleportation?: boolean;
  56785. /**
  56786. * Floor meshes that will be used for teleport
  56787. */
  56788. floorMeshes?: Array<AbstractMesh>;
  56789. /**
  56790. * If set to true, the first frame will not be used to reset position
  56791. * The first frame is mainly used when copying transformation from the old camera
  56792. * Mainly used in AR
  56793. */
  56794. ignoreNativeCameraTransformation?: boolean;
  56795. /**
  56796. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56797. */
  56798. inputOptions?: IWebXRInputOptions;
  56799. /**
  56800. * optional configuration for the output canvas
  56801. */
  56802. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56803. /**
  56804. * optional UI options. This can be used among other to change session mode and reference space type
  56805. */
  56806. uiOptions?: WebXREnterExitUIOptions;
  56807. /**
  56808. * When loading teleportation and pointer select, use stable versions instead of latest.
  56809. */
  56810. useStablePlugins?: boolean;
  56811. /**
  56812. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56813. */
  56814. renderingGroupId?: number;
  56815. /**
  56816. * A list of optional features to init the session with
  56817. * If set to true, all features we support will be added
  56818. */
  56819. optionalFeatures?: boolean | string[];
  56820. }
  56821. /**
  56822. * Default experience which provides a similar setup to the previous webVRExperience
  56823. */
  56824. export class WebXRDefaultExperience {
  56825. /**
  56826. * Base experience
  56827. */
  56828. baseExperience: WebXRExperienceHelper;
  56829. /**
  56830. * Enables ui for entering/exiting xr
  56831. */
  56832. enterExitUI: WebXREnterExitUI;
  56833. /**
  56834. * Input experience extension
  56835. */
  56836. input: WebXRInput;
  56837. /**
  56838. * Enables laser pointer and selection
  56839. */
  56840. pointerSelection: WebXRControllerPointerSelection;
  56841. /**
  56842. * Default target xr should render to
  56843. */
  56844. renderTarget: WebXRRenderTarget;
  56845. /**
  56846. * Enables teleportation
  56847. */
  56848. teleportation: WebXRMotionControllerTeleportation;
  56849. private constructor();
  56850. /**
  56851. * Creates the default xr experience
  56852. * @param scene scene
  56853. * @param options options for basic configuration
  56854. * @returns resulting WebXRDefaultExperience
  56855. */
  56856. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56857. /**
  56858. * Disposes of the experience helper
  56859. */
  56860. dispose(): void;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /**
  56865. * Options to modify the vr teleportation behavior.
  56866. */
  56867. export interface VRTeleportationOptions {
  56868. /**
  56869. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56870. */
  56871. floorMeshName?: string;
  56872. /**
  56873. * A list of meshes to be used as the teleportation floor. (default: empty)
  56874. */
  56875. floorMeshes?: Mesh[];
  56876. /**
  56877. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56878. */
  56879. teleportationMode?: number;
  56880. /**
  56881. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56882. */
  56883. teleportationTime?: number;
  56884. /**
  56885. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56886. */
  56887. teleportationSpeed?: number;
  56888. /**
  56889. * The easing function used in the animation or null for Linear. (default CircleEase)
  56890. */
  56891. easingFunction?: EasingFunction;
  56892. }
  56893. /**
  56894. * Options to modify the vr experience helper's behavior.
  56895. */
  56896. export interface VRExperienceHelperOptions extends WebVROptions {
  56897. /**
  56898. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56899. */
  56900. createDeviceOrientationCamera?: boolean;
  56901. /**
  56902. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56903. */
  56904. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56905. /**
  56906. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56907. */
  56908. laserToggle?: boolean;
  56909. /**
  56910. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56911. */
  56912. floorMeshes?: Mesh[];
  56913. /**
  56914. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56915. */
  56916. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56917. /**
  56918. * Defines if WebXR should be used instead of WebVR (if available)
  56919. */
  56920. useXR?: boolean;
  56921. }
  56922. /**
  56923. * Event containing information after VR has been entered
  56924. */
  56925. export class OnAfterEnteringVRObservableEvent {
  56926. /**
  56927. * If entering vr was successful
  56928. */
  56929. success: boolean;
  56930. }
  56931. /**
  56932. * Helps to quickly add VR support to an existing scene.
  56933. * See https://doc.babylonjs.com/how_to/webvr_helper
  56934. */
  56935. export class VRExperienceHelper {
  56936. /** Options to modify the vr experience helper's behavior. */
  56937. webVROptions: VRExperienceHelperOptions;
  56938. private _scene;
  56939. private _position;
  56940. private _btnVR;
  56941. private _btnVRDisplayed;
  56942. private _webVRsupported;
  56943. private _webVRready;
  56944. private _webVRrequesting;
  56945. private _webVRpresenting;
  56946. private _hasEnteredVR;
  56947. private _fullscreenVRpresenting;
  56948. private _inputElement;
  56949. private _webVRCamera;
  56950. private _vrDeviceOrientationCamera;
  56951. private _deviceOrientationCamera;
  56952. private _existingCamera;
  56953. private _onKeyDown;
  56954. private _onVrDisplayPresentChange;
  56955. private _onVRDisplayChanged;
  56956. private _onVRRequestPresentStart;
  56957. private _onVRRequestPresentComplete;
  56958. /**
  56959. * 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)
  56960. */
  56961. enableGazeEvenWhenNoPointerLock: boolean;
  56962. /**
  56963. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56964. */
  56965. exitVROnDoubleTap: boolean;
  56966. /**
  56967. * Observable raised right before entering VR.
  56968. */
  56969. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56970. /**
  56971. * Observable raised when entering VR has completed.
  56972. */
  56973. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56974. /**
  56975. * Observable raised when exiting VR.
  56976. */
  56977. onExitingVRObservable: Observable<VRExperienceHelper>;
  56978. /**
  56979. * Observable raised when controller mesh is loaded.
  56980. */
  56981. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56982. /** Return this.onEnteringVRObservable
  56983. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56984. */
  56985. get onEnteringVR(): Observable<VRExperienceHelper>;
  56986. /** Return this.onExitingVRObservable
  56987. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56988. */
  56989. get onExitingVR(): Observable<VRExperienceHelper>;
  56990. /** Return this.onControllerMeshLoadedObservable
  56991. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56992. */
  56993. get onControllerMeshLoaded(): Observable<WebVRController>;
  56994. private _rayLength;
  56995. private _useCustomVRButton;
  56996. private _teleportationRequested;
  56997. private _teleportActive;
  56998. private _floorMeshName;
  56999. private _floorMeshesCollection;
  57000. private _teleportationMode;
  57001. private _teleportationTime;
  57002. private _teleportationSpeed;
  57003. private _teleportationEasing;
  57004. private _rotationAllowed;
  57005. private _teleportBackwardsVector;
  57006. private _teleportationTarget;
  57007. private _isDefaultTeleportationTarget;
  57008. private _postProcessMove;
  57009. private _teleportationFillColor;
  57010. private _teleportationBorderColor;
  57011. private _rotationAngle;
  57012. private _haloCenter;
  57013. private _cameraGazer;
  57014. private _padSensibilityUp;
  57015. private _padSensibilityDown;
  57016. private _leftController;
  57017. private _rightController;
  57018. private _gazeColor;
  57019. private _laserColor;
  57020. private _pickedLaserColor;
  57021. private _pickedGazeColor;
  57022. /**
  57023. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  57024. */
  57025. onNewMeshSelected: Observable<AbstractMesh>;
  57026. /**
  57027. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  57028. * This observable will provide the mesh and the controller used to select the mesh
  57029. */
  57030. onMeshSelectedWithController: Observable<{
  57031. mesh: AbstractMesh;
  57032. controller: WebVRController;
  57033. }>;
  57034. /**
  57035. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  57036. */
  57037. onNewMeshPicked: Observable<PickingInfo>;
  57038. private _circleEase;
  57039. /**
  57040. * Observable raised before camera teleportation
  57041. */
  57042. onBeforeCameraTeleport: Observable<Vector3>;
  57043. /**
  57044. * Observable raised after camera teleportation
  57045. */
  57046. onAfterCameraTeleport: Observable<Vector3>;
  57047. /**
  57048. * Observable raised when current selected mesh gets unselected
  57049. */
  57050. onSelectedMeshUnselected: Observable<AbstractMesh>;
  57051. private _raySelectionPredicate;
  57052. /**
  57053. * To be optionally changed by user to define custom ray selection
  57054. */
  57055. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  57056. /**
  57057. * To be optionally changed by user to define custom selection logic (after ray selection)
  57058. */
  57059. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57060. /**
  57061. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  57062. */
  57063. teleportationEnabled: boolean;
  57064. private _defaultHeight;
  57065. private _teleportationInitialized;
  57066. private _interactionsEnabled;
  57067. private _interactionsRequested;
  57068. private _displayGaze;
  57069. private _displayLaserPointer;
  57070. /**
  57071. * The mesh used to display where the user is going to teleport.
  57072. */
  57073. get teleportationTarget(): Mesh;
  57074. /**
  57075. * Sets the mesh to be used to display where the user is going to teleport.
  57076. */
  57077. set teleportationTarget(value: Mesh);
  57078. /**
  57079. * 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
  57080. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  57081. * See https://doc.babylonjs.com/resources/baking_transformations
  57082. */
  57083. get gazeTrackerMesh(): Mesh;
  57084. set gazeTrackerMesh(value: Mesh);
  57085. /**
  57086. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  57087. */
  57088. updateGazeTrackerScale: boolean;
  57089. /**
  57090. * If the gaze trackers color should be updated when selecting meshes
  57091. */
  57092. updateGazeTrackerColor: boolean;
  57093. /**
  57094. * If the controller laser color should be updated when selecting meshes
  57095. */
  57096. updateControllerLaserColor: boolean;
  57097. /**
  57098. * The gaze tracking mesh corresponding to the left controller
  57099. */
  57100. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  57101. /**
  57102. * The gaze tracking mesh corresponding to the right controller
  57103. */
  57104. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  57105. /**
  57106. * If the ray of the gaze should be displayed.
  57107. */
  57108. get displayGaze(): boolean;
  57109. /**
  57110. * Sets if the ray of the gaze should be displayed.
  57111. */
  57112. set displayGaze(value: boolean);
  57113. /**
  57114. * If the ray of the LaserPointer should be displayed.
  57115. */
  57116. get displayLaserPointer(): boolean;
  57117. /**
  57118. * Sets if the ray of the LaserPointer should be displayed.
  57119. */
  57120. set displayLaserPointer(value: boolean);
  57121. /**
  57122. * The deviceOrientationCamera used as the camera when not in VR.
  57123. */
  57124. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  57125. /**
  57126. * Based on the current WebVR support, returns the current VR camera used.
  57127. */
  57128. get currentVRCamera(): Nullable<Camera>;
  57129. /**
  57130. * The webVRCamera which is used when in VR.
  57131. */
  57132. get webVRCamera(): WebVRFreeCamera;
  57133. /**
  57134. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  57135. */
  57136. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  57137. /**
  57138. * The html button that is used to trigger entering into VR.
  57139. */
  57140. get vrButton(): Nullable<HTMLButtonElement>;
  57141. private get _teleportationRequestInitiated();
  57142. /**
  57143. * Defines whether or not Pointer lock should be requested when switching to
  57144. * full screen.
  57145. */
  57146. requestPointerLockOnFullScreen: boolean;
  57147. /**
  57148. * If asking to force XR, this will be populated with the default xr experience
  57149. */
  57150. xr: WebXRDefaultExperience;
  57151. /**
  57152. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  57153. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  57154. */
  57155. xrTestDone: boolean;
  57156. /**
  57157. * Instantiates a VRExperienceHelper.
  57158. * Helps to quickly add VR support to an existing scene.
  57159. * @param scene The scene the VRExperienceHelper belongs to.
  57160. * @param webVROptions Options to modify the vr experience helper's behavior.
  57161. */
  57162. constructor(scene: Scene,
  57163. /** Options to modify the vr experience helper's behavior. */
  57164. webVROptions?: VRExperienceHelperOptions);
  57165. private completeVRInit;
  57166. private _onDefaultMeshLoaded;
  57167. private _onResize;
  57168. private _onFullscreenChange;
  57169. /**
  57170. * Gets a value indicating if we are currently in VR mode.
  57171. */
  57172. get isInVRMode(): boolean;
  57173. private onVrDisplayPresentChange;
  57174. private onVRDisplayChanged;
  57175. private moveButtonToBottomRight;
  57176. private displayVRButton;
  57177. private updateButtonVisibility;
  57178. private _cachedAngularSensibility;
  57179. /**
  57180. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  57181. * Otherwise, will use the fullscreen API.
  57182. */
  57183. enterVR(): void;
  57184. /**
  57185. * Attempt to exit VR, or fullscreen.
  57186. */
  57187. exitVR(): void;
  57188. /**
  57189. * The position of the vr experience helper.
  57190. */
  57191. get position(): Vector3;
  57192. /**
  57193. * Sets the position of the vr experience helper.
  57194. */
  57195. set position(value: Vector3);
  57196. /**
  57197. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  57198. */
  57199. enableInteractions(): void;
  57200. private get _noControllerIsActive();
  57201. private beforeRender;
  57202. private _isTeleportationFloor;
  57203. /**
  57204. * Adds a floor mesh to be used for teleportation.
  57205. * @param floorMesh the mesh to be used for teleportation.
  57206. */
  57207. addFloorMesh(floorMesh: Mesh): void;
  57208. /**
  57209. * Removes a floor mesh from being used for teleportation.
  57210. * @param floorMesh the mesh to be removed.
  57211. */
  57212. removeFloorMesh(floorMesh: Mesh): void;
  57213. /**
  57214. * Enables interactions and teleportation using the VR controllers and gaze.
  57215. * @param vrTeleportationOptions options to modify teleportation behavior.
  57216. */
  57217. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  57218. private _onNewGamepadConnected;
  57219. private _tryEnableInteractionOnController;
  57220. private _onNewGamepadDisconnected;
  57221. private _enableInteractionOnController;
  57222. private _checkTeleportWithRay;
  57223. private _checkRotate;
  57224. private _checkTeleportBackwards;
  57225. private _enableTeleportationOnController;
  57226. private _createTeleportationCircles;
  57227. private _displayTeleportationTarget;
  57228. private _hideTeleportationTarget;
  57229. private _rotateCamera;
  57230. private _moveTeleportationSelectorTo;
  57231. private _workingVector;
  57232. private _workingQuaternion;
  57233. private _workingMatrix;
  57234. /**
  57235. * Time Constant Teleportation Mode
  57236. */
  57237. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  57238. /**
  57239. * Speed Constant Teleportation Mode
  57240. */
  57241. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  57242. /**
  57243. * Teleports the users feet to the desired location
  57244. * @param location The location where the user's feet should be placed
  57245. */
  57246. teleportCamera(location: Vector3): void;
  57247. private _convertNormalToDirectionOfRay;
  57248. private _castRayAndSelectObject;
  57249. private _notifySelectedMeshUnselected;
  57250. /**
  57251. * Permanently set new colors for the laser pointer
  57252. * @param color the new laser color
  57253. * @param pickedColor the new laser color when picked mesh detected
  57254. */
  57255. setLaserColor(color: Color3, pickedColor?: Color3): void;
  57256. /**
  57257. * Set lighting enabled / disabled on the laser pointer of both controllers
  57258. * @param enabled should the lighting be enabled on the laser pointer
  57259. */
  57260. setLaserLightingState(enabled?: boolean): void;
  57261. /**
  57262. * Permanently set new colors for the gaze pointer
  57263. * @param color the new gaze color
  57264. * @param pickedColor the new gaze color when picked mesh detected
  57265. */
  57266. setGazeColor(color: Color3, pickedColor?: Color3): void;
  57267. /**
  57268. * Sets the color of the laser ray from the vr controllers.
  57269. * @param color new color for the ray.
  57270. */
  57271. changeLaserColor(color: Color3): void;
  57272. /**
  57273. * Sets the color of the ray from the vr headsets gaze.
  57274. * @param color new color for the ray.
  57275. */
  57276. changeGazeColor(color: Color3): void;
  57277. /**
  57278. * Exits VR and disposes of the vr experience helper
  57279. */
  57280. dispose(): void;
  57281. /**
  57282. * Gets the name of the VRExperienceHelper class
  57283. * @returns "VRExperienceHelper"
  57284. */
  57285. getClassName(): string;
  57286. }
  57287. }
  57288. declare module BABYLON {
  57289. /**
  57290. * Contains an array of blocks representing the octree
  57291. */
  57292. export interface IOctreeContainer<T> {
  57293. /**
  57294. * Blocks within the octree
  57295. */
  57296. blocks: Array<OctreeBlock<T>>;
  57297. }
  57298. /**
  57299. * Class used to store a cell in an octree
  57300. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57301. */
  57302. export class OctreeBlock<T> {
  57303. /**
  57304. * Gets the content of the current block
  57305. */
  57306. entries: T[];
  57307. /**
  57308. * Gets the list of block children
  57309. */
  57310. blocks: Array<OctreeBlock<T>>;
  57311. private _depth;
  57312. private _maxDepth;
  57313. private _capacity;
  57314. private _minPoint;
  57315. private _maxPoint;
  57316. private _boundingVectors;
  57317. private _creationFunc;
  57318. /**
  57319. * Creates a new block
  57320. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  57321. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  57322. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57323. * @param depth defines the current depth of this block in the octree
  57324. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  57325. * @param creationFunc defines a callback to call when an element is added to the block
  57326. */
  57327. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  57328. /**
  57329. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  57330. */
  57331. get capacity(): number;
  57332. /**
  57333. * Gets the minimum vector (in world space) of the block's bounding box
  57334. */
  57335. get minPoint(): Vector3;
  57336. /**
  57337. * Gets the maximum vector (in world space) of the block's bounding box
  57338. */
  57339. get maxPoint(): Vector3;
  57340. /**
  57341. * Add a new element to this block
  57342. * @param entry defines the element to add
  57343. */
  57344. addEntry(entry: T): void;
  57345. /**
  57346. * Remove an element from this block
  57347. * @param entry defines the element to remove
  57348. */
  57349. removeEntry(entry: T): void;
  57350. /**
  57351. * Add an array of elements to this block
  57352. * @param entries defines the array of elements to add
  57353. */
  57354. addEntries(entries: T[]): void;
  57355. /**
  57356. * Test if the current block intersects the frustum planes and if yes, then add its content to the selection array
  57357. * @param frustumPlanes defines the frustum planes to test
  57358. * @param selection defines the array to store current content if selection is positive
  57359. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57360. */
  57361. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57362. /**
  57363. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  57364. * @param sphereCenter defines the bounding sphere center
  57365. * @param sphereRadius defines the bounding sphere radius
  57366. * @param selection defines the array to store current content if selection is positive
  57367. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57368. */
  57369. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  57370. /**
  57371. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  57372. * @param ray defines the ray to test with
  57373. * @param selection defines the array to store current content if selection is positive
  57374. */
  57375. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  57376. /**
  57377. * Subdivide the content into child blocks (this block will then be empty)
  57378. */
  57379. createInnerBlocks(): void;
  57380. /**
  57381. * @hidden
  57382. */
  57383. 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;
  57384. }
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  57389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57390. */
  57391. export class Octree<T> {
  57392. /** 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.) */
  57393. maxDepth: number;
  57394. /**
  57395. * Blocks within the octree containing objects
  57396. */
  57397. blocks: Array<OctreeBlock<T>>;
  57398. /**
  57399. * Content stored in the octree
  57400. */
  57401. dynamicContent: T[];
  57402. private _maxBlockCapacity;
  57403. private _selectionContent;
  57404. private _creationFunc;
  57405. /**
  57406. * Creates a octree
  57407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57408. * @param creationFunc function to be used to instantiate the octree
  57409. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  57410. * @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.)
  57411. */
  57412. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  57413. /** 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.) */
  57414. maxDepth?: number);
  57415. /**
  57416. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  57417. * @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);
  57418. * @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);
  57419. * @param entries meshes to be added to the octree blocks
  57420. */
  57421. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  57422. /**
  57423. * Adds a mesh to the octree
  57424. * @param entry Mesh to add to the octree
  57425. */
  57426. addMesh(entry: T): void;
  57427. /**
  57428. * Remove an element from the octree
  57429. * @param entry defines the element to remove
  57430. */
  57431. removeMesh(entry: T): void;
  57432. /**
  57433. * Selects an array of meshes within the frustum
  57434. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  57435. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  57436. * @returns array of meshes within the frustum
  57437. */
  57438. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  57439. /**
  57440. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  57441. * @param sphereCenter defines the bounding sphere center
  57442. * @param sphereRadius defines the bounding sphere radius
  57443. * @param allowDuplicate defines if the selection array can contains duplicated entries
  57444. * @returns an array of objects that intersect the sphere
  57445. */
  57446. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  57447. /**
  57448. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  57449. * @param ray defines the ray to test with
  57450. * @returns array of intersected objects
  57451. */
  57452. intersectsRay(ray: Ray): SmartArray<T>;
  57453. /**
  57454. * Adds a mesh into the octree block if it intersects the block
  57455. */
  57456. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  57457. /**
  57458. * Adds a submesh into the octree block if it intersects the block
  57459. */
  57460. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  57461. }
  57462. }
  57463. declare module BABYLON {
  57464. interface Scene {
  57465. /**
  57466. * @hidden
  57467. * Backing Filed
  57468. */
  57469. _selectionOctree: Octree<AbstractMesh>;
  57470. /**
  57471. * Gets the octree used to boost mesh selection (picking)
  57472. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57473. */
  57474. selectionOctree: Octree<AbstractMesh>;
  57475. /**
  57476. * Creates or updates the octree used to boost selection (picking)
  57477. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57478. * @param maxCapacity defines the maximum capacity per leaf
  57479. * @param maxDepth defines the maximum depth of the octree
  57480. * @returns an octree of AbstractMesh
  57481. */
  57482. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  57483. }
  57484. interface AbstractMesh {
  57485. /**
  57486. * @hidden
  57487. * Backing Field
  57488. */
  57489. _submeshesOctree: Octree<SubMesh>;
  57490. /**
  57491. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  57492. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  57493. * @param maxCapacity defines the maximum size of each block (64 by default)
  57494. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  57495. * @returns the new octree
  57496. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  57497. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  57498. */
  57499. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  57500. }
  57501. /**
  57502. * Defines the octree scene component responsible to manage any octrees
  57503. * in a given scene.
  57504. */
  57505. export class OctreeSceneComponent {
  57506. /**
  57507. * The component name help to identify the component in the list of scene components.
  57508. */
  57509. readonly name: string;
  57510. /**
  57511. * The scene the component belongs to.
  57512. */
  57513. scene: Scene;
  57514. /**
  57515. * Indicates if the meshes have been checked to make sure they are isEnabled()
  57516. */
  57517. readonly checksIsEnabled: boolean;
  57518. /**
  57519. * Creates a new instance of the component for the given scene
  57520. * @param scene Defines the scene to register the component in
  57521. */
  57522. constructor(scene: Scene);
  57523. /**
  57524. * Registers the component in a given scene
  57525. */
  57526. register(): void;
  57527. /**
  57528. * Return the list of active meshes
  57529. * @returns the list of active meshes
  57530. */
  57531. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  57532. /**
  57533. * Return the list of active sub meshes
  57534. * @param mesh The mesh to get the candidates sub meshes from
  57535. * @returns the list of active sub meshes
  57536. */
  57537. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  57538. private _tempRay;
  57539. /**
  57540. * Return the list of sub meshes intersecting with a given local ray
  57541. * @param mesh defines the mesh to find the submesh for
  57542. * @param localRay defines the ray in local space
  57543. * @returns the list of intersecting sub meshes
  57544. */
  57545. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  57546. /**
  57547. * Return the list of sub meshes colliding with a collider
  57548. * @param mesh defines the mesh to find the submesh for
  57549. * @param collider defines the collider to evaluate the collision against
  57550. * @returns the list of colliding sub meshes
  57551. */
  57552. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  57553. /**
  57554. * Rebuilds the elements related to this component in case of
  57555. * context lost for instance.
  57556. */
  57557. rebuild(): void;
  57558. /**
  57559. * Disposes the component and the associated resources.
  57560. */
  57561. dispose(): void;
  57562. }
  57563. }
  57564. declare module BABYLON {
  57565. /**
  57566. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  57567. */
  57568. export interface GizmoAxisCache {
  57569. /** Mesh used to render the Gizmo */
  57570. gizmoMeshes: Mesh[];
  57571. /** Mesh used to detect user interaction with Gizmo */
  57572. colliderMeshes: Mesh[];
  57573. /** Material used to indicate color of gizmo mesh */
  57574. material: StandardMaterial;
  57575. /** Material used to indicate hover state of the Gizmo */
  57576. hoverMaterial: StandardMaterial;
  57577. /** Material used to indicate disabled state of the Gizmo */
  57578. disableMaterial: StandardMaterial;
  57579. /** Used to indicate Active state of the Gizmo */
  57580. active: boolean;
  57581. }
  57582. /**
  57583. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  57584. */
  57585. export class Gizmo implements IDisposable {
  57586. /** The utility layer the gizmo will be added to */
  57587. gizmoLayer: UtilityLayerRenderer;
  57588. /**
  57589. * The root mesh of the gizmo
  57590. */
  57591. _rootMesh: Mesh;
  57592. private _attachedMesh;
  57593. private _attachedNode;
  57594. /**
  57595. * Ratio for the scale of the gizmo (Default: 1)
  57596. */
  57597. protected _scaleRatio: number;
  57598. /**
  57599. * boolean updated by pointermove when a gizmo mesh is hovered
  57600. */
  57601. protected _isHovered: boolean;
  57602. /**
  57603. * Ratio for the scale of the gizmo (Default: 1)
  57604. */
  57605. set scaleRatio(value: number);
  57606. get scaleRatio(): number;
  57607. /**
  57608. * True when the mouse pointer is hovered a gizmo mesh
  57609. */
  57610. get isHovered(): boolean;
  57611. /**
  57612. * If a custom mesh has been set (Default: false)
  57613. */
  57614. protected _customMeshSet: boolean;
  57615. /**
  57616. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  57617. * * When set, interactions will be enabled
  57618. */
  57619. get attachedMesh(): Nullable<AbstractMesh>;
  57620. set attachedMesh(value: Nullable<AbstractMesh>);
  57621. /**
  57622. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  57623. * * When set, interactions will be enabled
  57624. */
  57625. get attachedNode(): Nullable<Node>;
  57626. set attachedNode(value: Nullable<Node>);
  57627. /**
  57628. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57629. * @param mesh The mesh to replace the default mesh of the gizmo
  57630. */
  57631. setCustomMesh(mesh: Mesh): void;
  57632. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  57633. /**
  57634. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  57635. */
  57636. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57637. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57638. /**
  57639. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  57640. */
  57641. updateGizmoPositionToMatchAttachedMesh: boolean;
  57642. /**
  57643. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  57644. */
  57645. updateScale: boolean;
  57646. protected _interactionsEnabled: boolean;
  57647. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57648. private _beforeRenderObserver;
  57649. private _tempQuaternion;
  57650. private _tempVector;
  57651. private _tempVector2;
  57652. private _tempMatrix1;
  57653. private _tempMatrix2;
  57654. private _rightHandtoLeftHandMatrix;
  57655. /**
  57656. * Creates a gizmo
  57657. * @param gizmoLayer The utility layer the gizmo will be added to
  57658. */
  57659. constructor(
  57660. /** The utility layer the gizmo will be added to */
  57661. gizmoLayer?: UtilityLayerRenderer);
  57662. /**
  57663. * Updates the gizmo to match the attached mesh's position/rotation
  57664. */
  57665. protected _update(): void;
  57666. /**
  57667. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  57668. * @param value Node, TransformNode or mesh
  57669. */
  57670. protected _matrixChanged(): void;
  57671. /**
  57672. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57673. * @param gizmoLayer The utility layer the gizmo will be added to
  57674. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57675. * @returns {Observer<PointerInfo>} pointerObserver
  57676. */
  57677. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57678. /**
  57679. * Disposes of the gizmo
  57680. */
  57681. dispose(): void;
  57682. }
  57683. }
  57684. declare module BABYLON {
  57685. /**
  57686. * Single plane drag gizmo
  57687. */
  57688. export class PlaneDragGizmo extends Gizmo {
  57689. /**
  57690. * Drag behavior responsible for the gizmos dragging interactions
  57691. */
  57692. dragBehavior: PointerDragBehavior;
  57693. private _pointerObserver;
  57694. /**
  57695. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57696. */
  57697. snapDistance: number;
  57698. /**
  57699. * Event that fires each time the gizmo snaps to a new location.
  57700. * * snapDistance is the the change in distance
  57701. */
  57702. onSnapObservable: Observable<{
  57703. snapDistance: number;
  57704. }>;
  57705. private _gizmoMesh;
  57706. private _coloredMaterial;
  57707. private _hoverMaterial;
  57708. private _disableMaterial;
  57709. private _isEnabled;
  57710. private _parent;
  57711. private _dragging;
  57712. /** @hidden */
  57713. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57714. /**
  57715. * Creates a PlaneDragGizmo
  57716. * @param gizmoLayer The utility layer the gizmo will be added to
  57717. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57718. * @param color The color of the gizmo
  57719. */
  57720. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57721. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57722. /**
  57723. * If the gizmo is enabled
  57724. */
  57725. set isEnabled(value: boolean);
  57726. get isEnabled(): boolean;
  57727. /**
  57728. * Disposes of the gizmo
  57729. */
  57730. dispose(): void;
  57731. }
  57732. }
  57733. declare module BABYLON {
  57734. /**
  57735. * Single plane rotation gizmo
  57736. */
  57737. export class PlaneRotationGizmo extends Gizmo {
  57738. /**
  57739. * Drag behavior responsible for the gizmos dragging interactions
  57740. */
  57741. dragBehavior: PointerDragBehavior;
  57742. private _pointerObserver;
  57743. /**
  57744. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57745. */
  57746. snapDistance: number;
  57747. /**
  57748. * Event that fires each time the gizmo snaps to a new location.
  57749. * * snapDistance is the the change in distance
  57750. */
  57751. onSnapObservable: Observable<{
  57752. snapDistance: number;
  57753. }>;
  57754. private _isEnabled;
  57755. private _parent;
  57756. private _coloredMaterial;
  57757. private _hoverMaterial;
  57758. private _disableMaterial;
  57759. private _gizmoMesh;
  57760. private _rotationCircle;
  57761. private _dragging;
  57762. private static _CircleConstants;
  57763. /**
  57764. * Creates a PlaneRotationGizmo
  57765. * @param gizmoLayer The utility layer the gizmo will be added to
  57766. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57767. * @param color The color of the gizmo
  57768. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57769. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57770. * @param thickness display gizmo axis thickness
  57771. */
  57772. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57773. /** Create Geometry for Gizmo */
  57774. private _createGizmoMesh;
  57775. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57776. private setupRotationCircle;
  57777. private updateRotationPath;
  57778. private updateRotationCircle;
  57779. /**
  57780. * If the gizmo is enabled
  57781. */
  57782. set isEnabled(value: boolean);
  57783. get isEnabled(): boolean;
  57784. /**
  57785. * Disposes of the gizmo
  57786. */
  57787. dispose(): void;
  57788. }
  57789. }
  57790. declare module BABYLON {
  57791. /**
  57792. * Gizmo that enables rotating a mesh along 3 axis
  57793. */
  57794. export class RotationGizmo extends Gizmo {
  57795. /**
  57796. * Internal gizmo used for interactions on the x axis
  57797. */
  57798. xGizmo: PlaneRotationGizmo;
  57799. /**
  57800. * Internal gizmo used for interactions on the y axis
  57801. */
  57802. yGizmo: PlaneRotationGizmo;
  57803. /**
  57804. * Internal gizmo used for interactions on the z axis
  57805. */
  57806. zGizmo: PlaneRotationGizmo;
  57807. /** Fires an event when any of it's sub gizmos are dragged */
  57808. onDragStartObservable: Observable<unknown>;
  57809. /** Fires an event when any of it's sub gizmos are released from dragging */
  57810. onDragEndObservable: Observable<unknown>;
  57811. private _meshAttached;
  57812. private _nodeAttached;
  57813. private _observables;
  57814. /** Node Caching for quick lookup */
  57815. private _gizmoAxisCache;
  57816. get attachedMesh(): Nullable<AbstractMesh>;
  57817. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57818. get attachedNode(): Nullable<Node>;
  57819. set attachedNode(node: Nullable<Node>);
  57820. protected _checkBillboardTransform(): void;
  57821. /**
  57822. * True when the mouse pointer is hovering a gizmo mesh
  57823. */
  57824. get isHovered(): boolean;
  57825. /**
  57826. * Creates a RotationGizmo
  57827. * @param gizmoLayer The utility layer the gizmo will be added to
  57828. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57829. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57830. * @param thickness display gizmo axis thickness
  57831. */
  57832. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57833. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57834. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57835. /**
  57836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57837. */
  57838. set snapDistance(value: number);
  57839. get snapDistance(): number;
  57840. /**
  57841. * Ratio for the scale of the gizmo (Default: 1)
  57842. */
  57843. set scaleRatio(value: number);
  57844. get scaleRatio(): number;
  57845. /**
  57846. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57847. * @param mesh Axis gizmo mesh
  57848. * @param cache Gizmo axis definition used for reactive gizmo UI
  57849. */
  57850. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57851. /**
  57852. * Disposes of the gizmo
  57853. */
  57854. dispose(): void;
  57855. /**
  57856. * CustomMeshes are not supported by this gizmo
  57857. * @param mesh The mesh to replace the default mesh of the gizmo
  57858. */
  57859. setCustomMesh(mesh: Mesh): void;
  57860. }
  57861. }
  57862. declare module BABYLON {
  57863. /**
  57864. * Class containing static functions to help procedurally build meshes
  57865. */
  57866. export class PolyhedronBuilder {
  57867. /**
  57868. * Creates a polyhedron mesh
  57869. * * 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
  57870. * * The parameter `size` (positive float, default 1) sets the polygon size
  57871. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57872. * * 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`
  57873. * * 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
  57874. * * 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)`)
  57875. * * 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
  57876. * * 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
  57877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57878. * * 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
  57879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57880. * @param name defines the name of the mesh
  57881. * @param options defines the options used to create the mesh
  57882. * @param scene defines the hosting scene
  57883. * @returns the polyhedron mesh
  57884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57885. */
  57886. static CreatePolyhedron(name: string, options: {
  57887. type?: number;
  57888. size?: number;
  57889. sizeX?: number;
  57890. sizeY?: number;
  57891. sizeZ?: number;
  57892. custom?: any;
  57893. faceUV?: Vector4[];
  57894. faceColors?: Color4[];
  57895. flat?: boolean;
  57896. updatable?: boolean;
  57897. sideOrientation?: number;
  57898. frontUVs?: Vector4;
  57899. backUVs?: Vector4;
  57900. }, scene?: Nullable<Scene>): Mesh;
  57901. }
  57902. }
  57903. declare module BABYLON {
  57904. /**
  57905. * Class containing static functions to help procedurally build meshes
  57906. */
  57907. export class BoxBuilder {
  57908. /**
  57909. * Creates a box mesh
  57910. * * The parameter `size` sets the size (float) of each box side (default 1)
  57911. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57912. * * 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)
  57913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57915. * * 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
  57916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57917. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57918. * @param name defines the name of the mesh
  57919. * @param options defines the options used to create the mesh
  57920. * @param scene defines the hosting scene
  57921. * @returns the box mesh
  57922. */
  57923. static CreateBox(name: string, options: {
  57924. size?: number;
  57925. width?: number;
  57926. height?: number;
  57927. depth?: number;
  57928. faceUV?: Vector4[];
  57929. faceColors?: Color4[];
  57930. sideOrientation?: number;
  57931. frontUVs?: Vector4;
  57932. backUVs?: Vector4;
  57933. wrap?: boolean;
  57934. topBaseAt?: number;
  57935. bottomBaseAt?: number;
  57936. updatable?: boolean;
  57937. }, scene?: Nullable<Scene>): Mesh;
  57938. }
  57939. }
  57940. declare module BABYLON {
  57941. /**
  57942. * Single axis scale gizmo
  57943. */
  57944. export class AxisScaleGizmo extends Gizmo {
  57945. /**
  57946. * Drag behavior responsible for the gizmos dragging interactions
  57947. */
  57948. dragBehavior: PointerDragBehavior;
  57949. private _pointerObserver;
  57950. /**
  57951. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57952. */
  57953. snapDistance: number;
  57954. /**
  57955. * Event that fires each time the gizmo snaps to a new location.
  57956. * * snapDistance is the the change in distance
  57957. */
  57958. onSnapObservable: Observable<{
  57959. snapDistance: number;
  57960. }>;
  57961. /**
  57962. * If the scaling operation should be done on all axis (default: false)
  57963. */
  57964. uniformScaling: boolean;
  57965. /**
  57966. * Custom sensitivity value for the drag strength
  57967. */
  57968. sensitivity: number;
  57969. private _isEnabled;
  57970. private _parent;
  57971. private _gizmoMesh;
  57972. private _coloredMaterial;
  57973. private _hoverMaterial;
  57974. private _disableMaterial;
  57975. private _dragging;
  57976. private _tmpVector;
  57977. private _tmpMatrix;
  57978. private _tmpMatrix2;
  57979. /**
  57980. * Creates an AxisScaleGizmo
  57981. * @param gizmoLayer The utility layer the gizmo will be added to
  57982. * @param dragAxis The axis which the gizmo will be able to scale on
  57983. * @param color The color of the gizmo
  57984. * @param thickness display gizmo axis thickness
  57985. */
  57986. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57987. /** Create Geometry for Gizmo */
  57988. private _createGizmoMesh;
  57989. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57990. /**
  57991. * If the gizmo is enabled
  57992. */
  57993. set isEnabled(value: boolean);
  57994. get isEnabled(): boolean;
  57995. /**
  57996. * Disposes of the gizmo
  57997. */
  57998. dispose(): void;
  57999. /**
  58000. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  58001. * @param mesh The mesh to replace the default mesh of the gizmo
  58002. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  58003. */
  58004. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  58005. }
  58006. }
  58007. declare module BABYLON {
  58008. /**
  58009. * Gizmo that enables scaling a mesh along 3 axis
  58010. */
  58011. export class ScaleGizmo extends Gizmo {
  58012. /**
  58013. * Internal gizmo used for interactions on the x axis
  58014. */
  58015. xGizmo: AxisScaleGizmo;
  58016. /**
  58017. * Internal gizmo used for interactions on the y axis
  58018. */
  58019. yGizmo: AxisScaleGizmo;
  58020. /**
  58021. * Internal gizmo used for interactions on the z axis
  58022. */
  58023. zGizmo: AxisScaleGizmo;
  58024. /**
  58025. * Internal gizmo used to scale all axis equally
  58026. */
  58027. uniformScaleGizmo: AxisScaleGizmo;
  58028. private _meshAttached;
  58029. private _nodeAttached;
  58030. private _snapDistance;
  58031. private _uniformScalingMesh;
  58032. private _octahedron;
  58033. private _sensitivity;
  58034. private _coloredMaterial;
  58035. private _hoverMaterial;
  58036. private _disableMaterial;
  58037. private _observables;
  58038. /** Node Caching for quick lookup */
  58039. private _gizmoAxisCache;
  58040. /** Fires an event when any of it's sub gizmos are dragged */
  58041. onDragStartObservable: Observable<unknown>;
  58042. /** Fires an event when any of it's sub gizmos are released from dragging */
  58043. onDragEndObservable: Observable<unknown>;
  58044. get attachedMesh(): Nullable<AbstractMesh>;
  58045. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58046. get attachedNode(): Nullable<Node>;
  58047. set attachedNode(node: Nullable<Node>);
  58048. /**
  58049. * True when the mouse pointer is hovering a gizmo mesh
  58050. */
  58051. get isHovered(): boolean;
  58052. /**
  58053. * Creates a ScaleGizmo
  58054. * @param gizmoLayer The utility layer the gizmo will be added to
  58055. * @param thickness display gizmo axis thickness
  58056. */
  58057. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58058. /** Create Geometry for Gizmo */
  58059. private _createUniformScaleMesh;
  58060. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58061. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58062. /**
  58063. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58064. */
  58065. set snapDistance(value: number);
  58066. get snapDistance(): number;
  58067. /**
  58068. * Ratio for the scale of the gizmo (Default: 1)
  58069. */
  58070. set scaleRatio(value: number);
  58071. get scaleRatio(): number;
  58072. /**
  58073. * Sensitivity factor for dragging (Default: 1)
  58074. */
  58075. set sensitivity(value: number);
  58076. get sensitivity(): number;
  58077. /**
  58078. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58079. * @param mesh Axis gizmo mesh
  58080. * @param cache Gizmo axis definition used for reactive gizmo UI
  58081. */
  58082. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58083. /**
  58084. * Disposes of the gizmo
  58085. */
  58086. dispose(): void;
  58087. }
  58088. }
  58089. declare module BABYLON {
  58090. /**
  58091. * Bounding box gizmo
  58092. */
  58093. export class BoundingBoxGizmo extends Gizmo {
  58094. private _lineBoundingBox;
  58095. private _rotateSpheresParent;
  58096. private _scaleBoxesParent;
  58097. private _boundingDimensions;
  58098. private _renderObserver;
  58099. private _pointerObserver;
  58100. private _scaleDragSpeed;
  58101. private _tmpQuaternion;
  58102. private _tmpVector;
  58103. private _tmpRotationMatrix;
  58104. /**
  58105. * 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)
  58106. */
  58107. ignoreChildren: boolean;
  58108. /**
  58109. * 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)
  58110. */
  58111. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  58112. /**
  58113. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  58114. */
  58115. rotationSphereSize: number;
  58116. /**
  58117. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  58118. */
  58119. scaleBoxSize: number;
  58120. /**
  58121. * 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)
  58122. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58123. */
  58124. fixedDragMeshScreenSize: boolean;
  58125. /**
  58126. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  58127. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  58128. */
  58129. fixedDragMeshBoundsSize: boolean;
  58130. /**
  58131. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  58132. */
  58133. fixedDragMeshScreenSizeDistanceFactor: number;
  58134. /**
  58135. * Fired when a rotation sphere or scale box is dragged
  58136. */
  58137. onDragStartObservable: Observable<{}>;
  58138. /**
  58139. * Fired when a scale box is dragged
  58140. */
  58141. onScaleBoxDragObservable: Observable<{}>;
  58142. /**
  58143. * Fired when a scale box drag is ended
  58144. */
  58145. onScaleBoxDragEndObservable: Observable<{}>;
  58146. /**
  58147. * Fired when a rotation sphere is dragged
  58148. */
  58149. onRotationSphereDragObservable: Observable<{}>;
  58150. /**
  58151. * Fired when a rotation sphere drag is ended
  58152. */
  58153. onRotationSphereDragEndObservable: Observable<{}>;
  58154. /**
  58155. * 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)
  58156. */
  58157. scalePivot: Nullable<Vector3>;
  58158. /**
  58159. * Mesh used as a pivot to rotate the attached node
  58160. */
  58161. private _anchorMesh;
  58162. private _existingMeshScale;
  58163. private _dragMesh;
  58164. private pointerDragBehavior;
  58165. private coloredMaterial;
  58166. private hoverColoredMaterial;
  58167. /**
  58168. * Sets the color of the bounding box gizmo
  58169. * @param color the color to set
  58170. */
  58171. setColor(color: Color3): void;
  58172. /**
  58173. * Creates an BoundingBoxGizmo
  58174. * @param gizmoLayer The utility layer the gizmo will be added to
  58175. * @param color The color of the gizmo
  58176. */
  58177. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  58178. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  58179. private _selectNode;
  58180. /**
  58181. * Updates the bounding box information for the Gizmo
  58182. */
  58183. updateBoundingBox(): void;
  58184. private _updateRotationSpheres;
  58185. private _updateScaleBoxes;
  58186. /**
  58187. * Enables rotation on the specified axis and disables rotation on the others
  58188. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  58189. */
  58190. setEnabledRotationAxis(axis: string): void;
  58191. /**
  58192. * Enables/disables scaling
  58193. * @param enable if scaling should be enabled
  58194. * @param homogeneousScaling defines if scaling should only be homogeneous
  58195. */
  58196. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  58197. private _updateDummy;
  58198. /**
  58199. * Enables a pointer drag behavior on the bounding box of the gizmo
  58200. */
  58201. enableDragBehavior(): void;
  58202. /**
  58203. * Disposes of the gizmo
  58204. */
  58205. dispose(): void;
  58206. /**
  58207. * 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)
  58208. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  58209. * @returns the bounding box mesh with the passed in mesh as a child
  58210. */
  58211. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  58212. /**
  58213. * CustomMeshes are not supported by this gizmo
  58214. * @param mesh The mesh to replace the default mesh of the gizmo
  58215. */
  58216. setCustomMesh(mesh: Mesh): void;
  58217. }
  58218. }
  58219. declare module BABYLON {
  58220. /**
  58221. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  58222. */
  58223. export class GizmoManager implements IDisposable {
  58224. private scene;
  58225. /**
  58226. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  58227. */
  58228. gizmos: {
  58229. positionGizmo: Nullable<PositionGizmo>;
  58230. rotationGizmo: Nullable<RotationGizmo>;
  58231. scaleGizmo: Nullable<ScaleGizmo>;
  58232. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  58233. };
  58234. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  58235. clearGizmoOnEmptyPointerEvent: boolean;
  58236. /** Fires an event when the manager is attached to a mesh */
  58237. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  58238. /** Fires an event when the manager is attached to a node */
  58239. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  58240. private _gizmosEnabled;
  58241. private _pointerObservers;
  58242. private _attachedMesh;
  58243. private _attachedNode;
  58244. private _boundingBoxColor;
  58245. private _defaultUtilityLayer;
  58246. private _defaultKeepDepthUtilityLayer;
  58247. private _thickness;
  58248. /** Node Caching for quick lookup */
  58249. private _gizmoAxisCache;
  58250. /**
  58251. * When bounding box gizmo is enabled, this can be used to track drag/end events
  58252. */
  58253. boundingBoxDragBehavior: SixDofDragBehavior;
  58254. /**
  58255. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  58256. */
  58257. attachableMeshes: Nullable<Array<AbstractMesh>>;
  58258. /**
  58259. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  58260. */
  58261. attachableNodes: Nullable<Array<Node>>;
  58262. /**
  58263. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  58264. */
  58265. usePointerToAttachGizmos: boolean;
  58266. /**
  58267. * Utility layer that the bounding box gizmo belongs to
  58268. */
  58269. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  58270. /**
  58271. * Utility layer that all gizmos besides bounding box belong to
  58272. */
  58273. get utilityLayer(): UtilityLayerRenderer;
  58274. /**
  58275. * True when the mouse pointer is hovering a gizmo mesh
  58276. */
  58277. get isHovered(): boolean;
  58278. /**
  58279. * Instantiates a gizmo manager
  58280. * @param scene the scene to overlay the gizmos on top of
  58281. * @param thickness display gizmo axis thickness
  58282. * @param utilityLayer the layer where gizmos are rendered
  58283. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  58284. */
  58285. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  58286. /**
  58287. * Subscribes to pointer down events, for attaching and detaching mesh
  58288. * @param scene The scene layer the observer will be added to
  58289. */
  58290. private _attachToMeshPointerObserver;
  58291. /**
  58292. * Attaches a set of gizmos to the specified mesh
  58293. * @param mesh The mesh the gizmo's should be attached to
  58294. */
  58295. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58296. /**
  58297. * Attaches a set of gizmos to the specified node
  58298. * @param node The node the gizmo's should be attached to
  58299. */
  58300. attachToNode(node: Nullable<Node>): void;
  58301. /**
  58302. * If the position gizmo is enabled
  58303. */
  58304. set positionGizmoEnabled(value: boolean);
  58305. get positionGizmoEnabled(): boolean;
  58306. /**
  58307. * If the rotation gizmo is enabled
  58308. */
  58309. set rotationGizmoEnabled(value: boolean);
  58310. get rotationGizmoEnabled(): boolean;
  58311. /**
  58312. * If the scale gizmo is enabled
  58313. */
  58314. set scaleGizmoEnabled(value: boolean);
  58315. get scaleGizmoEnabled(): boolean;
  58316. /**
  58317. * If the boundingBox gizmo is enabled
  58318. */
  58319. set boundingBoxGizmoEnabled(value: boolean);
  58320. get boundingBoxGizmoEnabled(): boolean;
  58321. /**
  58322. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58323. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  58324. */
  58325. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  58326. /**
  58327. * Disposes of the gizmo manager
  58328. */
  58329. dispose(): void;
  58330. }
  58331. }
  58332. declare module BABYLON {
  58333. /**
  58334. * Gizmo that enables dragging a mesh along 3 axis
  58335. */
  58336. export class PositionGizmo extends Gizmo {
  58337. /**
  58338. * Internal gizmo used for interactions on the x axis
  58339. */
  58340. xGizmo: AxisDragGizmo;
  58341. /**
  58342. * Internal gizmo used for interactions on the y axis
  58343. */
  58344. yGizmo: AxisDragGizmo;
  58345. /**
  58346. * Internal gizmo used for interactions on the z axis
  58347. */
  58348. zGizmo: AxisDragGizmo;
  58349. /**
  58350. * Internal gizmo used for interactions on the yz plane
  58351. */
  58352. xPlaneGizmo: PlaneDragGizmo;
  58353. /**
  58354. * Internal gizmo used for interactions on the xz plane
  58355. */
  58356. yPlaneGizmo: PlaneDragGizmo;
  58357. /**
  58358. * Internal gizmo used for interactions on the xy plane
  58359. */
  58360. zPlaneGizmo: PlaneDragGizmo;
  58361. /**
  58362. * private variables
  58363. */
  58364. private _meshAttached;
  58365. private _nodeAttached;
  58366. private _snapDistance;
  58367. private _observables;
  58368. /** Node Caching for quick lookup */
  58369. private _gizmoAxisCache;
  58370. /** Fires an event when any of it's sub gizmos are dragged */
  58371. onDragStartObservable: Observable<unknown>;
  58372. /** Fires an event when any of it's sub gizmos are released from dragging */
  58373. onDragEndObservable: Observable<unknown>;
  58374. /**
  58375. * If set to true, planar drag is enabled
  58376. */
  58377. private _planarGizmoEnabled;
  58378. get attachedMesh(): Nullable<AbstractMesh>;
  58379. set attachedMesh(mesh: Nullable<AbstractMesh>);
  58380. get attachedNode(): Nullable<Node>;
  58381. set attachedNode(node: Nullable<Node>);
  58382. /**
  58383. * True when the mouse pointer is hovering a gizmo mesh
  58384. */
  58385. get isHovered(): boolean;
  58386. /**
  58387. * Creates a PositionGizmo
  58388. * @param gizmoLayer The utility layer the gizmo will be added to
  58389. @param thickness display gizmo axis thickness
  58390. */
  58391. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  58392. /**
  58393. * If the planar drag gizmo is enabled
  58394. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  58395. */
  58396. set planarGizmoEnabled(value: boolean);
  58397. get planarGizmoEnabled(): boolean;
  58398. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  58399. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  58400. /**
  58401. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58402. */
  58403. set snapDistance(value: number);
  58404. get snapDistance(): number;
  58405. /**
  58406. * Ratio for the scale of the gizmo (Default: 1)
  58407. */
  58408. set scaleRatio(value: number);
  58409. get scaleRatio(): number;
  58410. /**
  58411. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  58412. * @param mesh Axis gizmo mesh
  58413. * @param cache Gizmo axis definition used for reactive gizmo UI
  58414. */
  58415. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  58416. /**
  58417. * Disposes of the gizmo
  58418. */
  58419. dispose(): void;
  58420. /**
  58421. * CustomMeshes are not supported by this gizmo
  58422. * @param mesh The mesh to replace the default mesh of the gizmo
  58423. */
  58424. setCustomMesh(mesh: Mesh): void;
  58425. }
  58426. }
  58427. declare module BABYLON {
  58428. /**
  58429. * Single axis drag gizmo
  58430. */
  58431. export class AxisDragGizmo extends Gizmo {
  58432. /**
  58433. * Drag behavior responsible for the gizmos dragging interactions
  58434. */
  58435. dragBehavior: PointerDragBehavior;
  58436. private _pointerObserver;
  58437. /**
  58438. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  58439. */
  58440. snapDistance: number;
  58441. /**
  58442. * Event that fires each time the gizmo snaps to a new location.
  58443. * * snapDistance is the the change in distance
  58444. */
  58445. onSnapObservable: Observable<{
  58446. snapDistance: number;
  58447. }>;
  58448. private _isEnabled;
  58449. private _parent;
  58450. private _gizmoMesh;
  58451. private _coloredMaterial;
  58452. private _hoverMaterial;
  58453. private _disableMaterial;
  58454. private _dragging;
  58455. /** @hidden */
  58456. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  58457. /** @hidden */
  58458. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  58459. /**
  58460. * Creates an AxisDragGizmo
  58461. * @param gizmoLayer The utility layer the gizmo will be added to
  58462. * @param dragAxis The axis which the gizmo will be able to drag on
  58463. * @param color The color of the gizmo
  58464. * @param thickness display gizmo axis thickness
  58465. */
  58466. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  58467. protected _attachedNodeChanged(value: Nullable<Node>): void;
  58468. /**
  58469. * If the gizmo is enabled
  58470. */
  58471. set isEnabled(value: boolean);
  58472. get isEnabled(): boolean;
  58473. /**
  58474. * Disposes of the gizmo
  58475. */
  58476. dispose(): void;
  58477. }
  58478. }
  58479. declare module BABYLON.Debug {
  58480. /**
  58481. * The Axes viewer will show 3 axes in a specific point in space
  58482. */
  58483. export class AxesViewer {
  58484. private _xAxis;
  58485. private _yAxis;
  58486. private _zAxis;
  58487. private _scaleLinesFactor;
  58488. private _instanced;
  58489. /**
  58490. * Gets the hosting scene
  58491. */
  58492. scene: Nullable<Scene>;
  58493. /**
  58494. * Gets or sets a number used to scale line length
  58495. */
  58496. scaleLines: number;
  58497. /** Gets the node hierarchy used to render x-axis */
  58498. get xAxis(): TransformNode;
  58499. /** Gets the node hierarchy used to render y-axis */
  58500. get yAxis(): TransformNode;
  58501. /** Gets the node hierarchy used to render z-axis */
  58502. get zAxis(): TransformNode;
  58503. /**
  58504. * Creates a new AxesViewer
  58505. * @param scene defines the hosting scene
  58506. * @param scaleLines defines a number used to scale line length (1 by default)
  58507. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  58508. * @param xAxis defines the node hierarchy used to render the x-axis
  58509. * @param yAxis defines the node hierarchy used to render the y-axis
  58510. * @param zAxis defines the node hierarchy used to render the z-axis
  58511. */
  58512. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  58513. /**
  58514. * Force the viewer to update
  58515. * @param position defines the position of the viewer
  58516. * @param xaxis defines the x axis of the viewer
  58517. * @param yaxis defines the y axis of the viewer
  58518. * @param zaxis defines the z axis of the viewer
  58519. */
  58520. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  58521. /**
  58522. * Creates an instance of this axes viewer.
  58523. * @returns a new axes viewer with instanced meshes
  58524. */
  58525. createInstance(): AxesViewer;
  58526. /** Releases resources */
  58527. dispose(): void;
  58528. private static _SetRenderingGroupId;
  58529. }
  58530. }
  58531. declare module BABYLON.Debug {
  58532. /**
  58533. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  58534. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  58535. */
  58536. export class BoneAxesViewer extends AxesViewer {
  58537. /**
  58538. * Gets or sets the target mesh where to display the axes viewer
  58539. */
  58540. mesh: Nullable<Mesh>;
  58541. /**
  58542. * Gets or sets the target bone where to display the axes viewer
  58543. */
  58544. bone: Nullable<Bone>;
  58545. /** Gets current position */
  58546. pos: Vector3;
  58547. /** Gets direction of X axis */
  58548. xaxis: Vector3;
  58549. /** Gets direction of Y axis */
  58550. yaxis: Vector3;
  58551. /** Gets direction of Z axis */
  58552. zaxis: Vector3;
  58553. /**
  58554. * Creates a new BoneAxesViewer
  58555. * @param scene defines the hosting scene
  58556. * @param bone defines the target bone
  58557. * @param mesh defines the target mesh
  58558. * @param scaleLines defines a scaling factor for line length (1 by default)
  58559. */
  58560. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  58561. /**
  58562. * Force the viewer to update
  58563. */
  58564. update(): void;
  58565. /** Releases resources */
  58566. dispose(): void;
  58567. }
  58568. }
  58569. declare module BABYLON {
  58570. /**
  58571. * Interface used to define scene explorer extensibility option
  58572. */
  58573. export interface IExplorerExtensibilityOption {
  58574. /**
  58575. * Define the option label
  58576. */
  58577. label: string;
  58578. /**
  58579. * Defines the action to execute on click
  58580. */
  58581. action: (entity: any) => void;
  58582. }
  58583. /**
  58584. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  58585. */
  58586. export interface IExplorerExtensibilityGroup {
  58587. /**
  58588. * Defines a predicate to test if a given type mut be extended
  58589. */
  58590. predicate: (entity: any) => boolean;
  58591. /**
  58592. * Gets the list of options added to a type
  58593. */
  58594. entries: IExplorerExtensibilityOption[];
  58595. }
  58596. /**
  58597. * Interface used to define the options to use to create the Inspector
  58598. */
  58599. export interface IInspectorOptions {
  58600. /**
  58601. * Display in overlay mode (default: false)
  58602. */
  58603. overlay?: boolean;
  58604. /**
  58605. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  58606. */
  58607. globalRoot?: HTMLElement;
  58608. /**
  58609. * Display the Scene explorer
  58610. */
  58611. showExplorer?: boolean;
  58612. /**
  58613. * Display the property inspector
  58614. */
  58615. showInspector?: boolean;
  58616. /**
  58617. * Display in embed mode (both panes on the right)
  58618. */
  58619. embedMode?: boolean;
  58620. /**
  58621. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  58622. */
  58623. handleResize?: boolean;
  58624. /**
  58625. * Allow the panes to popup (default: true)
  58626. */
  58627. enablePopup?: boolean;
  58628. /**
  58629. * Allow the panes to be closed by users (default: true)
  58630. */
  58631. enableClose?: boolean;
  58632. /**
  58633. * Optional list of extensibility entries
  58634. */
  58635. explorerExtensibility?: IExplorerExtensibilityGroup[];
  58636. /**
  58637. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  58638. */
  58639. inspectorURL?: string;
  58640. /**
  58641. * Optional initial tab (default to DebugLayerTab.Properties)
  58642. */
  58643. initialTab?: DebugLayerTab;
  58644. }
  58645. interface Scene {
  58646. /**
  58647. * @hidden
  58648. * Backing field
  58649. */
  58650. _debugLayer: DebugLayer;
  58651. /**
  58652. * Gets the debug layer (aka Inspector) associated with the scene
  58653. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58654. */
  58655. debugLayer: DebugLayer;
  58656. }
  58657. /**
  58658. * Enum of inspector action tab
  58659. */
  58660. export enum DebugLayerTab {
  58661. /**
  58662. * Properties tag (default)
  58663. */
  58664. Properties = 0,
  58665. /**
  58666. * Debug tab
  58667. */
  58668. Debug = 1,
  58669. /**
  58670. * Statistics tab
  58671. */
  58672. Statistics = 2,
  58673. /**
  58674. * Tools tab
  58675. */
  58676. Tools = 3,
  58677. /**
  58678. * Settings tab
  58679. */
  58680. Settings = 4
  58681. }
  58682. /**
  58683. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58684. * what is happening in your scene
  58685. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58686. */
  58687. export class DebugLayer {
  58688. /**
  58689. * Define the url to get the inspector script from.
  58690. * By default it uses the babylonjs CDN.
  58691. * @ignoreNaming
  58692. */
  58693. static InspectorURL: string;
  58694. private _scene;
  58695. private BJSINSPECTOR;
  58696. private _onPropertyChangedObservable?;
  58697. /**
  58698. * Observable triggered when a property is changed through the inspector.
  58699. */
  58700. get onPropertyChangedObservable(): any;
  58701. /**
  58702. * Instantiates a new debug layer.
  58703. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58704. * what is happening in your scene
  58705. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58706. * @param scene Defines the scene to inspect
  58707. */
  58708. constructor(scene: Scene);
  58709. /** Creates the inspector window. */
  58710. private _createInspector;
  58711. /**
  58712. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58713. * @param entity defines the entity to select
  58714. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58715. */
  58716. select(entity: any, lineContainerTitles?: string | string[]): void;
  58717. /** Get the inspector from bundle or global */
  58718. private _getGlobalInspector;
  58719. /**
  58720. * Get if the inspector is visible or not.
  58721. * @returns true if visible otherwise, false
  58722. */
  58723. isVisible(): boolean;
  58724. /**
  58725. * Hide the inspector and close its window.
  58726. */
  58727. hide(): void;
  58728. /**
  58729. * Update the scene in the inspector
  58730. */
  58731. setAsActiveScene(): void;
  58732. /**
  58733. * Launch the debugLayer.
  58734. * @param config Define the configuration of the inspector
  58735. * @return a promise fulfilled when the debug layer is visible
  58736. */
  58737. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58738. }
  58739. }
  58740. declare module BABYLON.Debug {
  58741. /**
  58742. * Used to show the physics impostor around the specific mesh
  58743. */
  58744. export class PhysicsViewer {
  58745. /** @hidden */
  58746. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58747. /** @hidden */
  58748. protected _meshes: Array<Nullable<AbstractMesh>>;
  58749. /** @hidden */
  58750. protected _scene: Nullable<Scene>;
  58751. /** @hidden */
  58752. protected _numMeshes: number;
  58753. /** @hidden */
  58754. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58755. private _renderFunction;
  58756. private _utilityLayer;
  58757. private _debugBoxMesh;
  58758. private _debugSphereMesh;
  58759. private _debugCylinderMesh;
  58760. private _debugMaterial;
  58761. private _debugMeshMeshes;
  58762. /**
  58763. * Creates a new PhysicsViewer
  58764. * @param scene defines the hosting scene
  58765. */
  58766. constructor(scene: Scene);
  58767. /** @hidden */
  58768. protected _updateDebugMeshes(): void;
  58769. /**
  58770. * Renders a specified physic impostor
  58771. * @param impostor defines the impostor to render
  58772. * @param targetMesh defines the mesh represented by the impostor
  58773. * @returns the new debug mesh used to render the impostor
  58774. */
  58775. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58776. /**
  58777. * Hides a specified physic impostor
  58778. * @param impostor defines the impostor to hide
  58779. */
  58780. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58781. private _getDebugMaterial;
  58782. private _getDebugBoxMesh;
  58783. private _getDebugSphereMesh;
  58784. private _getDebugCylinderMesh;
  58785. private _getDebugMeshMesh;
  58786. private _getDebugMesh;
  58787. /** Releases all resources */
  58788. dispose(): void;
  58789. }
  58790. }
  58791. declare module BABYLON {
  58792. /**
  58793. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58794. * in order to better appreciate the issue one might have.
  58795. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58796. */
  58797. export class RayHelper {
  58798. /**
  58799. * Defines the ray we are currently tryin to visualize.
  58800. */
  58801. ray: Nullable<Ray>;
  58802. private _renderPoints;
  58803. private _renderLine;
  58804. private _renderFunction;
  58805. private _scene;
  58806. private _onAfterRenderObserver;
  58807. private _onAfterStepObserver;
  58808. private _attachedToMesh;
  58809. private _meshSpaceDirection;
  58810. private _meshSpaceOrigin;
  58811. /**
  58812. * Helper function to create a colored helper in a scene in one line.
  58813. * @param ray Defines the ray we are currently tryin to visualize
  58814. * @param scene Defines the scene the ray is used in
  58815. * @param color Defines the color we want to see the ray in
  58816. * @returns The newly created ray helper.
  58817. */
  58818. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58819. /**
  58820. * Instantiate a new ray helper.
  58821. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58822. * in order to better appreciate the issue one might have.
  58823. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58824. * @param ray Defines the ray we are currently tryin to visualize
  58825. */
  58826. constructor(ray: Ray);
  58827. /**
  58828. * Shows the ray we are willing to debug.
  58829. * @param scene Defines the scene the ray needs to be rendered in
  58830. * @param color Defines the color the ray needs to be rendered in
  58831. */
  58832. show(scene: Scene, color?: Color3): void;
  58833. /**
  58834. * Hides the ray we are debugging.
  58835. */
  58836. hide(): void;
  58837. private _render;
  58838. /**
  58839. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58840. * @param mesh Defines the mesh we want the helper attached to
  58841. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58842. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58843. * @param length Defines the length of the ray
  58844. */
  58845. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58846. /**
  58847. * Detach the ray helper from the mesh it has previously been attached to.
  58848. */
  58849. detachFromMesh(): void;
  58850. private _updateToMesh;
  58851. /**
  58852. * Dispose the helper and release its associated resources.
  58853. */
  58854. dispose(): void;
  58855. }
  58856. }
  58857. declare module BABYLON {
  58858. /**
  58859. * Defines the options associated with the creation of a SkeletonViewer.
  58860. */
  58861. export interface ISkeletonViewerOptions {
  58862. /** Should the system pause animations before building the Viewer? */
  58863. pauseAnimations: boolean;
  58864. /** Should the system return the skeleton to rest before building? */
  58865. returnToRest: boolean;
  58866. /** public Display Mode of the Viewer */
  58867. displayMode: number;
  58868. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58869. displayOptions: ISkeletonViewerDisplayOptions;
  58870. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58871. computeBonesUsingShaders: boolean;
  58872. /** Flag ignore non weighted bones */
  58873. useAllBones: boolean;
  58874. }
  58875. /**
  58876. * Defines how to display the various bone meshes for the viewer.
  58877. */
  58878. export interface ISkeletonViewerDisplayOptions {
  58879. /** How far down to start tapering the bone spurs */
  58880. midStep?: number;
  58881. /** How big is the midStep? */
  58882. midStepFactor?: number;
  58883. /** Base for the Sphere Size */
  58884. sphereBaseSize?: number;
  58885. /** The ratio of the sphere to the longest bone in units */
  58886. sphereScaleUnit?: number;
  58887. /** Ratio for the Sphere Size */
  58888. sphereFactor?: number;
  58889. /** Whether a spur should attach its far end to the child bone position */
  58890. spurFollowsChild?: boolean;
  58891. /** Whether to show local axes or not */
  58892. showLocalAxes?: boolean;
  58893. /** Length of each local axis */
  58894. localAxesSize?: number;
  58895. }
  58896. /**
  58897. * Defines the constructor options for the BoneWeight Shader.
  58898. */
  58899. export interface IBoneWeightShaderOptions {
  58900. /** Skeleton to Map */
  58901. skeleton: Skeleton;
  58902. /** Colors for Uninfluenced bones */
  58903. colorBase?: Color3;
  58904. /** Colors for 0.0-0.25 Weight bones */
  58905. colorZero?: Color3;
  58906. /** Color for 0.25-0.5 Weight Influence */
  58907. colorQuarter?: Color3;
  58908. /** Color for 0.5-0.75 Weight Influence */
  58909. colorHalf?: Color3;
  58910. /** Color for 0.75-1 Weight Influence */
  58911. colorFull?: Color3;
  58912. /** Color for Zero Weight Influence */
  58913. targetBoneIndex?: number;
  58914. }
  58915. /**
  58916. * Simple structure of the gradient steps for the Color Map.
  58917. */
  58918. export interface ISkeletonMapShaderColorMapKnot {
  58919. /** Color of the Knot */
  58920. color: Color3;
  58921. /** Location of the Knot */
  58922. location: number;
  58923. }
  58924. /**
  58925. * Defines the constructor options for the SkeletonMap Shader.
  58926. */
  58927. export interface ISkeletonMapShaderOptions {
  58928. /** Skeleton to Map */
  58929. skeleton: Skeleton;
  58930. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58931. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /**
  58936. * Class containing static functions to help procedurally build meshes
  58937. */
  58938. export class RibbonBuilder {
  58939. /**
  58940. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58941. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58942. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58943. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58944. * * 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
  58945. * * 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
  58946. * * 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
  58947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58948. * * 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
  58949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58950. * * 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
  58951. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58952. * * 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
  58953. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58955. * @param name defines the name of the mesh
  58956. * @param options defines the options used to create the mesh
  58957. * @param scene defines the hosting scene
  58958. * @returns the ribbon mesh
  58959. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58961. */
  58962. static CreateRibbon(name: string, options: {
  58963. pathArray: Vector3[][];
  58964. closeArray?: boolean;
  58965. closePath?: boolean;
  58966. offset?: number;
  58967. updatable?: boolean;
  58968. sideOrientation?: number;
  58969. frontUVs?: Vector4;
  58970. backUVs?: Vector4;
  58971. instance?: Mesh;
  58972. invertUV?: boolean;
  58973. uvs?: Vector2[];
  58974. colors?: Color4[];
  58975. }, scene?: Nullable<Scene>): Mesh;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /**
  58980. * Class containing static functions to help procedurally build meshes
  58981. */
  58982. export class ShapeBuilder {
  58983. /**
  58984. * 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.
  58985. * * 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.
  58986. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58987. * * 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.
  58988. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58989. * * 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
  58990. * * 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
  58991. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58993. * * 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
  58994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58996. * @param name defines the name of the mesh
  58997. * @param options defines the options used to create the mesh
  58998. * @param scene defines the hosting scene
  58999. * @returns the extruded shape mesh
  59000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59002. */
  59003. static ExtrudeShape(name: string, options: {
  59004. shape: Vector3[];
  59005. path: Vector3[];
  59006. scale?: number;
  59007. rotation?: number;
  59008. cap?: number;
  59009. updatable?: boolean;
  59010. sideOrientation?: number;
  59011. frontUVs?: Vector4;
  59012. backUVs?: Vector4;
  59013. instance?: Mesh;
  59014. invertUV?: boolean;
  59015. }, scene?: Nullable<Scene>): Mesh;
  59016. /**
  59017. * Creates an custom extruded shape mesh.
  59018. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59019. * * 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.
  59020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59021. * * 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
  59022. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59023. * * 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
  59024. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59025. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59026. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59027. * * 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
  59028. * * 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
  59029. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59031. * * 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
  59032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59034. * @param name defines the name of the mesh
  59035. * @param options defines the options used to create the mesh
  59036. * @param scene defines the hosting scene
  59037. * @returns the custom extruded shape mesh
  59038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59041. */
  59042. static ExtrudeShapeCustom(name: string, options: {
  59043. shape: Vector3[];
  59044. path: Vector3[];
  59045. scaleFunction?: any;
  59046. rotationFunction?: any;
  59047. ribbonCloseArray?: boolean;
  59048. ribbonClosePath?: boolean;
  59049. cap?: number;
  59050. updatable?: boolean;
  59051. sideOrientation?: number;
  59052. frontUVs?: Vector4;
  59053. backUVs?: Vector4;
  59054. instance?: Mesh;
  59055. invertUV?: boolean;
  59056. }, scene?: Nullable<Scene>): Mesh;
  59057. private static _ExtrudeShapeGeneric;
  59058. }
  59059. }
  59060. declare module BABYLON.Debug {
  59061. /**
  59062. * Class used to render a debug view of a given skeleton
  59063. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  59064. */
  59065. export class SkeletonViewer {
  59066. /** defines the skeleton to render */
  59067. skeleton: Skeleton;
  59068. /** defines the mesh attached to the skeleton */
  59069. mesh: AbstractMesh;
  59070. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59071. autoUpdateBonesMatrices: boolean;
  59072. /** defines the rendering group id to use with the viewer */
  59073. renderingGroupId: number;
  59074. /** is the options for the viewer */
  59075. options: Partial<ISkeletonViewerOptions>;
  59076. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  59077. static readonly DISPLAY_LINES: number;
  59078. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  59079. static readonly DISPLAY_SPHERES: number;
  59080. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  59081. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  59082. /** public static method to create a BoneWeight Shader
  59083. * @param options The constructor options
  59084. * @param scene The scene that the shader is scoped to
  59085. * @returns The created ShaderMaterial
  59086. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  59087. */
  59088. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  59089. /** public static method to create a BoneWeight Shader
  59090. * @param options The constructor options
  59091. * @param scene The scene that the shader is scoped to
  59092. * @returns The created ShaderMaterial
  59093. */
  59094. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  59095. /** private static method to create a BoneWeight Shader
  59096. * @param size The size of the buffer to create (usually the bone count)
  59097. * @param colorMap The gradient data to generate
  59098. * @param scene The scene that the shader is scoped to
  59099. * @returns an Array of floats from the color gradient values
  59100. */
  59101. private static _CreateBoneMapColorBuffer;
  59102. /** If SkeletonViewer scene scope. */
  59103. private _scene;
  59104. /** Gets or sets the color used to render the skeleton */
  59105. color: Color3;
  59106. /** Array of the points of the skeleton fo the line view. */
  59107. private _debugLines;
  59108. /** The SkeletonViewers Mesh. */
  59109. private _debugMesh;
  59110. /** The local axes Meshes. */
  59111. private _localAxes;
  59112. /** If SkeletonViewer is enabled. */
  59113. private _isEnabled;
  59114. /** If SkeletonViewer is ready. */
  59115. private _ready;
  59116. /** SkeletonViewer render observable. */
  59117. private _obs;
  59118. /** The Utility Layer to render the gizmos in. */
  59119. private _utilityLayer;
  59120. private _boneIndices;
  59121. /** Gets the Scene. */
  59122. get scene(): Scene;
  59123. /** Gets the utilityLayer. */
  59124. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  59125. /** Checks Ready Status. */
  59126. get isReady(): Boolean;
  59127. /** Sets Ready Status. */
  59128. set ready(value: boolean);
  59129. /** Gets the debugMesh */
  59130. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  59131. /** Sets the debugMesh */
  59132. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  59133. /** Gets the displayMode */
  59134. get displayMode(): number;
  59135. /** Sets the displayMode */
  59136. set displayMode(value: number);
  59137. /**
  59138. * Creates a new SkeletonViewer
  59139. * @param skeleton defines the skeleton to render
  59140. * @param mesh defines the mesh attached to the skeleton
  59141. * @param scene defines the hosting scene
  59142. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  59143. * @param renderingGroupId defines the rendering group id to use with the viewer
  59144. * @param options All of the extra constructor options for the SkeletonViewer
  59145. */
  59146. constructor(
  59147. /** defines the skeleton to render */
  59148. skeleton: Skeleton,
  59149. /** defines the mesh attached to the skeleton */
  59150. mesh: AbstractMesh,
  59151. /** The Scene scope*/
  59152. scene: Scene,
  59153. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  59154. autoUpdateBonesMatrices?: boolean,
  59155. /** defines the rendering group id to use with the viewer */
  59156. renderingGroupId?: number,
  59157. /** is the options for the viewer */
  59158. options?: Partial<ISkeletonViewerOptions>);
  59159. /** The Dynamic bindings for the update functions */
  59160. private _bindObs;
  59161. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  59162. update(): void;
  59163. /** Gets or sets a boolean indicating if the viewer is enabled */
  59164. set isEnabled(value: boolean);
  59165. get isEnabled(): boolean;
  59166. private _getBonePosition;
  59167. private _getLinesForBonesWithLength;
  59168. private _getLinesForBonesNoLength;
  59169. /** function to revert the mesh and scene back to the initial state. */
  59170. private _revert;
  59171. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  59172. private _getAbsoluteBindPoseToRef;
  59173. /** function to build and bind sphere joint points and spur bone representations. */
  59174. private _buildSpheresAndSpurs;
  59175. private _buildLocalAxes;
  59176. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  59177. private _displayLinesUpdate;
  59178. /** Changes the displayMode of the skeleton viewer
  59179. * @param mode The displayMode numerical value
  59180. */
  59181. changeDisplayMode(mode: number): void;
  59182. /** Sets a display option of the skeleton viewer
  59183. *
  59184. * | Option | Type | Default | Description |
  59185. * | ---------------- | ------- | ------- | ----------- |
  59186. * | 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`. |
  59187. * | 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`. |
  59188. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  59189. * | 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`. |
  59190. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  59191. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  59192. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  59193. *
  59194. * @param option String of the option name
  59195. * @param value The numerical option value
  59196. */
  59197. changeDisplayOptions(option: string, value: number): void;
  59198. /** Release associated resources */
  59199. dispose(): void;
  59200. }
  59201. }
  59202. declare module BABYLON {
  59203. /**
  59204. * Enum for Device Types
  59205. */
  59206. export enum DeviceType {
  59207. /** Generic */
  59208. Generic = 0,
  59209. /** Keyboard */
  59210. Keyboard = 1,
  59211. /** Mouse */
  59212. Mouse = 2,
  59213. /** Touch Pointers */
  59214. Touch = 3,
  59215. /** PS4 Dual Shock */
  59216. DualShock = 4,
  59217. /** Xbox */
  59218. Xbox = 5,
  59219. /** Switch Controller */
  59220. Switch = 6
  59221. }
  59222. /**
  59223. * Enum for All Pointers (Touch/Mouse)
  59224. */
  59225. export enum PointerInput {
  59226. /** Horizontal Axis */
  59227. Horizontal = 0,
  59228. /** Vertical Axis */
  59229. Vertical = 1,
  59230. /** Left Click or Touch */
  59231. LeftClick = 2,
  59232. /** Middle Click */
  59233. MiddleClick = 3,
  59234. /** Right Click */
  59235. RightClick = 4,
  59236. /** Browser Back */
  59237. BrowserBack = 5,
  59238. /** Browser Forward */
  59239. BrowserForward = 6
  59240. }
  59241. /**
  59242. * Enum for Dual Shock Gamepad
  59243. */
  59244. export enum DualShockInput {
  59245. /** Cross */
  59246. Cross = 0,
  59247. /** Circle */
  59248. Circle = 1,
  59249. /** Square */
  59250. Square = 2,
  59251. /** Triangle */
  59252. Triangle = 3,
  59253. /** L1 */
  59254. L1 = 4,
  59255. /** R1 */
  59256. R1 = 5,
  59257. /** L2 */
  59258. L2 = 6,
  59259. /** R2 */
  59260. R2 = 7,
  59261. /** Share */
  59262. Share = 8,
  59263. /** Options */
  59264. Options = 9,
  59265. /** L3 */
  59266. L3 = 10,
  59267. /** R3 */
  59268. R3 = 11,
  59269. /** DPadUp */
  59270. DPadUp = 12,
  59271. /** DPadDown */
  59272. DPadDown = 13,
  59273. /** DPadLeft */
  59274. DPadLeft = 14,
  59275. /** DRight */
  59276. DPadRight = 15,
  59277. /** Home */
  59278. Home = 16,
  59279. /** TouchPad */
  59280. TouchPad = 17,
  59281. /** LStickXAxis */
  59282. LStickXAxis = 18,
  59283. /** LStickYAxis */
  59284. LStickYAxis = 19,
  59285. /** RStickXAxis */
  59286. RStickXAxis = 20,
  59287. /** RStickYAxis */
  59288. RStickYAxis = 21
  59289. }
  59290. /**
  59291. * Enum for Xbox Gamepad
  59292. */
  59293. export enum XboxInput {
  59294. /** A */
  59295. A = 0,
  59296. /** B */
  59297. B = 1,
  59298. /** X */
  59299. X = 2,
  59300. /** Y */
  59301. Y = 3,
  59302. /** LB */
  59303. LB = 4,
  59304. /** RB */
  59305. RB = 5,
  59306. /** LT */
  59307. LT = 6,
  59308. /** RT */
  59309. RT = 7,
  59310. /** Back */
  59311. Back = 8,
  59312. /** Start */
  59313. Start = 9,
  59314. /** LS */
  59315. LS = 10,
  59316. /** RS */
  59317. RS = 11,
  59318. /** DPadUp */
  59319. DPadUp = 12,
  59320. /** DPadDown */
  59321. DPadDown = 13,
  59322. /** DPadLeft */
  59323. DPadLeft = 14,
  59324. /** DRight */
  59325. DPadRight = 15,
  59326. /** Home */
  59327. Home = 16,
  59328. /** LStickXAxis */
  59329. LStickXAxis = 17,
  59330. /** LStickYAxis */
  59331. LStickYAxis = 18,
  59332. /** RStickXAxis */
  59333. RStickXAxis = 19,
  59334. /** RStickYAxis */
  59335. RStickYAxis = 20
  59336. }
  59337. /**
  59338. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  59339. */
  59340. export enum SwitchInput {
  59341. /** B */
  59342. B = 0,
  59343. /** A */
  59344. A = 1,
  59345. /** Y */
  59346. Y = 2,
  59347. /** X */
  59348. X = 3,
  59349. /** L */
  59350. L = 4,
  59351. /** R */
  59352. R = 5,
  59353. /** ZL */
  59354. ZL = 6,
  59355. /** ZR */
  59356. ZR = 7,
  59357. /** Minus */
  59358. Minus = 8,
  59359. /** Plus */
  59360. Plus = 9,
  59361. /** LS */
  59362. LS = 10,
  59363. /** RS */
  59364. RS = 11,
  59365. /** DPadUp */
  59366. DPadUp = 12,
  59367. /** DPadDown */
  59368. DPadDown = 13,
  59369. /** DPadLeft */
  59370. DPadLeft = 14,
  59371. /** DRight */
  59372. DPadRight = 15,
  59373. /** Home */
  59374. Home = 16,
  59375. /** Capture */
  59376. Capture = 17,
  59377. /** LStickXAxis */
  59378. LStickXAxis = 18,
  59379. /** LStickYAxis */
  59380. LStickYAxis = 19,
  59381. /** RStickXAxis */
  59382. RStickXAxis = 20,
  59383. /** RStickYAxis */
  59384. RStickYAxis = 21
  59385. }
  59386. }
  59387. declare module BABYLON {
  59388. /**
  59389. * This class will take all inputs from Keyboard, Pointer, and
  59390. * any Gamepads and provide a polling system that all devices
  59391. * will use. This class assumes that there will only be one
  59392. * pointer device and one keyboard.
  59393. */
  59394. export class DeviceInputSystem implements IDisposable {
  59395. /**
  59396. * Returns onDeviceConnected callback property
  59397. * @returns Callback with function to execute when a device is connected
  59398. */
  59399. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  59400. /**
  59401. * Sets callback function when a device is connected and executes against all connected devices
  59402. * @param callback Function to execute when a device is connected
  59403. */
  59404. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  59405. /**
  59406. * Callback to be triggered when a device is disconnected
  59407. */
  59408. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  59409. /**
  59410. * Callback to be triggered when event driven input is updated
  59411. */
  59412. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  59413. private _inputs;
  59414. private _gamepads;
  59415. private _keyboardActive;
  59416. private _pointerActive;
  59417. private _elementToAttachTo;
  59418. private _keyboardDownEvent;
  59419. private _keyboardUpEvent;
  59420. private _pointerMoveEvent;
  59421. private _pointerDownEvent;
  59422. private _pointerUpEvent;
  59423. private _gamepadConnectedEvent;
  59424. private _gamepadDisconnectedEvent;
  59425. private _onDeviceConnected;
  59426. private static _MAX_KEYCODES;
  59427. private static _MAX_POINTER_INPUTS;
  59428. private constructor();
  59429. /**
  59430. * Creates a new DeviceInputSystem instance
  59431. * @param engine Engine to pull input element from
  59432. * @returns The new instance
  59433. */
  59434. static Create(engine: Engine): DeviceInputSystem;
  59435. /**
  59436. * Checks for current device input value, given an id and input index
  59437. * @param deviceName Id of connected device
  59438. * @param inputIndex Index of device input
  59439. * @returns Current value of input
  59440. */
  59441. /**
  59442. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  59443. * @param deviceType Enum specifiying device type
  59444. * @param deviceSlot "Slot" or index that device is referenced in
  59445. * @param inputIndex Id of input to be checked
  59446. * @returns Current value of input
  59447. */
  59448. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  59449. /**
  59450. * Dispose of all the eventlisteners
  59451. */
  59452. dispose(): void;
  59453. /**
  59454. * Checks for existing connections to devices and register them, if necessary
  59455. * Currently handles gamepads and mouse
  59456. */
  59457. private _checkForConnectedDevices;
  59458. /**
  59459. * Add a gamepad to the DeviceInputSystem
  59460. * @param gamepad A single DOM Gamepad object
  59461. */
  59462. private _addGamePad;
  59463. /**
  59464. * Add pointer device to DeviceInputSystem
  59465. * @param deviceType Type of Pointer to add
  59466. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  59467. * @param currentX Current X at point of adding
  59468. * @param currentY Current Y at point of adding
  59469. */
  59470. private _addPointerDevice;
  59471. /**
  59472. * Add device and inputs to device array
  59473. * @param deviceType Enum specifiying device type
  59474. * @param deviceSlot "Slot" or index that device is referenced in
  59475. * @param numberOfInputs Number of input entries to create for given device
  59476. */
  59477. private _registerDevice;
  59478. /**
  59479. * Given a specific device name, remove that device from the device map
  59480. * @param deviceType Enum specifiying device type
  59481. * @param deviceSlot "Slot" or index that device is referenced in
  59482. */
  59483. private _unregisterDevice;
  59484. /**
  59485. * Handle all actions that come from keyboard interaction
  59486. */
  59487. private _handleKeyActions;
  59488. /**
  59489. * Handle all actions that come from pointer interaction
  59490. */
  59491. private _handlePointerActions;
  59492. /**
  59493. * Handle all actions that come from gamepad interaction
  59494. */
  59495. private _handleGamepadActions;
  59496. /**
  59497. * Update all non-event based devices with each frame
  59498. * @param deviceType Enum specifiying device type
  59499. * @param deviceSlot "Slot" or index that device is referenced in
  59500. * @param inputIndex Id of input to be checked
  59501. */
  59502. private _updateDevice;
  59503. /**
  59504. * Gets DeviceType from the device name
  59505. * @param deviceName Name of Device from DeviceInputSystem
  59506. * @returns DeviceType enum value
  59507. */
  59508. private _getGamepadDeviceType;
  59509. }
  59510. }
  59511. declare module BABYLON {
  59512. /**
  59513. * Type to handle enforcement of inputs
  59514. */
  59515. 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;
  59516. }
  59517. declare module BABYLON {
  59518. /**
  59519. * Class that handles all input for a specific device
  59520. */
  59521. export class DeviceSource<T extends DeviceType> {
  59522. /** Type of device */
  59523. readonly deviceType: DeviceType;
  59524. /** "Slot" or index that device is referenced in */
  59525. readonly deviceSlot: number;
  59526. /**
  59527. * Observable to handle device input changes per device
  59528. */
  59529. readonly onInputChangedObservable: Observable<{
  59530. inputIndex: DeviceInput<T>;
  59531. previousState: Nullable<number>;
  59532. currentState: Nullable<number>;
  59533. }>;
  59534. private readonly _deviceInputSystem;
  59535. /**
  59536. * Default Constructor
  59537. * @param deviceInputSystem Reference to DeviceInputSystem
  59538. * @param deviceType Type of device
  59539. * @param deviceSlot "Slot" or index that device is referenced in
  59540. */
  59541. constructor(deviceInputSystem: DeviceInputSystem,
  59542. /** Type of device */
  59543. deviceType: DeviceType,
  59544. /** "Slot" or index that device is referenced in */
  59545. deviceSlot?: number);
  59546. /**
  59547. * Get input for specific input
  59548. * @param inputIndex index of specific input on device
  59549. * @returns Input value from DeviceInputSystem
  59550. */
  59551. getInput(inputIndex: DeviceInput<T>): number;
  59552. }
  59553. /**
  59554. * Class to keep track of devices
  59555. */
  59556. export class DeviceSourceManager implements IDisposable {
  59557. /**
  59558. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  59559. */
  59560. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  59561. /**
  59562. * Observable to be triggered when after a device is disconnected
  59563. */
  59564. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  59565. private readonly _devices;
  59566. private readonly _firstDevice;
  59567. private readonly _deviceInputSystem;
  59568. /**
  59569. * Default Constructor
  59570. * @param engine engine to pull input element from
  59571. */
  59572. constructor(engine: Engine);
  59573. /**
  59574. * Gets a DeviceSource, given a type and slot
  59575. * @param deviceType Enum specifying device type
  59576. * @param deviceSlot "Slot" or index that device is referenced in
  59577. * @returns DeviceSource object
  59578. */
  59579. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  59580. /**
  59581. * Gets an array of DeviceSource objects for a given device type
  59582. * @param deviceType Enum specifying device type
  59583. * @returns Array of DeviceSource objects
  59584. */
  59585. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  59586. /**
  59587. * Returns a read-only list of all available devices
  59588. * @returns Read-only array with active devices
  59589. */
  59590. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  59591. /**
  59592. * Dispose of DeviceInputSystem and other parts
  59593. */
  59594. dispose(): void;
  59595. /**
  59596. * Function to add device name to device list
  59597. * @param deviceType Enum specifying device type
  59598. * @param deviceSlot "Slot" or index that device is referenced in
  59599. */
  59600. private _addDevice;
  59601. /**
  59602. * Function to remove device name to device list
  59603. * @param deviceType Enum specifying device type
  59604. * @param deviceSlot "Slot" or index that device is referenced in
  59605. */
  59606. private _removeDevice;
  59607. /**
  59608. * Updates array storing first connected device of each type
  59609. * @param type Type of Device
  59610. */
  59611. private _updateFirstDevices;
  59612. }
  59613. }
  59614. declare module BABYLON {
  59615. /**
  59616. * Options to create the null engine
  59617. */
  59618. export class NullEngineOptions {
  59619. /**
  59620. * Render width (Default: 512)
  59621. */
  59622. renderWidth: number;
  59623. /**
  59624. * Render height (Default: 256)
  59625. */
  59626. renderHeight: number;
  59627. /**
  59628. * Texture size (Default: 512)
  59629. */
  59630. textureSize: number;
  59631. /**
  59632. * If delta time between frames should be constant
  59633. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59634. */
  59635. deterministicLockstep: boolean;
  59636. /**
  59637. * Maximum about of steps between frames (Default: 4)
  59638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59639. */
  59640. lockstepMaxSteps: number;
  59641. /**
  59642. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  59643. */
  59644. useHighPrecisionMatrix?: boolean;
  59645. }
  59646. /**
  59647. * The null engine class provides support for headless version of babylon.js.
  59648. * This can be used in server side scenario or for testing purposes
  59649. */
  59650. export class NullEngine extends Engine {
  59651. private _options;
  59652. /**
  59653. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  59654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59655. * @returns true if engine is in deterministic lock step mode
  59656. */
  59657. isDeterministicLockStep(): boolean;
  59658. /**
  59659. * Gets the max steps when engine is running in deterministic lock step
  59660. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  59661. * @returns the max steps
  59662. */
  59663. getLockstepMaxSteps(): number;
  59664. /**
  59665. * Gets the current hardware scaling level.
  59666. * By default the hardware scaling level is computed from the window device ratio.
  59667. * 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.
  59668. * @returns a number indicating the current hardware scaling level
  59669. */
  59670. getHardwareScalingLevel(): number;
  59671. constructor(options?: NullEngineOptions);
  59672. /**
  59673. * Creates a vertex buffer
  59674. * @param vertices the data for the vertex buffer
  59675. * @returns the new WebGL static buffer
  59676. */
  59677. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59678. /**
  59679. * Creates a new index buffer
  59680. * @param indices defines the content of the index buffer
  59681. * @param updatable defines if the index buffer must be updatable
  59682. * @returns a new webGL buffer
  59683. */
  59684. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59685. /**
  59686. * Clear the current render buffer or the current render target (if any is set up)
  59687. * @param color defines the color to use
  59688. * @param backBuffer defines if the back buffer must be cleared
  59689. * @param depth defines if the depth buffer must be cleared
  59690. * @param stencil defines if the stencil buffer must be cleared
  59691. */
  59692. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59693. /**
  59694. * Gets the current render width
  59695. * @param useScreen defines if screen size must be used (or the current render target if any)
  59696. * @returns a number defining the current render width
  59697. */
  59698. getRenderWidth(useScreen?: boolean): number;
  59699. /**
  59700. * Gets the current render height
  59701. * @param useScreen defines if screen size must be used (or the current render target if any)
  59702. * @returns a number defining the current render height
  59703. */
  59704. getRenderHeight(useScreen?: boolean): number;
  59705. /**
  59706. * Set the WebGL's viewport
  59707. * @param viewport defines the viewport element to be used
  59708. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59709. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59710. */
  59711. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59712. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59713. /**
  59714. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59715. * @param pipelineContext defines the pipeline context to use
  59716. * @param uniformsNames defines the list of uniform names
  59717. * @returns an array of webGL uniform locations
  59718. */
  59719. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59720. /**
  59721. * Gets the lsit of active attributes for a given webGL program
  59722. * @param pipelineContext defines the pipeline context to use
  59723. * @param attributesNames defines the list of attribute names to get
  59724. * @returns an array of indices indicating the offset of each attribute
  59725. */
  59726. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59727. /**
  59728. * Binds an effect to the webGL context
  59729. * @param effect defines the effect to bind
  59730. */
  59731. bindSamplers(effect: Effect): void;
  59732. /**
  59733. * Activates an effect, making it the current one (ie. the one used for rendering)
  59734. * @param effect defines the effect to activate
  59735. */
  59736. enableEffect(effect: Effect): void;
  59737. /**
  59738. * Set various states to the webGL context
  59739. * @param culling defines backface culling state
  59740. * @param zOffset defines the value to apply to zOffset (0 by default)
  59741. * @param force defines if states must be applied even if cache is up to date
  59742. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59743. */
  59744. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59745. /**
  59746. * Set the value of an uniform to an array of int32
  59747. * @param uniform defines the webGL uniform location where to store the value
  59748. * @param array defines the array of int32 to store
  59749. * @returns true if value was set
  59750. */
  59751. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59752. /**
  59753. * Set the value of an uniform to an array of int32 (stored as vec2)
  59754. * @param uniform defines the webGL uniform location where to store the value
  59755. * @param array defines the array of int32 to store
  59756. * @returns true if value was set
  59757. */
  59758. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59759. /**
  59760. * Set the value of an uniform to an array of int32 (stored as vec3)
  59761. * @param uniform defines the webGL uniform location where to store the value
  59762. * @param array defines the array of int32 to store
  59763. * @returns true if value was set
  59764. */
  59765. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59766. /**
  59767. * Set the value of an uniform to an array of int32 (stored as vec4)
  59768. * @param uniform defines the webGL uniform location where to store the value
  59769. * @param array defines the array of int32 to store
  59770. * @returns true if value was set
  59771. */
  59772. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59773. /**
  59774. * Set the value of an uniform to an array of float32
  59775. * @param uniform defines the webGL uniform location where to store the value
  59776. * @param array defines the array of float32 to store
  59777. * @returns true if value was set
  59778. */
  59779. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59780. /**
  59781. * Set the value of an uniform to an array of float32 (stored as vec2)
  59782. * @param uniform defines the webGL uniform location where to store the value
  59783. * @param array defines the array of float32 to store
  59784. * @returns true if value was set
  59785. */
  59786. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59787. /**
  59788. * Set the value of an uniform to an array of float32 (stored as vec3)
  59789. * @param uniform defines the webGL uniform location where to store the value
  59790. * @param array defines the array of float32 to store
  59791. * @returns true if value was set
  59792. */
  59793. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59794. /**
  59795. * Set the value of an uniform to an array of float32 (stored as vec4)
  59796. * @param uniform defines the webGL uniform location where to store the value
  59797. * @param array defines the array of float32 to store
  59798. * @returns true if value was set
  59799. */
  59800. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59801. /**
  59802. * Set the value of an uniform to an array of number
  59803. * @param uniform defines the webGL uniform location where to store the value
  59804. * @param array defines the array of number to store
  59805. * @returns true if value was set
  59806. */
  59807. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59808. /**
  59809. * Set the value of an uniform to an array of number (stored as vec2)
  59810. * @param uniform defines the webGL uniform location where to store the value
  59811. * @param array defines the array of number to store
  59812. * @returns true if value was set
  59813. */
  59814. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59815. /**
  59816. * Set the value of an uniform to an array of number (stored as vec3)
  59817. * @param uniform defines the webGL uniform location where to store the value
  59818. * @param array defines the array of number to store
  59819. * @returns true if value was set
  59820. */
  59821. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59822. /**
  59823. * Set the value of an uniform to an array of number (stored as vec4)
  59824. * @param uniform defines the webGL uniform location where to store the value
  59825. * @param array defines the array of number to store
  59826. * @returns true if value was set
  59827. */
  59828. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59829. /**
  59830. * Set the value of an uniform to an array of float32 (stored as matrices)
  59831. * @param uniform defines the webGL uniform location where to store the value
  59832. * @param matrices defines the array of float32 to store
  59833. * @returns true if value was set
  59834. */
  59835. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59836. /**
  59837. * Set the value of an uniform to a matrix (3x3)
  59838. * @param uniform defines the webGL uniform location where to store the value
  59839. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59840. * @returns true if value was set
  59841. */
  59842. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59843. /**
  59844. * Set the value of an uniform to a matrix (2x2)
  59845. * @param uniform defines the webGL uniform location where to store the value
  59846. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59847. * @returns true if value was set
  59848. */
  59849. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59850. /**
  59851. * Set the value of an uniform to a number (float)
  59852. * @param uniform defines the webGL uniform location where to store the value
  59853. * @param value defines the float number to store
  59854. * @returns true if value was set
  59855. */
  59856. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59857. /**
  59858. * Set the value of an uniform to a vec2
  59859. * @param uniform defines the webGL uniform location where to store the value
  59860. * @param x defines the 1st component of the value
  59861. * @param y defines the 2nd component of the value
  59862. * @returns true if value was set
  59863. */
  59864. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59865. /**
  59866. * Set the value of an uniform to a vec3
  59867. * @param uniform defines the webGL uniform location where to store the value
  59868. * @param x defines the 1st component of the value
  59869. * @param y defines the 2nd component of the value
  59870. * @param z defines the 3rd component of the value
  59871. * @returns true if value was set
  59872. */
  59873. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59874. /**
  59875. * Set the value of an uniform to a boolean
  59876. * @param uniform defines the webGL uniform location where to store the value
  59877. * @param bool defines the boolean to store
  59878. * @returns true if value was set
  59879. */
  59880. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59881. /**
  59882. * Set the value of an uniform to a vec4
  59883. * @param uniform defines the webGL uniform location where to store the value
  59884. * @param x defines the 1st component of the value
  59885. * @param y defines the 2nd component of the value
  59886. * @param z defines the 3rd component of the value
  59887. * @param w defines the 4th component of the value
  59888. * @returns true if value was set
  59889. */
  59890. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59891. /**
  59892. * Sets the current alpha mode
  59893. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59894. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59895. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59896. */
  59897. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59898. /**
  59899. * Bind webGl buffers directly to the webGL context
  59900. * @param vertexBuffers defines the vertex buffer to bind
  59901. * @param indexBuffer defines the index buffer to bind
  59902. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59903. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59904. * @param effect defines the effect associated with the vertex buffer
  59905. */
  59906. bindBuffers(vertexBuffers: {
  59907. [key: string]: VertexBuffer;
  59908. }, indexBuffer: DataBuffer, effect: Effect): void;
  59909. /**
  59910. * Force the entire cache to be cleared
  59911. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59912. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59913. */
  59914. wipeCaches(bruteForce?: boolean): void;
  59915. /**
  59916. * Send a draw order
  59917. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59918. * @param indexStart defines the starting index
  59919. * @param indexCount defines the number of index to draw
  59920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59921. */
  59922. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59923. /**
  59924. * Draw a list of indexed primitives
  59925. * @param fillMode defines the primitive to use
  59926. * @param indexStart defines the starting index
  59927. * @param indexCount defines the number of index to draw
  59928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59929. */
  59930. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59931. /**
  59932. * Draw a list of unindexed primitives
  59933. * @param fillMode defines the primitive to use
  59934. * @param verticesStart defines the index of first vertex to draw
  59935. * @param verticesCount defines the count of vertices to draw
  59936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59937. */
  59938. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59939. /** @hidden */
  59940. protected _createTexture(): WebGLTexture;
  59941. /** @hidden */
  59942. _releaseTexture(texture: InternalTexture): void;
  59943. /**
  59944. * Usually called from Texture.ts.
  59945. * Passed information to create a WebGLTexture
  59946. * @param urlArg defines a value which contains one of the following:
  59947. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59948. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59949. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59950. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59951. * @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)
  59952. * @param scene needed for loading to the correct scene
  59953. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59954. * @param onLoad optional callback to be called upon successful completion
  59955. * @param onError optional callback to be called upon failure
  59956. * @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
  59957. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59958. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59959. * @param forcedExtension defines the extension to use to pick the right loader
  59960. * @param mimeType defines an optional mime type
  59961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59962. */
  59963. 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;
  59964. /**
  59965. * Creates a new render target texture
  59966. * @param size defines the size of the texture
  59967. * @param options defines the options used to create the texture
  59968. * @returns a new render target texture stored in an InternalTexture
  59969. */
  59970. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59971. /**
  59972. * Update the sampling mode of a given texture
  59973. * @param samplingMode defines the required sampling mode
  59974. * @param texture defines the texture to update
  59975. */
  59976. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59977. /**
  59978. * Binds the frame buffer to the specified texture.
  59979. * @param texture The texture to render to or null for the default canvas
  59980. * @param faceIndex The face of the texture to render to in case of cube texture
  59981. * @param requiredWidth The width of the target to render to
  59982. * @param requiredHeight The height of the target to render to
  59983. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59984. * @param lodLevel defines le lod level to bind to the frame buffer
  59985. */
  59986. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59987. /**
  59988. * Unbind the current render target texture from the webGL context
  59989. * @param texture defines the render target texture to unbind
  59990. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59991. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59992. */
  59993. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59994. /**
  59995. * Creates a dynamic vertex buffer
  59996. * @param vertices the data for the dynamic vertex buffer
  59997. * @returns the new WebGL dynamic buffer
  59998. */
  59999. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  60000. /**
  60001. * Update the content of a dynamic texture
  60002. * @param texture defines the texture to update
  60003. * @param canvas defines the canvas containing the source
  60004. * @param invertY defines if data must be stored with Y axis inverted
  60005. * @param premulAlpha defines if alpha is stored as premultiplied
  60006. * @param format defines the format of the data
  60007. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60008. */
  60009. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60010. /**
  60011. * Gets a boolean indicating if all created effects are ready
  60012. * @returns true if all effects are ready
  60013. */
  60014. areAllEffectsReady(): boolean;
  60015. /**
  60016. * @hidden
  60017. * Get the current error code of the webGL context
  60018. * @returns the error code
  60019. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  60020. */
  60021. getError(): number;
  60022. /** @hidden */
  60023. _getUnpackAlignement(): number;
  60024. /** @hidden */
  60025. _unpackFlipY(value: boolean): void;
  60026. /**
  60027. * Update a dynamic index buffer
  60028. * @param indexBuffer defines the target index buffer
  60029. * @param indices defines the data to update
  60030. * @param offset defines the offset in the target index buffer where update should start
  60031. */
  60032. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  60033. /**
  60034. * Updates a dynamic vertex buffer.
  60035. * @param vertexBuffer the vertex buffer to update
  60036. * @param vertices the data used to update the vertex buffer
  60037. * @param byteOffset the byte offset of the data (optional)
  60038. * @param byteLength the byte length of the data (optional)
  60039. */
  60040. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  60041. /** @hidden */
  60042. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  60043. /** @hidden */
  60044. _bindTexture(channel: number, texture: InternalTexture): void;
  60045. protected _deleteBuffer(buffer: WebGLBuffer): void;
  60046. /**
  60047. * 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
  60048. */
  60049. releaseEffects(): void;
  60050. displayLoadingUI(): void;
  60051. hideLoadingUI(): void;
  60052. /** @hidden */
  60053. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60054. /** @hidden */
  60055. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60056. /** @hidden */
  60057. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60058. /** @hidden */
  60059. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60060. }
  60061. }
  60062. declare module BABYLON {
  60063. /** @hidden */
  60064. export class _OcclusionDataStorage {
  60065. /** @hidden */
  60066. occlusionInternalRetryCounter: number;
  60067. /** @hidden */
  60068. isOcclusionQueryInProgress: boolean;
  60069. /** @hidden */
  60070. isOccluded: boolean;
  60071. /** @hidden */
  60072. occlusionRetryCount: number;
  60073. /** @hidden */
  60074. occlusionType: number;
  60075. /** @hidden */
  60076. occlusionQueryAlgorithmType: number;
  60077. }
  60078. interface Engine {
  60079. /**
  60080. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  60081. * @return the new query
  60082. */
  60083. createQuery(): WebGLQuery;
  60084. /**
  60085. * Delete and release a webGL query
  60086. * @param query defines the query to delete
  60087. * @return the current engine
  60088. */
  60089. deleteQuery(query: WebGLQuery): Engine;
  60090. /**
  60091. * Check if a given query has resolved and got its value
  60092. * @param query defines the query to check
  60093. * @returns true if the query got its value
  60094. */
  60095. isQueryResultAvailable(query: WebGLQuery): boolean;
  60096. /**
  60097. * Gets the value of a given query
  60098. * @param query defines the query to check
  60099. * @returns the value of the query
  60100. */
  60101. getQueryResult(query: WebGLQuery): number;
  60102. /**
  60103. * Initiates an occlusion query
  60104. * @param algorithmType defines the algorithm to use
  60105. * @param query defines the query to use
  60106. * @returns the current engine
  60107. * @see https://doc.babylonjs.com/features/occlusionquery
  60108. */
  60109. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  60110. /**
  60111. * Ends an occlusion query
  60112. * @see https://doc.babylonjs.com/features/occlusionquery
  60113. * @param algorithmType defines the algorithm to use
  60114. * @returns the current engine
  60115. */
  60116. endOcclusionQuery(algorithmType: number): Engine;
  60117. /**
  60118. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  60119. * Please note that only one query can be issued at a time
  60120. * @returns a time token used to track the time span
  60121. */
  60122. startTimeQuery(): Nullable<_TimeToken>;
  60123. /**
  60124. * Ends a time query
  60125. * @param token defines the token used to measure the time span
  60126. * @returns the time spent (in ns)
  60127. */
  60128. endTimeQuery(token: _TimeToken): int;
  60129. /** @hidden */
  60130. _currentNonTimestampToken: Nullable<_TimeToken>;
  60131. /** @hidden */
  60132. _createTimeQuery(): WebGLQuery;
  60133. /** @hidden */
  60134. _deleteTimeQuery(query: WebGLQuery): void;
  60135. /** @hidden */
  60136. _getGlAlgorithmType(algorithmType: number): number;
  60137. /** @hidden */
  60138. _getTimeQueryResult(query: WebGLQuery): any;
  60139. /** @hidden */
  60140. _getTimeQueryAvailability(query: WebGLQuery): any;
  60141. }
  60142. interface AbstractMesh {
  60143. /**
  60144. * Backing filed
  60145. * @hidden
  60146. */
  60147. __occlusionDataStorage: _OcclusionDataStorage;
  60148. /**
  60149. * Access property
  60150. * @hidden
  60151. */
  60152. _occlusionDataStorage: _OcclusionDataStorage;
  60153. /**
  60154. * 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.
  60155. * The default value is -1 which means don't break the query and wait till the result
  60156. * @see https://doc.babylonjs.com/features/occlusionquery
  60157. */
  60158. occlusionRetryCount: number;
  60159. /**
  60160. * 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:
  60161. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  60162. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  60163. * * 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.
  60164. * @see https://doc.babylonjs.com/features/occlusionquery
  60165. */
  60166. occlusionType: number;
  60167. /**
  60168. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  60169. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  60170. * * 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.
  60171. * @see https://doc.babylonjs.com/features/occlusionquery
  60172. */
  60173. occlusionQueryAlgorithmType: number;
  60174. /**
  60175. * 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
  60176. * @see https://doc.babylonjs.com/features/occlusionquery
  60177. */
  60178. isOccluded: boolean;
  60179. /**
  60180. * Flag to check the progress status of the query
  60181. * @see https://doc.babylonjs.com/features/occlusionquery
  60182. */
  60183. isOcclusionQueryInProgress: boolean;
  60184. }
  60185. }
  60186. declare module BABYLON {
  60187. /** @hidden */
  60188. export var _forceTransformFeedbackToBundle: boolean;
  60189. interface Engine {
  60190. /**
  60191. * Creates a webGL transform feedback object
  60192. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  60193. * @returns the webGL transform feedback object
  60194. */
  60195. createTransformFeedback(): WebGLTransformFeedback;
  60196. /**
  60197. * Delete a webGL transform feedback object
  60198. * @param value defines the webGL transform feedback object to delete
  60199. */
  60200. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  60201. /**
  60202. * Bind a webGL transform feedback object to the webgl context
  60203. * @param value defines the webGL transform feedback object to bind
  60204. */
  60205. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  60206. /**
  60207. * Begins a transform feedback operation
  60208. * @param usePoints defines if points or triangles must be used
  60209. */
  60210. beginTransformFeedback(usePoints: boolean): void;
  60211. /**
  60212. * Ends a transform feedback operation
  60213. */
  60214. endTransformFeedback(): void;
  60215. /**
  60216. * Specify the varyings to use with transform feedback
  60217. * @param program defines the associated webGL program
  60218. * @param value defines the list of strings representing the varying names
  60219. */
  60220. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  60221. /**
  60222. * Bind a webGL buffer for a transform feedback operation
  60223. * @param value defines the webGL buffer to bind
  60224. */
  60225. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  60226. }
  60227. }
  60228. declare module BABYLON {
  60229. /**
  60230. * Class used to define an additional view for the engine
  60231. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60232. */
  60233. export class EngineView {
  60234. /** Defines the canvas where to render the view */
  60235. target: HTMLCanvasElement;
  60236. /** Defines an optional camera used to render the view (will use active camera else) */
  60237. camera?: Camera;
  60238. }
  60239. interface Engine {
  60240. /**
  60241. * Gets or sets the HTML element to use for attaching events
  60242. */
  60243. inputElement: Nullable<HTMLElement>;
  60244. /**
  60245. * Gets the current engine view
  60246. * @see https://doc.babylonjs.com/how_to/multi_canvases
  60247. */
  60248. activeView: Nullable<EngineView>;
  60249. /** Gets or sets the list of views */
  60250. views: EngineView[];
  60251. /**
  60252. * Register a new child canvas
  60253. * @param canvas defines the canvas to register
  60254. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  60255. * @returns the associated view
  60256. */
  60257. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  60258. /**
  60259. * Remove a registered child canvas
  60260. * @param canvas defines the canvas to remove
  60261. * @returns the current engine
  60262. */
  60263. unRegisterView(canvas: HTMLCanvasElement): Engine;
  60264. }
  60265. }
  60266. declare module BABYLON {
  60267. interface Engine {
  60268. /** @hidden */
  60269. _excludedCompressedTextures: string[];
  60270. /** @hidden */
  60271. _textureFormatInUse: string;
  60272. /**
  60273. * Gets the list of texture formats supported
  60274. */
  60275. readonly texturesSupported: Array<string>;
  60276. /**
  60277. * Gets the texture format in use
  60278. */
  60279. readonly textureFormatInUse: Nullable<string>;
  60280. /**
  60281. * Set the compressed texture extensions or file names to skip.
  60282. *
  60283. * @param skippedFiles defines the list of those texture files you want to skip
  60284. * Example: [".dds", ".env", "myfile.png"]
  60285. */
  60286. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  60287. /**
  60288. * Set the compressed texture format to use, based on the formats you have, and the formats
  60289. * supported by the hardware / browser.
  60290. *
  60291. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  60292. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  60293. * to API arguments needed to compressed textures. This puts the burden on the container
  60294. * generator to house the arcane code for determining these for current & future formats.
  60295. *
  60296. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60297. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60298. *
  60299. * Note: The result of this call is not taken into account when a texture is base64.
  60300. *
  60301. * @param formatsAvailable defines the list of those format families you have created
  60302. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  60303. *
  60304. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  60305. * @returns The extension selected.
  60306. */
  60307. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /** @hidden */
  60312. export var rgbdEncodePixelShader: {
  60313. name: string;
  60314. shader: string;
  60315. };
  60316. }
  60317. declare module BABYLON {
  60318. /**
  60319. * Raw texture data and descriptor sufficient for WebGL texture upload
  60320. */
  60321. export interface EnvironmentTextureInfo {
  60322. /**
  60323. * Version of the environment map
  60324. */
  60325. version: number;
  60326. /**
  60327. * Width of image
  60328. */
  60329. width: number;
  60330. /**
  60331. * Irradiance information stored in the file.
  60332. */
  60333. irradiance: any;
  60334. /**
  60335. * Specular information stored in the file.
  60336. */
  60337. specular: any;
  60338. }
  60339. /**
  60340. * Defines One Image in the file. It requires only the position in the file
  60341. * as well as the length.
  60342. */
  60343. interface BufferImageData {
  60344. /**
  60345. * Length of the image data.
  60346. */
  60347. length: number;
  60348. /**
  60349. * Position of the data from the null terminator delimiting the end of the JSON.
  60350. */
  60351. position: number;
  60352. }
  60353. /**
  60354. * Defines the specular data enclosed in the file.
  60355. * This corresponds to the version 1 of the data.
  60356. */
  60357. export interface EnvironmentTextureSpecularInfoV1 {
  60358. /**
  60359. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  60360. */
  60361. specularDataPosition?: number;
  60362. /**
  60363. * This contains all the images data needed to reconstruct the cubemap.
  60364. */
  60365. mipmaps: Array<BufferImageData>;
  60366. /**
  60367. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  60368. */
  60369. lodGenerationScale: number;
  60370. }
  60371. /**
  60372. * Sets of helpers addressing the serialization and deserialization of environment texture
  60373. * stored in a BabylonJS env file.
  60374. * Those files are usually stored as .env files.
  60375. */
  60376. export class EnvironmentTextureTools {
  60377. /**
  60378. * Magic number identifying the env file.
  60379. */
  60380. private static _MagicBytes;
  60381. /**
  60382. * Gets the environment info from an env file.
  60383. * @param data The array buffer containing the .env bytes.
  60384. * @returns the environment file info (the json header) if successfully parsed.
  60385. */
  60386. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  60387. /**
  60388. * Creates an environment texture from a loaded cube texture.
  60389. * @param texture defines the cube texture to convert in env file
  60390. * @return a promise containing the environment data if successful.
  60391. */
  60392. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  60393. /**
  60394. * Creates a JSON representation of the spherical data.
  60395. * @param texture defines the texture containing the polynomials
  60396. * @return the JSON representation of the spherical info
  60397. */
  60398. private static _CreateEnvTextureIrradiance;
  60399. /**
  60400. * Creates the ArrayBufferViews used for initializing environment texture image data.
  60401. * @param data the image data
  60402. * @param info parameters that determine what views will be created for accessing the underlying buffer
  60403. * @return the views described by info providing access to the underlying buffer
  60404. */
  60405. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  60406. /**
  60407. * Uploads the texture info contained in the env file to the GPU.
  60408. * @param texture defines the internal texture to upload to
  60409. * @param data defines the data to load
  60410. * @param info defines the texture info retrieved through the GetEnvInfo method
  60411. * @returns a promise
  60412. */
  60413. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  60414. private static _OnImageReadyAsync;
  60415. /**
  60416. * Uploads the levels of image data to the GPU.
  60417. * @param texture defines the internal texture to upload to
  60418. * @param imageData defines the array buffer views of image data [mipmap][face]
  60419. * @returns a promise
  60420. */
  60421. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  60422. /**
  60423. * Uploads spherical polynomials information to the texture.
  60424. * @param texture defines the texture we are trying to upload the information to
  60425. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  60426. */
  60427. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  60428. /** @hidden */
  60429. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60430. }
  60431. }
  60432. declare module BABYLON {
  60433. /**
  60434. * Container for accessors for natively-stored mesh data buffers.
  60435. */
  60436. class NativeDataBuffer extends DataBuffer {
  60437. /**
  60438. * Accessor value used to identify/retrieve a natively-stored index buffer.
  60439. */
  60440. nativeIndexBuffer?: any;
  60441. /**
  60442. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  60443. */
  60444. nativeVertexBuffer?: any;
  60445. }
  60446. /** @hidden */
  60447. class NativeTexture extends InternalTexture {
  60448. getInternalTexture(): InternalTexture;
  60449. getViewCount(): number;
  60450. }
  60451. /** @hidden */
  60452. export class NativeEngine extends Engine {
  60453. private readonly _native;
  60454. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  60455. private readonly INVALID_HANDLE;
  60456. private _boundBuffersVertexArray;
  60457. private _currentDepthTest;
  60458. getHardwareScalingLevel(): number;
  60459. constructor();
  60460. dispose(): void;
  60461. /**
  60462. * Can be used to override the current requestAnimationFrame requester.
  60463. * @hidden
  60464. */
  60465. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  60466. /**
  60467. * Override default engine behavior.
  60468. * @param color
  60469. * @param backBuffer
  60470. * @param depth
  60471. * @param stencil
  60472. */
  60473. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  60474. /**
  60475. * Gets host document
  60476. * @returns the host document object
  60477. */
  60478. getHostDocument(): Nullable<Document>;
  60479. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  60480. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  60481. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  60482. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  60483. [key: string]: VertexBuffer;
  60484. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60485. bindBuffers(vertexBuffers: {
  60486. [key: string]: VertexBuffer;
  60487. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  60488. recordVertexArrayObject(vertexBuffers: {
  60489. [key: string]: VertexBuffer;
  60490. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  60491. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60492. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  60493. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  60494. /**
  60495. * Draw a list of indexed primitives
  60496. * @param fillMode defines the primitive to use
  60497. * @param indexStart defines the starting index
  60498. * @param indexCount defines the number of index to draw
  60499. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60500. */
  60501. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  60502. /**
  60503. * Draw a list of unindexed primitives
  60504. * @param fillMode defines the primitive to use
  60505. * @param verticesStart defines the index of first vertex to draw
  60506. * @param verticesCount defines the count of vertices to draw
  60507. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  60508. */
  60509. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  60510. createPipelineContext(): IPipelineContext;
  60511. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  60512. /** @hidden */
  60513. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  60514. /** @hidden */
  60515. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  60516. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60517. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  60518. protected _setProgram(program: WebGLProgram): void;
  60519. _releaseEffect(effect: Effect): void;
  60520. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  60521. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  60522. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  60523. bindSamplers(effect: Effect): void;
  60524. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  60525. getRenderWidth(useScreen?: boolean): number;
  60526. getRenderHeight(useScreen?: boolean): number;
  60527. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  60528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  60529. /**
  60530. * Set the z offset to apply to current rendering
  60531. * @param value defines the offset to apply
  60532. */
  60533. setZOffset(value: number): void;
  60534. /**
  60535. * Gets the current value of the zOffset
  60536. * @returns the current zOffset state
  60537. */
  60538. getZOffset(): number;
  60539. /**
  60540. * Enable or disable depth buffering
  60541. * @param enable defines the state to set
  60542. */
  60543. setDepthBuffer(enable: boolean): void;
  60544. /**
  60545. * Gets a boolean indicating if depth writing is enabled
  60546. * @returns the current depth writing state
  60547. */
  60548. getDepthWrite(): boolean;
  60549. setDepthFunctionToGreater(): void;
  60550. setDepthFunctionToGreaterOrEqual(): void;
  60551. setDepthFunctionToLess(): void;
  60552. setDepthFunctionToLessOrEqual(): void;
  60553. /**
  60554. * Enable or disable depth writing
  60555. * @param enable defines the state to set
  60556. */
  60557. setDepthWrite(enable: boolean): void;
  60558. /**
  60559. * Enable or disable color writing
  60560. * @param enable defines the state to set
  60561. */
  60562. setColorWrite(enable: boolean): void;
  60563. /**
  60564. * Gets a boolean indicating if color writing is enabled
  60565. * @returns the current color writing state
  60566. */
  60567. getColorWrite(): boolean;
  60568. /**
  60569. * Sets alpha constants used by some alpha blending modes
  60570. * @param r defines the red component
  60571. * @param g defines the green component
  60572. * @param b defines the blue component
  60573. * @param a defines the alpha component
  60574. */
  60575. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  60576. /**
  60577. * Sets the current alpha mode
  60578. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  60579. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  60580. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60581. */
  60582. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  60583. /**
  60584. * Gets the current alpha mode
  60585. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  60586. * @returns the current alpha mode
  60587. */
  60588. getAlphaMode(): number;
  60589. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  60590. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60591. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60592. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60593. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  60594. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60595. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60596. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60597. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  60598. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  60599. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  60600. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  60601. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  60602. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  60603. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60604. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  60605. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  60606. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  60607. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  60608. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  60609. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  60610. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  60611. wipeCaches(bruteForce?: boolean): void;
  60612. protected _createTexture(): WebGLTexture;
  60613. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  60614. /**
  60615. * Update the content of a dynamic texture
  60616. * @param texture defines the texture to update
  60617. * @param canvas defines the canvas containing the source
  60618. * @param invertY defines if data must be stored with Y axis inverted
  60619. * @param premulAlpha defines if alpha is stored as premultiplied
  60620. * @param format defines the format of the data
  60621. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  60622. */
  60623. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  60624. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  60625. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  60626. /**
  60627. * Usually called from Texture.ts.
  60628. * Passed information to create a WebGLTexture
  60629. * @param url defines a value which contains one of the following:
  60630. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  60631. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  60632. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  60633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  60634. * @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)
  60635. * @param scene needed for loading to the correct scene
  60636. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  60637. * @param onLoad optional callback to be called upon successful completion
  60638. * @param onError optional callback to be called upon failure
  60639. * @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
  60640. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  60641. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  60642. * @param forcedExtension defines the extension to use to pick the right loader
  60643. * @param mimeType defines an optional mime type
  60644. * @param loaderOptions options to be passed to the loader
  60645. * @returns a InternalTexture for assignment back into BABYLON.Texture
  60646. */
  60647. 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;
  60648. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  60649. _releaseFramebufferObjects(texture: InternalTexture): void;
  60650. /**
  60651. * Creates a cube texture
  60652. * @param rootUrl defines the url where the files to load is located
  60653. * @param scene defines the current scene
  60654. * @param files defines the list of files to load (1 per face)
  60655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  60656. * @param onLoad defines an optional callback raised when the texture is loaded
  60657. * @param onError defines an optional callback raised if there is an issue to load the texture
  60658. * @param format defines the format of the data
  60659. * @param forcedExtension defines the extension to use to pick the right loader
  60660. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  60661. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60662. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60663. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  60664. * @returns the cube texture as an InternalTexture
  60665. */
  60666. 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;
  60667. createRenderTargetTexture(size: number | {
  60668. width: number;
  60669. height: number;
  60670. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  60671. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  60672. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60674. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60675. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60676. /**
  60677. * Updates a dynamic vertex buffer.
  60678. * @param vertexBuffer the vertex buffer to update
  60679. * @param data the data used to update the vertex buffer
  60680. * @param byteOffset the byte offset of the data (optional)
  60681. * @param byteLength the byte length of the data (optional)
  60682. */
  60683. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60684. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60685. private _updateAnisotropicLevel;
  60686. private _getAddressMode;
  60687. /** @hidden */
  60688. _bindTexture(channel: number, texture: InternalTexture): void;
  60689. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60690. releaseEffects(): void;
  60691. /** @hidden */
  60692. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60693. /** @hidden */
  60694. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60695. /** @hidden */
  60696. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60697. /** @hidden */
  60698. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60699. private _getNativeSamplingMode;
  60700. private _getNativeTextureFormat;
  60701. private _getNativeAlphaMode;
  60702. private _getNativeAttribType;
  60703. }
  60704. }
  60705. declare module BABYLON {
  60706. /**
  60707. * Helper class to create the best engine depending on the current hardware
  60708. */
  60709. export class EngineFactory {
  60710. /**
  60711. * Creates an engine based on the capabilities of the underlying hardware
  60712. * @param canvas Defines the canvas to use to display the result
  60713. * @param options Defines the options passed to the engine to create the context dependencies
  60714. * @returns a promise that resolves with the created engine
  60715. */
  60716. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60717. }
  60718. }
  60719. declare module BABYLON {
  60720. /**
  60721. * Gather the list of clipboard event types as constants.
  60722. */
  60723. export class ClipboardEventTypes {
  60724. /**
  60725. * The clipboard event is fired when a copy command is active (pressed).
  60726. */
  60727. static readonly COPY: number;
  60728. /**
  60729. * The clipboard event is fired when a cut command is active (pressed).
  60730. */
  60731. static readonly CUT: number;
  60732. /**
  60733. * The clipboard event is fired when a paste command is active (pressed).
  60734. */
  60735. static readonly PASTE: number;
  60736. }
  60737. /**
  60738. * This class is used to store clipboard related info for the onClipboardObservable event.
  60739. */
  60740. export class ClipboardInfo {
  60741. /**
  60742. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60743. */
  60744. type: number;
  60745. /**
  60746. * Defines the related dom event
  60747. */
  60748. event: ClipboardEvent;
  60749. /**
  60750. *Creates an instance of ClipboardInfo.
  60751. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60752. * @param event Defines the related dom event
  60753. */
  60754. constructor(
  60755. /**
  60756. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60757. */
  60758. type: number,
  60759. /**
  60760. * Defines the related dom event
  60761. */
  60762. event: ClipboardEvent);
  60763. /**
  60764. * Get the clipboard event's type from the keycode.
  60765. * @param keyCode Defines the keyCode for the current keyboard event.
  60766. * @return {number}
  60767. */
  60768. static GetTypeFromCharacter(keyCode: number): number;
  60769. }
  60770. }
  60771. declare module BABYLON {
  60772. /**
  60773. * Google Daydream controller
  60774. */
  60775. export class DaydreamController extends WebVRController {
  60776. /**
  60777. * Base Url for the controller model.
  60778. */
  60779. static MODEL_BASE_URL: string;
  60780. /**
  60781. * File name for the controller model.
  60782. */
  60783. static MODEL_FILENAME: string;
  60784. /**
  60785. * Gamepad Id prefix used to identify Daydream Controller.
  60786. */
  60787. static readonly GAMEPAD_ID_PREFIX: string;
  60788. /**
  60789. * Creates a new DaydreamController from a gamepad
  60790. * @param vrGamepad the gamepad that the controller should be created from
  60791. */
  60792. constructor(vrGamepad: any);
  60793. /**
  60794. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60795. * @param scene scene in which to add meshes
  60796. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60797. */
  60798. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60799. /**
  60800. * Called once for each button that changed state since the last frame
  60801. * @param buttonIdx Which button index changed
  60802. * @param state New state of the button
  60803. * @param changes Which properties on the state changed since last frame
  60804. */
  60805. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60806. }
  60807. }
  60808. declare module BABYLON {
  60809. /**
  60810. * Gear VR Controller
  60811. */
  60812. export class GearVRController extends WebVRController {
  60813. /**
  60814. * Base Url for the controller model.
  60815. */
  60816. static MODEL_BASE_URL: string;
  60817. /**
  60818. * File name for the controller model.
  60819. */
  60820. static MODEL_FILENAME: string;
  60821. /**
  60822. * Gamepad Id prefix used to identify this controller.
  60823. */
  60824. static readonly GAMEPAD_ID_PREFIX: string;
  60825. private readonly _buttonIndexToObservableNameMap;
  60826. /**
  60827. * Creates a new GearVRController from a gamepad
  60828. * @param vrGamepad the gamepad that the controller should be created from
  60829. */
  60830. constructor(vrGamepad: any);
  60831. /**
  60832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60833. * @param scene scene in which to add meshes
  60834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60835. */
  60836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60837. /**
  60838. * Called once for each button that changed state since the last frame
  60839. * @param buttonIdx Which button index changed
  60840. * @param state New state of the button
  60841. * @param changes Which properties on the state changed since last frame
  60842. */
  60843. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60844. }
  60845. }
  60846. declare module BABYLON {
  60847. /**
  60848. * Generic Controller
  60849. */
  60850. export class GenericController extends WebVRController {
  60851. /**
  60852. * Base Url for the controller model.
  60853. */
  60854. static readonly MODEL_BASE_URL: string;
  60855. /**
  60856. * File name for the controller model.
  60857. */
  60858. static readonly MODEL_FILENAME: string;
  60859. /**
  60860. * Creates a new GenericController from a gamepad
  60861. * @param vrGamepad the gamepad that the controller should be created from
  60862. */
  60863. constructor(vrGamepad: any);
  60864. /**
  60865. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60866. * @param scene scene in which to add meshes
  60867. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60868. */
  60869. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60870. /**
  60871. * Called once for each button that changed state since the last frame
  60872. * @param buttonIdx Which button index changed
  60873. * @param state New state of the button
  60874. * @param changes Which properties on the state changed since last frame
  60875. */
  60876. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60877. }
  60878. }
  60879. declare module BABYLON {
  60880. /**
  60881. * Oculus Touch Controller
  60882. */
  60883. export class OculusTouchController extends WebVRController {
  60884. /**
  60885. * Base Url for the controller model.
  60886. */
  60887. static MODEL_BASE_URL: string;
  60888. /**
  60889. * File name for the left controller model.
  60890. */
  60891. static MODEL_LEFT_FILENAME: string;
  60892. /**
  60893. * File name for the right controller model.
  60894. */
  60895. static MODEL_RIGHT_FILENAME: string;
  60896. /**
  60897. * Base Url for the Quest controller model.
  60898. */
  60899. static QUEST_MODEL_BASE_URL: string;
  60900. /**
  60901. * @hidden
  60902. * If the controllers are running on a device that needs the updated Quest controller models
  60903. */
  60904. static _IsQuest: boolean;
  60905. /**
  60906. * Fired when the secondary trigger on this controller is modified
  60907. */
  60908. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60909. /**
  60910. * Fired when the thumb rest on this controller is modified
  60911. */
  60912. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60913. /**
  60914. * Creates a new OculusTouchController from a gamepad
  60915. * @param vrGamepad the gamepad that the controller should be created from
  60916. */
  60917. constructor(vrGamepad: any);
  60918. /**
  60919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60920. * @param scene scene in which to add meshes
  60921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60922. */
  60923. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60924. /**
  60925. * Fired when the A button on this controller is modified
  60926. */
  60927. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60928. /**
  60929. * Fired when the B button on this controller is modified
  60930. */
  60931. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60932. /**
  60933. * Fired when the X button on this controller is modified
  60934. */
  60935. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60936. /**
  60937. * Fired when the Y button on this controller is modified
  60938. */
  60939. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60940. /**
  60941. * Called once for each button that changed state since the last frame
  60942. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60943. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60944. * 2) secondary trigger (same)
  60945. * 3) A (right) X (left), touch, pressed = value
  60946. * 4) B / Y
  60947. * 5) thumb rest
  60948. * @param buttonIdx Which button index changed
  60949. * @param state New state of the button
  60950. * @param changes Which properties on the state changed since last frame
  60951. */
  60952. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60953. }
  60954. }
  60955. declare module BABYLON {
  60956. /**
  60957. * Vive Controller
  60958. */
  60959. export class ViveController extends WebVRController {
  60960. /**
  60961. * Base Url for the controller model.
  60962. */
  60963. static MODEL_BASE_URL: string;
  60964. /**
  60965. * File name for the controller model.
  60966. */
  60967. static MODEL_FILENAME: string;
  60968. /**
  60969. * Creates a new ViveController from a gamepad
  60970. * @param vrGamepad the gamepad that the controller should be created from
  60971. */
  60972. constructor(vrGamepad: any);
  60973. /**
  60974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60975. * @param scene scene in which to add meshes
  60976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60977. */
  60978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60979. /**
  60980. * Fired when the left button on this controller is modified
  60981. */
  60982. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60983. /**
  60984. * Fired when the right button on this controller is modified
  60985. */
  60986. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60987. /**
  60988. * Fired when the menu button on this controller is modified
  60989. */
  60990. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60991. /**
  60992. * Called once for each button that changed state since the last frame
  60993. * Vive mapping:
  60994. * 0: touchpad
  60995. * 1: trigger
  60996. * 2: left AND right buttons
  60997. * 3: menu button
  60998. * @param buttonIdx Which button index changed
  60999. * @param state New state of the button
  61000. * @param changes Which properties on the state changed since last frame
  61001. */
  61002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. /**
  61007. * Defines the WindowsMotionController object that the state of the windows motion controller
  61008. */
  61009. export class WindowsMotionController extends WebVRController {
  61010. /**
  61011. * The base url used to load the left and right controller models
  61012. */
  61013. static MODEL_BASE_URL: string;
  61014. /**
  61015. * The name of the left controller model file
  61016. */
  61017. static MODEL_LEFT_FILENAME: string;
  61018. /**
  61019. * The name of the right controller model file
  61020. */
  61021. static MODEL_RIGHT_FILENAME: string;
  61022. /**
  61023. * The controller name prefix for this controller type
  61024. */
  61025. static readonly GAMEPAD_ID_PREFIX: string;
  61026. /**
  61027. * The controller id pattern for this controller type
  61028. */
  61029. private static readonly GAMEPAD_ID_PATTERN;
  61030. private _loadedMeshInfo;
  61031. protected readonly _mapping: {
  61032. buttons: string[];
  61033. buttonMeshNames: {
  61034. trigger: string;
  61035. menu: string;
  61036. grip: string;
  61037. thumbstick: string;
  61038. trackpad: string;
  61039. };
  61040. buttonObservableNames: {
  61041. trigger: string;
  61042. menu: string;
  61043. grip: string;
  61044. thumbstick: string;
  61045. trackpad: string;
  61046. };
  61047. axisMeshNames: string[];
  61048. pointingPoseMeshName: string;
  61049. };
  61050. /**
  61051. * Fired when the trackpad on this controller is clicked
  61052. */
  61053. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61054. /**
  61055. * Fired when the trackpad on this controller is modified
  61056. */
  61057. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61058. /**
  61059. * The current x and y values of this controller's trackpad
  61060. */
  61061. trackpad: StickValues;
  61062. /**
  61063. * Creates a new WindowsMotionController from a gamepad
  61064. * @param vrGamepad the gamepad that the controller should be created from
  61065. */
  61066. constructor(vrGamepad: any);
  61067. /**
  61068. * Fired when the trigger on this controller is modified
  61069. */
  61070. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61071. /**
  61072. * Fired when the menu button on this controller is modified
  61073. */
  61074. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61075. /**
  61076. * Fired when the grip button on this controller is modified
  61077. */
  61078. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61079. /**
  61080. * Fired when the thumbstick button on this controller is modified
  61081. */
  61082. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61083. /**
  61084. * Fired when the touchpad button on this controller is modified
  61085. */
  61086. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61087. /**
  61088. * Fired when the touchpad values on this controller are modified
  61089. */
  61090. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  61091. protected _updateTrackpad(): void;
  61092. /**
  61093. * Called once per frame by the engine.
  61094. */
  61095. update(): void;
  61096. /**
  61097. * Called once for each button that changed state since the last frame
  61098. * @param buttonIdx Which button index changed
  61099. * @param state New state of the button
  61100. * @param changes Which properties on the state changed since last frame
  61101. */
  61102. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  61103. /**
  61104. * Moves the buttons on the controller mesh based on their current state
  61105. * @param buttonName the name of the button to move
  61106. * @param buttonValue the value of the button which determines the buttons new position
  61107. */
  61108. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  61109. /**
  61110. * Moves the axis on the controller mesh based on its current state
  61111. * @param axis the index of the axis
  61112. * @param axisValue the value of the axis which determines the meshes new position
  61113. * @hidden
  61114. */
  61115. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  61116. /**
  61117. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  61118. * @param scene scene in which to add meshes
  61119. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  61120. */
  61121. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  61122. /**
  61123. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  61124. * can be transformed by button presses and axes values, based on this._mapping.
  61125. *
  61126. * @param scene scene in which the meshes exist
  61127. * @param meshes list of meshes that make up the controller model to process
  61128. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  61129. */
  61130. private processModel;
  61131. private createMeshInfo;
  61132. /**
  61133. * Gets the ray of the controller in the direction the controller is pointing
  61134. * @param length the length the resulting ray should be
  61135. * @returns a ray in the direction the controller is pointing
  61136. */
  61137. getForwardRay(length?: number): Ray;
  61138. /**
  61139. * Disposes of the controller
  61140. */
  61141. dispose(): void;
  61142. }
  61143. /**
  61144. * This class represents a new windows motion controller in XR.
  61145. */
  61146. export class XRWindowsMotionController extends WindowsMotionController {
  61147. /**
  61148. * Changing the original WIndowsMotionController mapping to fir the new mapping
  61149. */
  61150. protected readonly _mapping: {
  61151. buttons: string[];
  61152. buttonMeshNames: {
  61153. trigger: string;
  61154. menu: string;
  61155. grip: string;
  61156. thumbstick: string;
  61157. trackpad: string;
  61158. };
  61159. buttonObservableNames: {
  61160. trigger: string;
  61161. menu: string;
  61162. grip: string;
  61163. thumbstick: string;
  61164. trackpad: string;
  61165. };
  61166. axisMeshNames: string[];
  61167. pointingPoseMeshName: string;
  61168. };
  61169. /**
  61170. * Construct a new XR-Based windows motion controller
  61171. *
  61172. * @param gamepadInfo the gamepad object from the browser
  61173. */
  61174. constructor(gamepadInfo: any);
  61175. /**
  61176. * holds the thumbstick values (X,Y)
  61177. */
  61178. thumbstickValues: StickValues;
  61179. /**
  61180. * Fired when the thumbstick on this controller is clicked
  61181. */
  61182. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  61183. /**
  61184. * Fired when the thumbstick on this controller is modified
  61185. */
  61186. onThumbstickValuesChangedObservable: Observable<StickValues>;
  61187. /**
  61188. * Fired when the touchpad button on this controller is modified
  61189. */
  61190. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  61191. /**
  61192. * Fired when the touchpad values on this controller are modified
  61193. */
  61194. onTrackpadValuesChangedObservable: Observable<StickValues>;
  61195. /**
  61196. * Fired when the thumbstick button on this controller is modified
  61197. * here to prevent breaking changes
  61198. */
  61199. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  61200. /**
  61201. * updating the thumbstick(!) and not the trackpad.
  61202. * This is named this way due to the difference between WebVR and XR and to avoid
  61203. * changing the parent class.
  61204. */
  61205. protected _updateTrackpad(): void;
  61206. /**
  61207. * Disposes the class with joy
  61208. */
  61209. dispose(): void;
  61210. }
  61211. }
  61212. declare module BABYLON {
  61213. /**
  61214. * A directional light is defined by a direction (what a surprise!).
  61215. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  61216. * 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.
  61217. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61218. */
  61219. export class DirectionalLight extends ShadowLight {
  61220. private _shadowFrustumSize;
  61221. /**
  61222. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  61223. */
  61224. get shadowFrustumSize(): number;
  61225. /**
  61226. * Specifies a fix frustum size for the shadow generation.
  61227. */
  61228. set shadowFrustumSize(value: number);
  61229. private _shadowOrthoScale;
  61230. /**
  61231. * Gets the shadow projection scale against the optimal computed one.
  61232. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61233. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61234. */
  61235. get shadowOrthoScale(): number;
  61236. /**
  61237. * Sets the shadow projection scale against the optimal computed one.
  61238. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  61239. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  61240. */
  61241. set shadowOrthoScale(value: number);
  61242. /**
  61243. * Automatically compute the projection matrix to best fit (including all the casters)
  61244. * on each frame.
  61245. */
  61246. autoUpdateExtends: boolean;
  61247. /**
  61248. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  61249. * on each frame. autoUpdateExtends must be set to true for this to work
  61250. */
  61251. autoCalcShadowZBounds: boolean;
  61252. private _orthoLeft;
  61253. private _orthoRight;
  61254. private _orthoTop;
  61255. private _orthoBottom;
  61256. /**
  61257. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  61258. * The directional light is emitted from everywhere in the given direction.
  61259. * It can cast shadows.
  61260. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61261. * @param name The friendly name of the light
  61262. * @param direction The direction of the light
  61263. * @param scene The scene the light belongs to
  61264. */
  61265. constructor(name: string, direction: Vector3, scene: Scene);
  61266. /**
  61267. * Returns the string "DirectionalLight".
  61268. * @return The class name
  61269. */
  61270. getClassName(): string;
  61271. /**
  61272. * Returns the integer 1.
  61273. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61274. */
  61275. getTypeID(): number;
  61276. /**
  61277. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  61278. * Returns the DirectionalLight Shadow projection matrix.
  61279. */
  61280. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61281. /**
  61282. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  61283. * Returns the DirectionalLight Shadow projection matrix.
  61284. */
  61285. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  61286. /**
  61287. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  61288. * Returns the DirectionalLight Shadow projection matrix.
  61289. */
  61290. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61291. protected _buildUniformLayout(): void;
  61292. /**
  61293. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  61294. * @param effect The effect to update
  61295. * @param lightIndex The index of the light in the effect to update
  61296. * @returns The directional light
  61297. */
  61298. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  61299. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  61300. /**
  61301. * Gets the minZ used for shadow according to both the scene and the light.
  61302. *
  61303. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61304. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61305. * @param activeCamera The camera we are returning the min for
  61306. * @returns the depth min z
  61307. */
  61308. getDepthMinZ(activeCamera: Camera): number;
  61309. /**
  61310. * Gets the maxZ used for shadow according to both the scene and the light.
  61311. *
  61312. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  61313. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  61314. * @param activeCamera The camera we are returning the max for
  61315. * @returns the depth max z
  61316. */
  61317. getDepthMaxZ(activeCamera: Camera): number;
  61318. /**
  61319. * Prepares the list of defines specific to the light type.
  61320. * @param defines the list of defines
  61321. * @param lightIndex defines the index of the light for the effect
  61322. */
  61323. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61324. }
  61325. }
  61326. declare module BABYLON {
  61327. /**
  61328. * Class containing static functions to help procedurally build meshes
  61329. */
  61330. export class HemisphereBuilder {
  61331. /**
  61332. * Creates a hemisphere mesh
  61333. * @param name defines the name of the mesh
  61334. * @param options defines the options used to create the mesh
  61335. * @param scene defines the hosting scene
  61336. * @returns the hemisphere mesh
  61337. */
  61338. static CreateHemisphere(name: string, options: {
  61339. segments?: number;
  61340. diameter?: number;
  61341. sideOrientation?: number;
  61342. }, scene: any): Mesh;
  61343. }
  61344. }
  61345. declare module BABYLON {
  61346. /**
  61347. * A spot light is defined by a position, a direction, an angle, and an exponent.
  61348. * These values define a cone of light starting from the position, emitting toward the direction.
  61349. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  61350. * and the exponent defines the speed of the decay of the light with distance (reach).
  61351. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61352. */
  61353. export class SpotLight extends ShadowLight {
  61354. private _angle;
  61355. private _innerAngle;
  61356. private _cosHalfAngle;
  61357. private _lightAngleScale;
  61358. private _lightAngleOffset;
  61359. /**
  61360. * Gets the cone angle of the spot light in Radians.
  61361. */
  61362. get angle(): number;
  61363. /**
  61364. * Sets the cone angle of the spot light in Radians.
  61365. */
  61366. set angle(value: number);
  61367. /**
  61368. * Only used in gltf falloff mode, this defines the angle where
  61369. * the directional falloff will start before cutting at angle which could be seen
  61370. * as outer angle.
  61371. */
  61372. get innerAngle(): number;
  61373. /**
  61374. * Only used in gltf falloff mode, this defines the angle where
  61375. * the directional falloff will start before cutting at angle which could be seen
  61376. * as outer angle.
  61377. */
  61378. set innerAngle(value: number);
  61379. private _shadowAngleScale;
  61380. /**
  61381. * Allows scaling the angle of the light for shadow generation only.
  61382. */
  61383. get shadowAngleScale(): number;
  61384. /**
  61385. * Allows scaling the angle of the light for shadow generation only.
  61386. */
  61387. set shadowAngleScale(value: number);
  61388. /**
  61389. * The light decay speed with the distance from the emission spot.
  61390. */
  61391. exponent: number;
  61392. private _projectionTextureMatrix;
  61393. /**
  61394. * Allows reading the projection texture
  61395. */
  61396. get projectionTextureMatrix(): Matrix;
  61397. protected _projectionTextureLightNear: number;
  61398. /**
  61399. * Gets the near clip of the Spotlight for texture projection.
  61400. */
  61401. get projectionTextureLightNear(): number;
  61402. /**
  61403. * Sets the near clip of the Spotlight for texture projection.
  61404. */
  61405. set projectionTextureLightNear(value: number);
  61406. protected _projectionTextureLightFar: number;
  61407. /**
  61408. * Gets the far clip of the Spotlight for texture projection.
  61409. */
  61410. get projectionTextureLightFar(): number;
  61411. /**
  61412. * Sets the far clip of the Spotlight for texture projection.
  61413. */
  61414. set projectionTextureLightFar(value: number);
  61415. protected _projectionTextureUpDirection: Vector3;
  61416. /**
  61417. * Gets the Up vector of the Spotlight for texture projection.
  61418. */
  61419. get projectionTextureUpDirection(): Vector3;
  61420. /**
  61421. * Sets the Up vector of the Spotlight for texture projection.
  61422. */
  61423. set projectionTextureUpDirection(value: Vector3);
  61424. private _projectionTexture;
  61425. /**
  61426. * Gets the projection texture of the light.
  61427. */
  61428. get projectionTexture(): Nullable<BaseTexture>;
  61429. /**
  61430. * Sets the projection texture of the light.
  61431. */
  61432. set projectionTexture(value: Nullable<BaseTexture>);
  61433. private static _IsProceduralTexture;
  61434. private static _IsTexture;
  61435. private _projectionTextureViewLightDirty;
  61436. private _projectionTextureProjectionLightDirty;
  61437. private _projectionTextureDirty;
  61438. private _projectionTextureViewTargetVector;
  61439. private _projectionTextureViewLightMatrix;
  61440. private _projectionTextureProjectionLightMatrix;
  61441. private _projectionTextureScalingMatrix;
  61442. /**
  61443. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  61444. * It can cast shadows.
  61445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61446. * @param name The light friendly name
  61447. * @param position The position of the spot light in the scene
  61448. * @param direction The direction of the light in the scene
  61449. * @param angle The cone angle of the light in Radians
  61450. * @param exponent The light decay speed with the distance from the emission spot
  61451. * @param scene The scene the lights belongs to
  61452. */
  61453. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  61454. /**
  61455. * Returns the string "SpotLight".
  61456. * @returns the class name
  61457. */
  61458. getClassName(): string;
  61459. /**
  61460. * Returns the integer 2.
  61461. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61462. */
  61463. getTypeID(): number;
  61464. /**
  61465. * Overrides the direction setter to recompute the projection texture view light Matrix.
  61466. */
  61467. protected _setDirection(value: Vector3): void;
  61468. /**
  61469. * Overrides the position setter to recompute the projection texture view light Matrix.
  61470. */
  61471. protected _setPosition(value: Vector3): void;
  61472. /**
  61473. * 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.
  61474. * Returns the SpotLight.
  61475. */
  61476. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61477. protected _computeProjectionTextureViewLightMatrix(): void;
  61478. protected _computeProjectionTextureProjectionLightMatrix(): void;
  61479. /**
  61480. * Main function for light texture projection matrix computing.
  61481. */
  61482. protected _computeProjectionTextureMatrix(): void;
  61483. protected _buildUniformLayout(): void;
  61484. private _computeAngleValues;
  61485. /**
  61486. * Sets the passed Effect "effect" with the Light textures.
  61487. * @param effect The effect to update
  61488. * @param lightIndex The index of the light in the effect to update
  61489. * @returns The light
  61490. */
  61491. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  61492. /**
  61493. * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.
  61494. * @param effect The effect to update
  61495. * @param lightIndex The index of the light in the effect to update
  61496. * @returns The spot light
  61497. */
  61498. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  61499. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61500. /**
  61501. * Disposes the light and the associated resources.
  61502. */
  61503. dispose(): void;
  61504. /**
  61505. * Prepares the list of defines specific to the light type.
  61506. * @param defines the list of defines
  61507. * @param lightIndex defines the index of the light for the effect
  61508. */
  61509. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61510. }
  61511. }
  61512. declare module BABYLON {
  61513. /**
  61514. * Gizmo that enables viewing a light
  61515. */
  61516. export class LightGizmo extends Gizmo {
  61517. private _lightMesh;
  61518. private _material;
  61519. private _cachedPosition;
  61520. private _cachedForward;
  61521. private _attachedMeshParent;
  61522. private _pointerObserver;
  61523. /**
  61524. * Event that fires each time the gizmo is clicked
  61525. */
  61526. onClickedObservable: Observable<Light>;
  61527. /**
  61528. * Creates a LightGizmo
  61529. * @param gizmoLayer The utility layer the gizmo will be added to
  61530. */
  61531. constructor(gizmoLayer?: UtilityLayerRenderer);
  61532. private _light;
  61533. /**
  61534. * The light that the gizmo is attached to
  61535. */
  61536. set light(light: Nullable<Light>);
  61537. get light(): Nullable<Light>;
  61538. /**
  61539. * Gets the material used to render the light gizmo
  61540. */
  61541. get material(): StandardMaterial;
  61542. /**
  61543. * @hidden
  61544. * Updates the gizmo to match the attached mesh's position/rotation
  61545. */
  61546. protected _update(): void;
  61547. private static _Scale;
  61548. /**
  61549. * Creates the lines for a light mesh
  61550. */
  61551. private static _CreateLightLines;
  61552. /**
  61553. * Disposes of the light gizmo
  61554. */
  61555. dispose(): void;
  61556. private static _CreateHemisphericLightMesh;
  61557. private static _CreatePointLightMesh;
  61558. private static _CreateSpotLightMesh;
  61559. private static _CreateDirectionalLightMesh;
  61560. }
  61561. }
  61562. declare module BABYLON {
  61563. /**
  61564. * Gizmo that enables viewing a camera
  61565. */
  61566. export class CameraGizmo extends Gizmo {
  61567. private _cameraMesh;
  61568. private _cameraLinesMesh;
  61569. private _material;
  61570. private _pointerObserver;
  61571. /**
  61572. * Event that fires each time the gizmo is clicked
  61573. */
  61574. onClickedObservable: Observable<Camera>;
  61575. /**
  61576. * Creates a CameraGizmo
  61577. * @param gizmoLayer The utility layer the gizmo will be added to
  61578. */
  61579. constructor(gizmoLayer?: UtilityLayerRenderer);
  61580. private _camera;
  61581. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  61582. get displayFrustum(): boolean;
  61583. set displayFrustum(value: boolean);
  61584. /**
  61585. * The camera that the gizmo is attached to
  61586. */
  61587. set camera(camera: Nullable<Camera>);
  61588. get camera(): Nullable<Camera>;
  61589. /**
  61590. * Gets the material used to render the camera gizmo
  61591. */
  61592. get material(): StandardMaterial;
  61593. /**
  61594. * @hidden
  61595. * Updates the gizmo to match the attached mesh's position/rotation
  61596. */
  61597. protected _update(): void;
  61598. private static _Scale;
  61599. private _invProjection;
  61600. /**
  61601. * Disposes of the camera gizmo
  61602. */
  61603. dispose(): void;
  61604. private static _CreateCameraMesh;
  61605. private static _CreateCameraFrustum;
  61606. }
  61607. }
  61608. declare module BABYLON {
  61609. /** @hidden */
  61610. export var backgroundFragmentDeclaration: {
  61611. name: string;
  61612. shader: string;
  61613. };
  61614. }
  61615. declare module BABYLON {
  61616. /** @hidden */
  61617. export var backgroundUboDeclaration: {
  61618. name: string;
  61619. shader: string;
  61620. };
  61621. }
  61622. declare module BABYLON {
  61623. /** @hidden */
  61624. export var backgroundPixelShader: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module BABYLON {
  61630. /** @hidden */
  61631. export var backgroundVertexDeclaration: {
  61632. name: string;
  61633. shader: string;
  61634. };
  61635. }
  61636. declare module BABYLON {
  61637. /** @hidden */
  61638. export var backgroundVertexShader: {
  61639. name: string;
  61640. shader: string;
  61641. };
  61642. }
  61643. declare module BABYLON {
  61644. /**
  61645. * Background material used to create an efficient environment around your scene.
  61646. */
  61647. export class BackgroundMaterial extends PushMaterial {
  61648. /**
  61649. * Standard reflectance value at parallel view angle.
  61650. */
  61651. static StandardReflectance0: number;
  61652. /**
  61653. * Standard reflectance value at grazing angle.
  61654. */
  61655. static StandardReflectance90: number;
  61656. protected _primaryColor: Color3;
  61657. /**
  61658. * Key light Color (multiply against the environment texture)
  61659. */
  61660. primaryColor: Color3;
  61661. protected __perceptualColor: Nullable<Color3>;
  61662. /**
  61663. * Experimental Internal Use Only.
  61664. *
  61665. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  61666. * This acts as a helper to set the primary color to a more "human friendly" value.
  61667. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  61668. * output color as close as possible from the chosen value.
  61669. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  61670. * part of lighting setup.)
  61671. */
  61672. get _perceptualColor(): Nullable<Color3>;
  61673. set _perceptualColor(value: Nullable<Color3>);
  61674. protected _primaryColorShadowLevel: float;
  61675. /**
  61676. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61677. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61678. */
  61679. get primaryColorShadowLevel(): float;
  61680. set primaryColorShadowLevel(value: float);
  61681. protected _primaryColorHighlightLevel: float;
  61682. /**
  61683. * Defines the level of the highlights (highlight area of the reflection map) in order to help scaling the colors.
  61684. * The primary color is used at the level chosen to define what the white area would look.
  61685. */
  61686. get primaryColorHighlightLevel(): float;
  61687. set primaryColorHighlightLevel(value: float);
  61688. protected _reflectionTexture: Nullable<BaseTexture>;
  61689. /**
  61690. * Reflection Texture used in the material.
  61691. * Should be author in a specific way for the best result (refer to the documentation).
  61692. */
  61693. reflectionTexture: Nullable<BaseTexture>;
  61694. protected _reflectionBlur: float;
  61695. /**
  61696. * Reflection Texture level of blur.
  61697. *
  61698. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61699. * texture twice.
  61700. */
  61701. reflectionBlur: float;
  61702. protected _diffuseTexture: Nullable<BaseTexture>;
  61703. /**
  61704. * Diffuse Texture used in the material.
  61705. * Should be author in a specific way for the best result (refer to the documentation).
  61706. */
  61707. diffuseTexture: Nullable<BaseTexture>;
  61708. protected _shadowLights: Nullable<IShadowLight[]>;
  61709. /**
  61710. * Specify the list of lights casting shadow on the material.
  61711. * All scene shadow lights will be included if null.
  61712. */
  61713. shadowLights: Nullable<IShadowLight[]>;
  61714. protected _shadowLevel: float;
  61715. /**
  61716. * Helps adjusting the shadow to a softer level if required.
  61717. * 0 means black shadows and 1 means no shadows.
  61718. */
  61719. shadowLevel: float;
  61720. protected _sceneCenter: Vector3;
  61721. /**
  61722. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61723. * It is usually zero but might be interesting to modify according to your setup.
  61724. */
  61725. sceneCenter: Vector3;
  61726. protected _opacityFresnel: boolean;
  61727. /**
  61728. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61729. * This helps ensuring a nice transition when the camera goes under the ground.
  61730. */
  61731. opacityFresnel: boolean;
  61732. protected _reflectionFresnel: boolean;
  61733. /**
  61734. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61735. * This helps adding a mirror texture on the ground.
  61736. */
  61737. reflectionFresnel: boolean;
  61738. protected _reflectionFalloffDistance: number;
  61739. /**
  61740. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61741. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61742. */
  61743. reflectionFalloffDistance: number;
  61744. protected _reflectionAmount: number;
  61745. /**
  61746. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61747. */
  61748. reflectionAmount: number;
  61749. protected _reflectionReflectance0: number;
  61750. /**
  61751. * This specifies the weight of the reflection at grazing angle.
  61752. */
  61753. reflectionReflectance0: number;
  61754. protected _reflectionReflectance90: number;
  61755. /**
  61756. * This specifies the weight of the reflection at a perpendicular point of view.
  61757. */
  61758. reflectionReflectance90: number;
  61759. /**
  61760. * Sets the reflection reflectance fresnel values according to the default standard
  61761. * empirically know to work well :-)
  61762. */
  61763. set reflectionStandardFresnelWeight(value: number);
  61764. protected _useRGBColor: boolean;
  61765. /**
  61766. * Helps to directly use the maps channels instead of their level.
  61767. */
  61768. useRGBColor: boolean;
  61769. protected _enableNoise: boolean;
  61770. /**
  61771. * This helps reducing the banding effect that could occur on the background.
  61772. */
  61773. enableNoise: boolean;
  61774. /**
  61775. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61776. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61777. * Recommended to be keep at 1.0 except for special cases.
  61778. */
  61779. get fovMultiplier(): number;
  61780. set fovMultiplier(value: number);
  61781. private _fovMultiplier;
  61782. /**
  61783. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61784. */
  61785. useEquirectangularFOV: boolean;
  61786. private _maxSimultaneousLights;
  61787. /**
  61788. * Number of Simultaneous lights allowed on the material.
  61789. */
  61790. maxSimultaneousLights: int;
  61791. private _shadowOnly;
  61792. /**
  61793. * Make the material only render shadows
  61794. */
  61795. shadowOnly: boolean;
  61796. /**
  61797. * Default configuration related to image processing available in the Background Material.
  61798. */
  61799. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61800. /**
  61801. * Keep track of the image processing observer to allow dispose and replace.
  61802. */
  61803. private _imageProcessingObserver;
  61804. /**
  61805. * Attaches a new image processing configuration to the PBR Material.
  61806. * @param configuration (if null the scene configuration will be use)
  61807. */
  61808. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61809. /**
  61810. * Gets the image processing configuration used either in this material.
  61811. */
  61812. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61813. /**
  61814. * Sets the Default image processing configuration used either in the this material.
  61815. *
  61816. * If sets to null, the scene one is in use.
  61817. */
  61818. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61819. /**
  61820. * Gets whether the color curves effect is enabled.
  61821. */
  61822. get cameraColorCurvesEnabled(): boolean;
  61823. /**
  61824. * Sets whether the color curves effect is enabled.
  61825. */
  61826. set cameraColorCurvesEnabled(value: boolean);
  61827. /**
  61828. * Gets whether the color grading effect is enabled.
  61829. */
  61830. get cameraColorGradingEnabled(): boolean;
  61831. /**
  61832. * Gets whether the color grading effect is enabled.
  61833. */
  61834. set cameraColorGradingEnabled(value: boolean);
  61835. /**
  61836. * Gets whether tonemapping is enabled or not.
  61837. */
  61838. get cameraToneMappingEnabled(): boolean;
  61839. /**
  61840. * Sets whether tonemapping is enabled or not
  61841. */
  61842. set cameraToneMappingEnabled(value: boolean);
  61843. /**
  61844. * The camera exposure used on this material.
  61845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61846. * This corresponds to a photographic exposure.
  61847. */
  61848. get cameraExposure(): float;
  61849. /**
  61850. * The camera exposure used on this material.
  61851. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61852. * This corresponds to a photographic exposure.
  61853. */
  61854. set cameraExposure(value: float);
  61855. /**
  61856. * Gets The camera contrast used on this material.
  61857. */
  61858. get cameraContrast(): float;
  61859. /**
  61860. * Sets The camera contrast used on this material.
  61861. */
  61862. set cameraContrast(value: float);
  61863. /**
  61864. * Gets the Color Grading 2D Lookup Texture.
  61865. */
  61866. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61867. /**
  61868. * Sets the Color Grading 2D Lookup Texture.
  61869. */
  61870. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61871. /**
  61872. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61874. * 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;
  61875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61876. */
  61877. get cameraColorCurves(): Nullable<ColorCurves>;
  61878. /**
  61879. * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
  61880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61881. * 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;
  61882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61883. */
  61884. set cameraColorCurves(value: Nullable<ColorCurves>);
  61885. /**
  61886. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61887. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61888. */
  61889. switchToBGR: boolean;
  61890. private _renderTargets;
  61891. private _reflectionControls;
  61892. private _white;
  61893. private _primaryShadowColor;
  61894. private _primaryHighlightColor;
  61895. /**
  61896. * Instantiates a Background Material in the given scene
  61897. * @param name The friendly name of the material
  61898. * @param scene The scene to add the material to
  61899. */
  61900. constructor(name: string, scene: Scene);
  61901. /**
  61902. * Gets a boolean indicating that current material needs to register RTT
  61903. */
  61904. get hasRenderTargetTextures(): boolean;
  61905. /**
  61906. * The entire material has been created in order to prevent overdraw.
  61907. * @returns false
  61908. */
  61909. needAlphaTesting(): boolean;
  61910. /**
  61911. * The entire material has been created in order to prevent overdraw.
  61912. * @returns true if blending is enable
  61913. */
  61914. needAlphaBlending(): boolean;
  61915. /**
  61916. * Checks whether the material is ready to be rendered for a given mesh.
  61917. * @param mesh The mesh to render
  61918. * @param subMesh The submesh to check against
  61919. * @param useInstances Specify wether or not the material is used with instances
  61920. * @returns true if all the dependencies are ready (Textures, Effects...)
  61921. */
  61922. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61923. /**
  61924. * Compute the primary color according to the chosen perceptual color.
  61925. */
  61926. private _computePrimaryColorFromPerceptualColor;
  61927. /**
  61928. * Compute the highlights and shadow colors according to their chosen levels.
  61929. */
  61930. private _computePrimaryColors;
  61931. /**
  61932. * Build the uniform buffer used in the material.
  61933. */
  61934. buildUniformLayout(): void;
  61935. /**
  61936. * Unbind the material.
  61937. */
  61938. unbind(): void;
  61939. /**
  61940. * Bind only the world matrix to the material.
  61941. * @param world The world matrix to bind.
  61942. */
  61943. bindOnlyWorldMatrix(world: Matrix): void;
  61944. /**
  61945. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61946. * @param world The world matrix to bind.
  61947. * @param subMesh The submesh to bind for.
  61948. */
  61949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61950. /**
  61951. * Checks to see if a texture is used in the material.
  61952. * @param texture - Base texture to use.
  61953. * @returns - Boolean specifying if a texture is used in the material.
  61954. */
  61955. hasTexture(texture: BaseTexture): boolean;
  61956. /**
  61957. * Dispose the material.
  61958. * @param forceDisposeEffect Force disposal of the associated effect.
  61959. * @param forceDisposeTextures Force disposal of the associated textures.
  61960. */
  61961. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61962. /**
  61963. * Clones the material.
  61964. * @param name The cloned name.
  61965. * @returns The cloned material.
  61966. */
  61967. clone(name: string): BackgroundMaterial;
  61968. /**
  61969. * Serializes the current material to its JSON representation.
  61970. * @returns The JSON representation.
  61971. */
  61972. serialize(): any;
  61973. /**
  61974. * Gets the class name of the material
  61975. * @returns "BackgroundMaterial"
  61976. */
  61977. getClassName(): string;
  61978. /**
  61979. * Parse a JSON input to create back a background material.
  61980. * @param source The JSON data to parse
  61981. * @param scene The scene to create the parsed material in
  61982. * @param rootUrl The root url of the assets the material depends upon
  61983. * @returns the instantiated BackgroundMaterial.
  61984. */
  61985. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61986. }
  61987. }
  61988. declare module BABYLON {
  61989. /**
  61990. * Represents the different options available during the creation of
  61991. * a Environment helper.
  61992. *
  61993. * This can control the default ground, skybox and image processing setup of your scene.
  61994. */
  61995. export interface IEnvironmentHelperOptions {
  61996. /**
  61997. * Specifies whether or not to create a ground.
  61998. * True by default.
  61999. */
  62000. createGround: boolean;
  62001. /**
  62002. * Specifies the ground size.
  62003. * 15 by default.
  62004. */
  62005. groundSize: number;
  62006. /**
  62007. * The texture used on the ground for the main color.
  62008. * Comes from the BabylonJS CDN by default.
  62009. *
  62010. * Remarks: Can be either a texture or a url.
  62011. */
  62012. groundTexture: string | BaseTexture;
  62013. /**
  62014. * The color mixed in the ground texture by default.
  62015. * BabylonJS clearColor by default.
  62016. */
  62017. groundColor: Color3;
  62018. /**
  62019. * Specifies the ground opacity.
  62020. * 1 by default.
  62021. */
  62022. groundOpacity: number;
  62023. /**
  62024. * Enables the ground to receive shadows.
  62025. * True by default.
  62026. */
  62027. enableGroundShadow: boolean;
  62028. /**
  62029. * Helps preventing the shadow to be fully black on the ground.
  62030. * 0.5 by default.
  62031. */
  62032. groundShadowLevel: number;
  62033. /**
  62034. * Creates a mirror texture attach to the ground.
  62035. * false by default.
  62036. */
  62037. enableGroundMirror: boolean;
  62038. /**
  62039. * Specifies the ground mirror size ratio.
  62040. * 0.3 by default as the default kernel is 64.
  62041. */
  62042. groundMirrorSizeRatio: number;
  62043. /**
  62044. * Specifies the ground mirror blur kernel size.
  62045. * 64 by default.
  62046. */
  62047. groundMirrorBlurKernel: number;
  62048. /**
  62049. * Specifies the ground mirror visibility amount.
  62050. * 1 by default
  62051. */
  62052. groundMirrorAmount: number;
  62053. /**
  62054. * Specifies the ground mirror reflectance weight.
  62055. * This uses the standard weight of the background material to setup the fresnel effect
  62056. * of the mirror.
  62057. * 1 by default.
  62058. */
  62059. groundMirrorFresnelWeight: number;
  62060. /**
  62061. * Specifies the ground mirror Falloff distance.
  62062. * This can helps reducing the size of the reflection.
  62063. * 0 by Default.
  62064. */
  62065. groundMirrorFallOffDistance: number;
  62066. /**
  62067. * Specifies the ground mirror texture type.
  62068. * Unsigned Int by Default.
  62069. */
  62070. groundMirrorTextureType: number;
  62071. /**
  62072. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  62073. * the shown objects.
  62074. */
  62075. groundYBias: number;
  62076. /**
  62077. * Specifies whether or not to create a skybox.
  62078. * True by default.
  62079. */
  62080. createSkybox: boolean;
  62081. /**
  62082. * Specifies the skybox size.
  62083. * 20 by default.
  62084. */
  62085. skyboxSize: number;
  62086. /**
  62087. * The texture used on the skybox for the main color.
  62088. * Comes from the BabylonJS CDN by default.
  62089. *
  62090. * Remarks: Can be either a texture or a url.
  62091. */
  62092. skyboxTexture: string | BaseTexture;
  62093. /**
  62094. * The color mixed in the skybox texture by default.
  62095. * BabylonJS clearColor by default.
  62096. */
  62097. skyboxColor: Color3;
  62098. /**
  62099. * The background rotation around the Y axis of the scene.
  62100. * This helps aligning the key lights of your scene with the background.
  62101. * 0 by default.
  62102. */
  62103. backgroundYRotation: number;
  62104. /**
  62105. * Compute automatically the size of the elements to best fit with the scene.
  62106. */
  62107. sizeAuto: boolean;
  62108. /**
  62109. * Default position of the rootMesh if autoSize is not true.
  62110. */
  62111. rootPosition: Vector3;
  62112. /**
  62113. * Sets up the image processing in the scene.
  62114. * true by default.
  62115. */
  62116. setupImageProcessing: boolean;
  62117. /**
  62118. * The texture used as your environment texture in the scene.
  62119. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  62120. *
  62121. * Remarks: Can be either a texture or a url.
  62122. */
  62123. environmentTexture: string | BaseTexture;
  62124. /**
  62125. * The value of the exposure to apply to the scene.
  62126. * 0.6 by default if setupImageProcessing is true.
  62127. */
  62128. cameraExposure: number;
  62129. /**
  62130. * The value of the contrast to apply to the scene.
  62131. * 1.6 by default if setupImageProcessing is true.
  62132. */
  62133. cameraContrast: number;
  62134. /**
  62135. * Specifies whether or not tonemapping should be enabled in the scene.
  62136. * true by default if setupImageProcessing is true.
  62137. */
  62138. toneMappingEnabled: boolean;
  62139. }
  62140. /**
  62141. * The Environment helper class can be used to add a fully featured none expensive background to your scene.
  62142. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  62143. * It also helps with the default setup of your imageProcessing configuration.
  62144. */
  62145. export class EnvironmentHelper {
  62146. /**
  62147. * Default ground texture URL.
  62148. */
  62149. private static _groundTextureCDNUrl;
  62150. /**
  62151. * Default skybox texture URL.
  62152. */
  62153. private static _skyboxTextureCDNUrl;
  62154. /**
  62155. * Default environment texture URL.
  62156. */
  62157. private static _environmentTextureCDNUrl;
  62158. /**
  62159. * Creates the default options for the helper.
  62160. */
  62161. private static _getDefaultOptions;
  62162. private _rootMesh;
  62163. /**
  62164. * Gets the root mesh created by the helper.
  62165. */
  62166. get rootMesh(): Mesh;
  62167. private _skybox;
  62168. /**
  62169. * Gets the skybox created by the helper.
  62170. */
  62171. get skybox(): Nullable<Mesh>;
  62172. private _skyboxTexture;
  62173. /**
  62174. * Gets the skybox texture created by the helper.
  62175. */
  62176. get skyboxTexture(): Nullable<BaseTexture>;
  62177. private _skyboxMaterial;
  62178. /**
  62179. * Gets the skybox material created by the helper.
  62180. */
  62181. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  62182. private _ground;
  62183. /**
  62184. * Gets the ground mesh created by the helper.
  62185. */
  62186. get ground(): Nullable<Mesh>;
  62187. private _groundTexture;
  62188. /**
  62189. * Gets the ground texture created by the helper.
  62190. */
  62191. get groundTexture(): Nullable<BaseTexture>;
  62192. private _groundMirror;
  62193. /**
  62194. * Gets the ground mirror created by the helper.
  62195. */
  62196. get groundMirror(): Nullable<MirrorTexture>;
  62197. /**
  62198. * Gets the ground mirror render list to helps pushing the meshes
  62199. * you wish in the ground reflection.
  62200. */
  62201. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  62202. private _groundMaterial;
  62203. /**
  62204. * Gets the ground material created by the helper.
  62205. */
  62206. get groundMaterial(): Nullable<BackgroundMaterial>;
  62207. /**
  62208. * Stores the creation options.
  62209. */
  62210. private readonly _scene;
  62211. private _options;
  62212. /**
  62213. * This observable will be notified with any error during the creation of the environment,
  62214. * mainly texture creation errors.
  62215. */
  62216. onErrorObservable: Observable<{
  62217. message?: string;
  62218. exception?: any;
  62219. }>;
  62220. /**
  62221. * constructor
  62222. * @param options Defines the options we want to customize the helper
  62223. * @param scene The scene to add the material to
  62224. */
  62225. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  62226. /**
  62227. * Updates the background according to the new options
  62228. * @param options
  62229. */
  62230. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  62231. /**
  62232. * Sets the primary color of all the available elements.
  62233. * @param color the main color to affect to the ground and the background
  62234. */
  62235. setMainColor(color: Color3): void;
  62236. /**
  62237. * Setup the image processing according to the specified options.
  62238. */
  62239. private _setupImageProcessing;
  62240. /**
  62241. * Setup the environment texture according to the specified options.
  62242. */
  62243. private _setupEnvironmentTexture;
  62244. /**
  62245. * Setup the background according to the specified options.
  62246. */
  62247. private _setupBackground;
  62248. /**
  62249. * Get the scene sizes according to the setup.
  62250. */
  62251. private _getSceneSize;
  62252. /**
  62253. * Setup the ground according to the specified options.
  62254. */
  62255. private _setupGround;
  62256. /**
  62257. * Setup the ground material according to the specified options.
  62258. */
  62259. private _setupGroundMaterial;
  62260. /**
  62261. * Setup the ground diffuse texture according to the specified options.
  62262. */
  62263. private _setupGroundDiffuseTexture;
  62264. /**
  62265. * Setup the ground mirror texture according to the specified options.
  62266. */
  62267. private _setupGroundMirrorTexture;
  62268. /**
  62269. * Setup the ground to receive the mirror texture.
  62270. */
  62271. private _setupMirrorInGroundMaterial;
  62272. /**
  62273. * Setup the skybox according to the specified options.
  62274. */
  62275. private _setupSkybox;
  62276. /**
  62277. * Setup the skybox material according to the specified options.
  62278. */
  62279. private _setupSkyboxMaterial;
  62280. /**
  62281. * Setup the skybox reflection texture according to the specified options.
  62282. */
  62283. private _setupSkyboxReflectionTexture;
  62284. private _errorHandler;
  62285. /**
  62286. * Dispose all the elements created by the Helper.
  62287. */
  62288. dispose(): void;
  62289. }
  62290. }
  62291. declare module BABYLON {
  62292. /**
  62293. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  62294. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  62295. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62296. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62297. */
  62298. export abstract class TextureDome<T extends Texture> extends TransformNode {
  62299. protected onError: Nullable<(message?: string, exception?: any) => void>;
  62300. /**
  62301. * Define the source as a Monoscopic panoramic 360/180.
  62302. */
  62303. static readonly MODE_MONOSCOPIC: number;
  62304. /**
  62305. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  62306. */
  62307. static readonly MODE_TOPBOTTOM: number;
  62308. /**
  62309. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  62310. */
  62311. static readonly MODE_SIDEBYSIDE: number;
  62312. private _halfDome;
  62313. private _crossEye;
  62314. protected _useDirectMapping: boolean;
  62315. /**
  62316. * The texture being displayed on the sphere
  62317. */
  62318. protected _texture: T;
  62319. /**
  62320. * Gets the texture being displayed on the sphere
  62321. */
  62322. get texture(): T;
  62323. /**
  62324. * Sets the texture being displayed on the sphere
  62325. */
  62326. set texture(newTexture: T);
  62327. /**
  62328. * The skybox material
  62329. */
  62330. protected _material: BackgroundMaterial;
  62331. /**
  62332. * The surface used for the dome
  62333. */
  62334. protected _mesh: Mesh;
  62335. /**
  62336. * Gets the mesh used for the dome.
  62337. */
  62338. get mesh(): Mesh;
  62339. /**
  62340. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  62341. */
  62342. private _halfDomeMask;
  62343. /**
  62344. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  62345. * Also see the options.resolution property.
  62346. */
  62347. get fovMultiplier(): number;
  62348. set fovMultiplier(value: number);
  62349. protected _textureMode: number;
  62350. /**
  62351. * Gets or set the current texture mode for the texture. It can be:
  62352. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62353. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62354. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62355. */
  62356. get textureMode(): number;
  62357. /**
  62358. * Sets the current texture mode for the texture. It can be:
  62359. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62360. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62361. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62362. */
  62363. set textureMode(value: number);
  62364. /**
  62365. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  62366. */
  62367. get halfDome(): boolean;
  62368. /**
  62369. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  62370. */
  62371. set halfDome(enabled: boolean);
  62372. /**
  62373. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  62374. */
  62375. set crossEye(enabled: boolean);
  62376. /**
  62377. * Is it a cross-eye texture?
  62378. */
  62379. get crossEye(): boolean;
  62380. /**
  62381. * The background material of this dome.
  62382. */
  62383. get material(): BackgroundMaterial;
  62384. /**
  62385. * Oberserver used in Stereoscopic VR Mode.
  62386. */
  62387. private _onBeforeCameraRenderObserver;
  62388. /**
  62389. * Observable raised when an error occurred while loading the texture
  62390. */
  62391. onLoadErrorObservable: Observable<string>;
  62392. /**
  62393. * Observable raised when the texture finished loading
  62394. */
  62395. onLoadObservable: Observable<void>;
  62396. /**
  62397. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  62398. * @param name Element's name, child elements will append suffixes for their own names.
  62399. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  62400. * @param options An object containing optional or exposed sub element properties
  62401. */
  62402. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  62403. resolution?: number;
  62404. clickToPlay?: boolean;
  62405. autoPlay?: boolean;
  62406. loop?: boolean;
  62407. size?: number;
  62408. poster?: string;
  62409. faceForward?: boolean;
  62410. useDirectMapping?: boolean;
  62411. halfDomeMode?: boolean;
  62412. crossEyeMode?: boolean;
  62413. generateMipMaps?: boolean;
  62414. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  62415. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  62416. protected _changeTextureMode(value: number): void;
  62417. /**
  62418. * Releases resources associated with this node.
  62419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  62420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  62421. */
  62422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  62423. }
  62424. }
  62425. declare module BABYLON {
  62426. /**
  62427. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  62428. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  62429. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  62430. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62431. */
  62432. export class PhotoDome extends TextureDome<Texture> {
  62433. /**
  62434. * Define the image as a Monoscopic panoramic 360 image.
  62435. */
  62436. static readonly MODE_MONOSCOPIC: number;
  62437. /**
  62438. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  62439. */
  62440. static readonly MODE_TOPBOTTOM: number;
  62441. /**
  62442. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  62443. */
  62444. static readonly MODE_SIDEBYSIDE: number;
  62445. /**
  62446. * Gets or sets the texture being displayed on the sphere
  62447. */
  62448. get photoTexture(): Texture;
  62449. /**
  62450. * sets the texture being displayed on the sphere
  62451. */
  62452. set photoTexture(value: Texture);
  62453. /**
  62454. * Gets the current video mode for the video. It can be:
  62455. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62456. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62457. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62458. */
  62459. get imageMode(): number;
  62460. /**
  62461. * Sets the current video mode for the video. It can be:
  62462. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  62463. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  62464. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  62465. */
  62466. set imageMode(value: number);
  62467. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  62468. }
  62469. }
  62470. declare module BABYLON {
  62471. /**
  62472. * Direct draw surface info
  62473. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  62474. */
  62475. export interface DDSInfo {
  62476. /**
  62477. * Width of the texture
  62478. */
  62479. width: number;
  62480. /**
  62481. * Width of the texture
  62482. */
  62483. height: number;
  62484. /**
  62485. * Number of Mipmaps for the texture
  62486. * @see https://en.wikipedia.org/wiki/Mipmap
  62487. */
  62488. mipmapCount: number;
  62489. /**
  62490. * If the textures format is a known fourCC format
  62491. * @see https://www.fourcc.org/
  62492. */
  62493. isFourCC: boolean;
  62494. /**
  62495. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  62496. */
  62497. isRGB: boolean;
  62498. /**
  62499. * If the texture is a lumincance format
  62500. */
  62501. isLuminance: boolean;
  62502. /**
  62503. * If this is a cube texture
  62504. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  62505. */
  62506. isCube: boolean;
  62507. /**
  62508. * If the texture is a compressed format eg. FOURCC_DXT1
  62509. */
  62510. isCompressed: boolean;
  62511. /**
  62512. * The dxgiFormat of the texture
  62513. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  62514. */
  62515. dxgiFormat: number;
  62516. /**
  62517. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  62518. */
  62519. textureType: number;
  62520. /**
  62521. * Sphericle polynomial created for the dds texture
  62522. */
  62523. sphericalPolynomial?: SphericalPolynomial;
  62524. }
  62525. /**
  62526. * Class used to provide DDS decompression tools
  62527. */
  62528. export class DDSTools {
  62529. /**
  62530. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  62531. */
  62532. static StoreLODInAlphaChannel: boolean;
  62533. /**
  62534. * Gets DDS information from an array buffer
  62535. * @param data defines the array buffer view to read data from
  62536. * @returns the DDS information
  62537. */
  62538. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  62539. private static _FloatView;
  62540. private static _Int32View;
  62541. private static _ToHalfFloat;
  62542. private static _FromHalfFloat;
  62543. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  62544. private static _GetHalfFloatRGBAArrayBuffer;
  62545. private static _GetFloatRGBAArrayBuffer;
  62546. private static _GetFloatAsUIntRGBAArrayBuffer;
  62547. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  62548. private static _GetRGBAArrayBuffer;
  62549. private static _ExtractLongWordOrder;
  62550. private static _GetRGBArrayBuffer;
  62551. private static _GetLuminanceArrayBuffer;
  62552. /**
  62553. * Uploads DDS Levels to a Babylon Texture
  62554. * @hidden
  62555. */
  62556. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  62557. }
  62558. interface ThinEngine {
  62559. /**
  62560. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  62561. * @param rootUrl defines the url where the file to load is located
  62562. * @param scene defines the current scene
  62563. * @param lodScale defines scale to apply to the mip map selection
  62564. * @param lodOffset defines offset to apply to the mip map selection
  62565. * @param onLoad defines an optional callback raised when the texture is loaded
  62566. * @param onError defines an optional callback raised if there is an issue to load the texture
  62567. * @param format defines the format of the data
  62568. * @param forcedExtension defines the extension to use to pick the right loader
  62569. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  62570. * @returns the cube texture as an InternalTexture
  62571. */
  62572. 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;
  62573. }
  62574. }
  62575. declare module BABYLON {
  62576. /**
  62577. * Implementation of the DDS Texture Loader.
  62578. * @hidden
  62579. */
  62580. export class _DDSTextureLoader implements IInternalTextureLoader {
  62581. /**
  62582. * Defines whether the loader supports cascade loading the different faces.
  62583. */
  62584. readonly supportCascades: boolean;
  62585. /**
  62586. * This returns if the loader support the current file information.
  62587. * @param extension defines the file extension of the file being loaded
  62588. * @returns true if the loader can load the specified file
  62589. */
  62590. canLoad(extension: string): boolean;
  62591. /**
  62592. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62593. * @param data contains the texture data
  62594. * @param texture defines the BabylonJS internal texture
  62595. * @param createPolynomials will be true if polynomials have been requested
  62596. * @param onLoad defines the callback to trigger once the texture is ready
  62597. * @param onError defines the callback to trigger in case of error
  62598. */
  62599. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62600. /**
  62601. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62602. * @param data contains the texture data
  62603. * @param texture defines the BabylonJS internal texture
  62604. * @param callback defines the method to call once ready to upload
  62605. */
  62606. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62607. }
  62608. }
  62609. declare module BABYLON {
  62610. /**
  62611. * Implementation of the ENV Texture Loader.
  62612. * @hidden
  62613. */
  62614. export class _ENVTextureLoader implements IInternalTextureLoader {
  62615. /**
  62616. * Defines whether the loader supports cascade loading the different faces.
  62617. */
  62618. readonly supportCascades: boolean;
  62619. /**
  62620. * This returns if the loader support the current file information.
  62621. * @param extension defines the file extension of the file being loaded
  62622. * @returns true if the loader can load the specified file
  62623. */
  62624. canLoad(extension: string): boolean;
  62625. /**
  62626. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62627. * @param data contains the texture data
  62628. * @param texture defines the BabylonJS internal texture
  62629. * @param createPolynomials will be true if polynomials have been requested
  62630. * @param onLoad defines the callback to trigger once the texture is ready
  62631. * @param onError defines the callback to trigger in case of error
  62632. */
  62633. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62634. /**
  62635. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62636. * @param data contains the texture data
  62637. * @param texture defines the BabylonJS internal texture
  62638. * @param callback defines the method to call once ready to upload
  62639. */
  62640. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62641. }
  62642. }
  62643. declare module BABYLON {
  62644. /**
  62645. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  62646. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  62647. */
  62648. export class KhronosTextureContainer {
  62649. /** contents of the KTX container file */
  62650. data: ArrayBufferView;
  62651. private static HEADER_LEN;
  62652. private static COMPRESSED_2D;
  62653. private static COMPRESSED_3D;
  62654. private static TEX_2D;
  62655. private static TEX_3D;
  62656. /**
  62657. * Gets the openGL type
  62658. */
  62659. glType: number;
  62660. /**
  62661. * Gets the openGL type size
  62662. */
  62663. glTypeSize: number;
  62664. /**
  62665. * Gets the openGL format
  62666. */
  62667. glFormat: number;
  62668. /**
  62669. * Gets the openGL internal format
  62670. */
  62671. glInternalFormat: number;
  62672. /**
  62673. * Gets the base internal format
  62674. */
  62675. glBaseInternalFormat: number;
  62676. /**
  62677. * Gets image width in pixel
  62678. */
  62679. pixelWidth: number;
  62680. /**
  62681. * Gets image height in pixel
  62682. */
  62683. pixelHeight: number;
  62684. /**
  62685. * Gets image depth in pixels
  62686. */
  62687. pixelDepth: number;
  62688. /**
  62689. * Gets the number of array elements
  62690. */
  62691. numberOfArrayElements: number;
  62692. /**
  62693. * Gets the number of faces
  62694. */
  62695. numberOfFaces: number;
  62696. /**
  62697. * Gets the number of mipmap levels
  62698. */
  62699. numberOfMipmapLevels: number;
  62700. /**
  62701. * Gets the bytes of key value data
  62702. */
  62703. bytesOfKeyValueData: number;
  62704. /**
  62705. * Gets the load type
  62706. */
  62707. loadType: number;
  62708. /**
  62709. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62710. */
  62711. isInvalid: boolean;
  62712. /**
  62713. * Creates a new KhronosTextureContainer
  62714. * @param data contents of the KTX container file
  62715. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62716. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62717. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62718. */
  62719. constructor(
  62720. /** contents of the KTX container file */
  62721. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62722. /**
  62723. * Uploads KTX content to a Babylon Texture.
  62724. * It is assumed that the texture has already been created & is currently bound
  62725. * @hidden
  62726. */
  62727. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62728. private _upload2DCompressedLevels;
  62729. /**
  62730. * Checks if the given data starts with a KTX file identifier.
  62731. * @param data the data to check
  62732. * @returns true if the data is a KTX file or false otherwise
  62733. */
  62734. static IsValid(data: ArrayBufferView): boolean;
  62735. }
  62736. }
  62737. declare module BABYLON {
  62738. /**
  62739. * Helper class to push actions to a pool of workers.
  62740. */
  62741. export class WorkerPool implements IDisposable {
  62742. private _workerInfos;
  62743. private _pendingActions;
  62744. /**
  62745. * Constructor
  62746. * @param workers Array of workers to use for actions
  62747. */
  62748. constructor(workers: Array<Worker>);
  62749. /**
  62750. * Terminates all workers and clears any pending actions.
  62751. */
  62752. dispose(): void;
  62753. /**
  62754. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62755. * pended until a worker has completed its action.
  62756. * @param action The action to perform. Call onComplete when the action is complete.
  62757. */
  62758. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62759. private _execute;
  62760. }
  62761. }
  62762. declare module BABYLON {
  62763. /**
  62764. * Class for loading KTX2 files
  62765. */
  62766. export class KhronosTextureContainer2 {
  62767. private static _WorkerPoolPromise?;
  62768. private static _Initialized;
  62769. private static _Ktx2Decoder;
  62770. /**
  62771. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62772. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62773. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62774. * Urls you can change:
  62775. * URLConfig.jsDecoderModule
  62776. * URLConfig.wasmUASTCToASTC
  62777. * URLConfig.wasmUASTCToBC7
  62778. * URLConfig.wasmUASTCToRGBA_UNORM
  62779. * URLConfig.wasmUASTCToRGBA_SRGB
  62780. * URLConfig.jsMSCTranscoder
  62781. * URLConfig.wasmMSCTranscoder
  62782. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62783. */
  62784. static URLConfig: {
  62785. jsDecoderModule: string;
  62786. wasmUASTCToASTC: null;
  62787. wasmUASTCToBC7: null;
  62788. wasmUASTCToRGBA_UNORM: null;
  62789. wasmUASTCToRGBA_SRGB: null;
  62790. jsMSCTranscoder: null;
  62791. wasmMSCTranscoder: null;
  62792. };
  62793. /**
  62794. * Default number of workers used to handle data decoding
  62795. */
  62796. static DefaultNumWorkers: number;
  62797. private static GetDefaultNumWorkers;
  62798. private _engine;
  62799. private static _CreateWorkerPool;
  62800. /**
  62801. * Constructor
  62802. * @param engine The engine to use
  62803. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62804. */
  62805. constructor(engine: ThinEngine, numWorkers?: number);
  62806. /** @hidden */
  62807. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62808. /**
  62809. * Stop all async operations and release resources.
  62810. */
  62811. dispose(): void;
  62812. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62813. /**
  62814. * Checks if the given data starts with a KTX2 file identifier.
  62815. * @param data the data to check
  62816. * @returns true if the data is a KTX2 file or false otherwise
  62817. */
  62818. static IsValid(data: ArrayBufferView): boolean;
  62819. }
  62820. }
  62821. declare module BABYLON {
  62822. /**
  62823. * Implementation of the KTX Texture Loader.
  62824. * @hidden
  62825. */
  62826. export class _KTXTextureLoader implements IInternalTextureLoader {
  62827. /**
  62828. * Defines whether the loader supports cascade loading the different faces.
  62829. */
  62830. readonly supportCascades: boolean;
  62831. /**
  62832. * This returns if the loader support the current file information.
  62833. * @param extension defines the file extension of the file being loaded
  62834. * @param mimeType defines the optional mime type of the file being loaded
  62835. * @returns true if the loader can load the specified file
  62836. */
  62837. canLoad(extension: string, mimeType?: string): boolean;
  62838. /**
  62839. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62840. * @param data contains the texture data
  62841. * @param texture defines the BabylonJS internal texture
  62842. * @param createPolynomials will be true if polynomials have been requested
  62843. * @param onLoad defines the callback to trigger once the texture is ready
  62844. * @param onError defines the callback to trigger in case of error
  62845. */
  62846. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62847. /**
  62848. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62849. * @param data contains the texture data
  62850. * @param texture defines the BabylonJS internal texture
  62851. * @param callback defines the method to call once ready to upload
  62852. */
  62853. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /** @hidden */
  62858. export var _forceSceneHelpersToBundle: boolean;
  62859. interface Scene {
  62860. /**
  62861. * Creates a default light for the scene.
  62862. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62863. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62864. */
  62865. createDefaultLight(replace?: boolean): void;
  62866. /**
  62867. * Creates a default camera for the scene.
  62868. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62869. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62870. * @param replace has default false, when true replaces the active camera in the scene
  62871. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62872. */
  62873. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62874. /**
  62875. * Creates a default camera and a default light.
  62876. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62877. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62878. * @param replace has the default false, when true replaces the active camera/light in the scene
  62879. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62880. */
  62881. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62882. /**
  62883. * Creates a new sky box
  62884. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62885. * @param environmentTexture defines the texture to use as environment texture
  62886. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62887. * @param scale defines the overall scale of the skybox
  62888. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62889. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62890. * @returns a new mesh holding the sky box
  62891. */
  62892. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62893. /**
  62894. * Creates a new environment
  62895. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62896. * @param options defines the options you can use to configure the environment
  62897. * @returns the new EnvironmentHelper
  62898. */
  62899. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62900. /**
  62901. * Creates a new VREXperienceHelper
  62902. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62903. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62904. * @returns a new VREXperienceHelper
  62905. */
  62906. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62907. /**
  62908. * Creates a new WebXRDefaultExperience
  62909. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62910. * @param options experience options
  62911. * @returns a promise for a new WebXRDefaultExperience
  62912. */
  62913. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62914. }
  62915. }
  62916. declare module BABYLON {
  62917. /**
  62918. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62919. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62920. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62921. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62922. */
  62923. export class VideoDome extends TextureDome<VideoTexture> {
  62924. /**
  62925. * Define the video source as a Monoscopic panoramic 360 video.
  62926. */
  62927. static readonly MODE_MONOSCOPIC: number;
  62928. /**
  62929. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62930. */
  62931. static readonly MODE_TOPBOTTOM: number;
  62932. /**
  62933. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62934. */
  62935. static readonly MODE_SIDEBYSIDE: number;
  62936. /**
  62937. * Get the video texture associated with this video dome
  62938. */
  62939. get videoTexture(): VideoTexture;
  62940. /**
  62941. * Get the video mode of this dome
  62942. */
  62943. get videoMode(): number;
  62944. /**
  62945. * Set the video mode of this dome.
  62946. * @see textureMode
  62947. */
  62948. set videoMode(value: number);
  62949. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62950. }
  62951. }
  62952. declare module BABYLON {
  62953. /**
  62954. * This class can be used to get instrumentation data from a Babylon engine
  62955. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62956. */
  62957. export class EngineInstrumentation implements IDisposable {
  62958. /**
  62959. * Define the instrumented engine.
  62960. */
  62961. engine: Engine;
  62962. private _captureGPUFrameTime;
  62963. private _gpuFrameTimeToken;
  62964. private _gpuFrameTime;
  62965. private _captureShaderCompilationTime;
  62966. private _shaderCompilationTime;
  62967. private _onBeginFrameObserver;
  62968. private _onEndFrameObserver;
  62969. private _onBeforeShaderCompilationObserver;
  62970. private _onAfterShaderCompilationObserver;
  62971. /**
  62972. * Gets the perf counter used for GPU frame time
  62973. */
  62974. get gpuFrameTimeCounter(): PerfCounter;
  62975. /**
  62976. * Gets the GPU frame time capture status
  62977. */
  62978. get captureGPUFrameTime(): boolean;
  62979. /**
  62980. * Enable or disable the GPU frame time capture
  62981. */
  62982. set captureGPUFrameTime(value: boolean);
  62983. /**
  62984. * Gets the perf counter used for shader compilation time
  62985. */
  62986. get shaderCompilationTimeCounter(): PerfCounter;
  62987. /**
  62988. * Gets the shader compilation time capture status
  62989. */
  62990. get captureShaderCompilationTime(): boolean;
  62991. /**
  62992. * Enable or disable the shader compilation time capture
  62993. */
  62994. set captureShaderCompilationTime(value: boolean);
  62995. /**
  62996. * Instantiates a new engine instrumentation.
  62997. * This class can be used to get instrumentation data from a Babylon engine
  62998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62999. * @param engine Defines the engine to instrument
  63000. */
  63001. constructor(
  63002. /**
  63003. * Define the instrumented engine.
  63004. */
  63005. engine: Engine);
  63006. /**
  63007. * Dispose and release associated resources.
  63008. */
  63009. dispose(): void;
  63010. }
  63011. }
  63012. declare module BABYLON {
  63013. /**
  63014. * This class can be used to get instrumentation data from a Babylon engine
  63015. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63016. */
  63017. export class SceneInstrumentation implements IDisposable {
  63018. /**
  63019. * Defines the scene to instrument
  63020. */
  63021. scene: Scene;
  63022. private _captureActiveMeshesEvaluationTime;
  63023. private _activeMeshesEvaluationTime;
  63024. private _captureRenderTargetsRenderTime;
  63025. private _renderTargetsRenderTime;
  63026. private _captureFrameTime;
  63027. private _frameTime;
  63028. private _captureRenderTime;
  63029. private _renderTime;
  63030. private _captureInterFrameTime;
  63031. private _interFrameTime;
  63032. private _captureParticlesRenderTime;
  63033. private _particlesRenderTime;
  63034. private _captureSpritesRenderTime;
  63035. private _spritesRenderTime;
  63036. private _capturePhysicsTime;
  63037. private _physicsTime;
  63038. private _captureAnimationsTime;
  63039. private _animationsTime;
  63040. private _captureCameraRenderTime;
  63041. private _cameraRenderTime;
  63042. private _onBeforeActiveMeshesEvaluationObserver;
  63043. private _onAfterActiveMeshesEvaluationObserver;
  63044. private _onBeforeRenderTargetsRenderObserver;
  63045. private _onAfterRenderTargetsRenderObserver;
  63046. private _onAfterRenderObserver;
  63047. private _onBeforeDrawPhaseObserver;
  63048. private _onAfterDrawPhaseObserver;
  63049. private _onBeforeAnimationsObserver;
  63050. private _onBeforeParticlesRenderingObserver;
  63051. private _onAfterParticlesRenderingObserver;
  63052. private _onBeforeSpritesRenderingObserver;
  63053. private _onAfterSpritesRenderingObserver;
  63054. private _onBeforePhysicsObserver;
  63055. private _onAfterPhysicsObserver;
  63056. private _onAfterAnimationsObserver;
  63057. private _onBeforeCameraRenderObserver;
  63058. private _onAfterCameraRenderObserver;
  63059. /**
  63060. * Gets the perf counter used for active meshes evaluation time
  63061. */
  63062. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  63063. /**
  63064. * Gets the active meshes evaluation time capture status
  63065. */
  63066. get captureActiveMeshesEvaluationTime(): boolean;
  63067. /**
  63068. * Enable or disable the active meshes evaluation time capture
  63069. */
  63070. set captureActiveMeshesEvaluationTime(value: boolean);
  63071. /**
  63072. * Gets the perf counter used for render targets render time
  63073. */
  63074. get renderTargetsRenderTimeCounter(): PerfCounter;
  63075. /**
  63076. * Gets the render targets render time capture status
  63077. */
  63078. get captureRenderTargetsRenderTime(): boolean;
  63079. /**
  63080. * Enable or disable the render targets render time capture
  63081. */
  63082. set captureRenderTargetsRenderTime(value: boolean);
  63083. /**
  63084. * Gets the perf counter used for particles render time
  63085. */
  63086. get particlesRenderTimeCounter(): PerfCounter;
  63087. /**
  63088. * Gets the particles render time capture status
  63089. */
  63090. get captureParticlesRenderTime(): boolean;
  63091. /**
  63092. * Enable or disable the particles render time capture
  63093. */
  63094. set captureParticlesRenderTime(value: boolean);
  63095. /**
  63096. * Gets the perf counter used for sprites render time
  63097. */
  63098. get spritesRenderTimeCounter(): PerfCounter;
  63099. /**
  63100. * Gets the sprites render time capture status
  63101. */
  63102. get captureSpritesRenderTime(): boolean;
  63103. /**
  63104. * Enable or disable the sprites render time capture
  63105. */
  63106. set captureSpritesRenderTime(value: boolean);
  63107. /**
  63108. * Gets the perf counter used for physics time
  63109. */
  63110. get physicsTimeCounter(): PerfCounter;
  63111. /**
  63112. * Gets the physics time capture status
  63113. */
  63114. get capturePhysicsTime(): boolean;
  63115. /**
  63116. * Enable or disable the physics time capture
  63117. */
  63118. set capturePhysicsTime(value: boolean);
  63119. /**
  63120. * Gets the perf counter used for animations time
  63121. */
  63122. get animationsTimeCounter(): PerfCounter;
  63123. /**
  63124. * Gets the animations time capture status
  63125. */
  63126. get captureAnimationsTime(): boolean;
  63127. /**
  63128. * Enable or disable the animations time capture
  63129. */
  63130. set captureAnimationsTime(value: boolean);
  63131. /**
  63132. * Gets the perf counter used for frame time capture
  63133. */
  63134. get frameTimeCounter(): PerfCounter;
  63135. /**
  63136. * Gets the frame time capture status
  63137. */
  63138. get captureFrameTime(): boolean;
  63139. /**
  63140. * Enable or disable the frame time capture
  63141. */
  63142. set captureFrameTime(value: boolean);
  63143. /**
  63144. * Gets the perf counter used for inter-frames time capture
  63145. */
  63146. get interFrameTimeCounter(): PerfCounter;
  63147. /**
  63148. * Gets the inter-frames time capture status
  63149. */
  63150. get captureInterFrameTime(): boolean;
  63151. /**
  63152. * Enable or disable the inter-frames time capture
  63153. */
  63154. set captureInterFrameTime(value: boolean);
  63155. /**
  63156. * Gets the perf counter used for render time capture
  63157. */
  63158. get renderTimeCounter(): PerfCounter;
  63159. /**
  63160. * Gets the render time capture status
  63161. */
  63162. get captureRenderTime(): boolean;
  63163. /**
  63164. * Enable or disable the render time capture
  63165. */
  63166. set captureRenderTime(value: boolean);
  63167. /**
  63168. * Gets the perf counter used for camera render time capture
  63169. */
  63170. get cameraRenderTimeCounter(): PerfCounter;
  63171. /**
  63172. * Gets the camera render time capture status
  63173. */
  63174. get captureCameraRenderTime(): boolean;
  63175. /**
  63176. * Enable or disable the camera render time capture
  63177. */
  63178. set captureCameraRenderTime(value: boolean);
  63179. /**
  63180. * Gets the perf counter used for draw calls
  63181. */
  63182. get drawCallsCounter(): PerfCounter;
  63183. /**
  63184. * Instantiates a new scene instrumentation.
  63185. * This class can be used to get instrumentation data from a Babylon engine
  63186. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  63187. * @param scene Defines the scene to instrument
  63188. */
  63189. constructor(
  63190. /**
  63191. * Defines the scene to instrument
  63192. */
  63193. scene: Scene);
  63194. /**
  63195. * Dispose and release associated resources.
  63196. */
  63197. dispose(): void;
  63198. }
  63199. }
  63200. declare module BABYLON {
  63201. /** @hidden */
  63202. export var glowMapGenerationPixelShader: {
  63203. name: string;
  63204. shader: string;
  63205. };
  63206. }
  63207. declare module BABYLON {
  63208. /** @hidden */
  63209. export var glowMapGenerationVertexShader: {
  63210. name: string;
  63211. shader: string;
  63212. };
  63213. }
  63214. declare module BABYLON {
  63215. /**
  63216. * Effect layer options. This helps customizing the behaviour
  63217. * of the effect layer.
  63218. */
  63219. export interface IEffectLayerOptions {
  63220. /**
  63221. * Multiplication factor apply to the canvas size to compute the render target size
  63222. * used to generated the objects (the smaller the faster).
  63223. */
  63224. mainTextureRatio: number;
  63225. /**
  63226. * Enforces a fixed size texture to ensure effect stability across devices.
  63227. */
  63228. mainTextureFixedSize?: number;
  63229. /**
  63230. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  63231. */
  63232. alphaBlendingMode: number;
  63233. /**
  63234. * The camera attached to the layer.
  63235. */
  63236. camera: Nullable<Camera>;
  63237. /**
  63238. * The rendering group to draw the layer in.
  63239. */
  63240. renderingGroupId: number;
  63241. }
  63242. /**
  63243. * The effect layer Helps adding post process effect blended with the main pass.
  63244. *
  63245. * This can be for instance use to generate glow or highlight effects on the scene.
  63246. *
  63247. * The effect layer class can not be used directly and is intented to inherited from to be
  63248. * customized per effects.
  63249. */
  63250. export abstract class EffectLayer {
  63251. private _vertexBuffers;
  63252. private _indexBuffer;
  63253. private _cachedDefines;
  63254. private _effectLayerMapGenerationEffect;
  63255. private _effectLayerOptions;
  63256. private _mergeEffect;
  63257. protected _scene: Scene;
  63258. protected _engine: Engine;
  63259. protected _maxSize: number;
  63260. protected _mainTextureDesiredSize: ISize;
  63261. protected _mainTexture: RenderTargetTexture;
  63262. protected _shouldRender: boolean;
  63263. protected _postProcesses: PostProcess[];
  63264. protected _textures: BaseTexture[];
  63265. protected _emissiveTextureAndColor: {
  63266. texture: Nullable<BaseTexture>;
  63267. color: Color4;
  63268. };
  63269. /**
  63270. * The name of the layer
  63271. */
  63272. name: string;
  63273. /**
  63274. * The clear color of the texture used to generate the glow map.
  63275. */
  63276. neutralColor: Color4;
  63277. /**
  63278. * Specifies whether the highlight layer is enabled or not.
  63279. */
  63280. isEnabled: boolean;
  63281. /**
  63282. * Gets the camera attached to the layer.
  63283. */
  63284. get camera(): Nullable<Camera>;
  63285. /**
  63286. * Gets the rendering group id the layer should render in.
  63287. */
  63288. get renderingGroupId(): number;
  63289. set renderingGroupId(renderingGroupId: number);
  63290. /**
  63291. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  63292. */
  63293. disableBoundingBoxesFromEffectLayer: boolean;
  63294. /**
  63295. * An event triggered when the effect layer has been disposed.
  63296. */
  63297. onDisposeObservable: Observable<EffectLayer>;
  63298. /**
  63299. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  63300. */
  63301. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  63302. /**
  63303. * An event triggered when the generated texture is being merged in the scene.
  63304. */
  63305. onBeforeComposeObservable: Observable<EffectLayer>;
  63306. /**
  63307. * An event triggered when the mesh is rendered into the effect render target.
  63308. */
  63309. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  63310. /**
  63311. * An event triggered after the mesh has been rendered into the effect render target.
  63312. */
  63313. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  63314. /**
  63315. * An event triggered when the generated texture has been merged in the scene.
  63316. */
  63317. onAfterComposeObservable: Observable<EffectLayer>;
  63318. /**
  63319. * An event triggered when the effect layer changes its size.
  63320. */
  63321. onSizeChangedObservable: Observable<EffectLayer>;
  63322. /** @hidden */
  63323. static _SceneComponentInitialization: (scene: Scene) => void;
  63324. /**
  63325. * Instantiates a new effect Layer and references it in the scene.
  63326. * @param name The name of the layer
  63327. * @param scene The scene to use the layer in
  63328. */
  63329. constructor(
  63330. /** The Friendly of the effect in the scene */
  63331. name: string, scene: Scene);
  63332. /**
  63333. * Get the effect name of the layer.
  63334. * @return The effect name
  63335. */
  63336. abstract getEffectName(): string;
  63337. /**
  63338. * Checks for the readiness of the element composing the layer.
  63339. * @param subMesh the mesh to check for
  63340. * @param useInstances specify whether or not to use instances to render the mesh
  63341. * @return true if ready otherwise, false
  63342. */
  63343. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63344. /**
  63345. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63346. * @returns true if the effect requires stencil during the main canvas render pass.
  63347. */
  63348. abstract needStencil(): boolean;
  63349. /**
  63350. * Create the merge effect. This is the shader use to blit the information back
  63351. * to the main canvas at the end of the scene rendering.
  63352. * @returns The effect containing the shader used to merge the effect on the main canvas
  63353. */
  63354. protected abstract _createMergeEffect(): Effect;
  63355. /**
  63356. * Creates the render target textures and post processes used in the effect layer.
  63357. */
  63358. protected abstract _createTextureAndPostProcesses(): void;
  63359. /**
  63360. * Implementation specific of rendering the generating effect on the main canvas.
  63361. * @param effect The effect used to render through
  63362. */
  63363. protected abstract _internalRender(effect: Effect): void;
  63364. /**
  63365. * Sets the required values for both the emissive texture and and the main color.
  63366. */
  63367. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63368. /**
  63369. * Free any resources and references associated to a mesh.
  63370. * Internal use
  63371. * @param mesh The mesh to free.
  63372. */
  63373. abstract _disposeMesh(mesh: Mesh): void;
  63374. /**
  63375. * Serializes this layer (Glow or Highlight for example)
  63376. * @returns a serialized layer object
  63377. */
  63378. abstract serialize?(): any;
  63379. /**
  63380. * Initializes the effect layer with the required options.
  63381. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  63382. */
  63383. protected _init(options: Partial<IEffectLayerOptions>): void;
  63384. /**
  63385. * Generates the index buffer of the full screen quad blending to the main canvas.
  63386. */
  63387. private _generateIndexBuffer;
  63388. /**
  63389. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  63390. */
  63391. private _generateVertexBuffer;
  63392. /**
  63393. * Sets the main texture desired size which is the closest power of two
  63394. * of the engine canvas size.
  63395. */
  63396. private _setMainTextureSize;
  63397. /**
  63398. * Creates the main texture for the effect layer.
  63399. */
  63400. protected _createMainTexture(): void;
  63401. /**
  63402. * Adds specific effects defines.
  63403. * @param defines The defines to add specifics to.
  63404. */
  63405. protected _addCustomEffectDefines(defines: string[]): void;
  63406. /**
  63407. * Checks for the readiness of the element composing the layer.
  63408. * @param subMesh the mesh to check for
  63409. * @param useInstances specify whether or not to use instances to render the mesh
  63410. * @param emissiveTexture the associated emissive texture used to generate the glow
  63411. * @return true if ready otherwise, false
  63412. */
  63413. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  63414. /**
  63415. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  63416. */
  63417. render(): void;
  63418. /**
  63419. * Determine if a given mesh will be used in the current effect.
  63420. * @param mesh mesh to test
  63421. * @returns true if the mesh will be used
  63422. */
  63423. hasMesh(mesh: AbstractMesh): boolean;
  63424. /**
  63425. * Returns true if the layer contains information to display, otherwise false.
  63426. * @returns true if the glow layer should be rendered
  63427. */
  63428. shouldRender(): boolean;
  63429. /**
  63430. * Returns true if the mesh should render, otherwise false.
  63431. * @param mesh The mesh to render
  63432. * @returns true if it should render otherwise false
  63433. */
  63434. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  63435. /**
  63436. * Returns true if the mesh can be rendered, otherwise false.
  63437. * @param mesh The mesh to render
  63438. * @param material The material used on the mesh
  63439. * @returns true if it can be rendered otherwise false
  63440. */
  63441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63442. /**
  63443. * Returns true if the mesh should render, otherwise false.
  63444. * @param mesh The mesh to render
  63445. * @returns true if it should render otherwise false
  63446. */
  63447. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  63448. /**
  63449. * Renders the submesh passed in parameter to the generation map.
  63450. */
  63451. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  63452. /**
  63453. * Defines whether the current material of the mesh should be use to render the effect.
  63454. * @param mesh defines the current mesh to render
  63455. */
  63456. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63457. /**
  63458. * Rebuild the required buffers.
  63459. * @hidden Internal use only.
  63460. */
  63461. _rebuild(): void;
  63462. /**
  63463. * Dispose only the render target textures and post process.
  63464. */
  63465. private _disposeTextureAndPostProcesses;
  63466. /**
  63467. * Dispose the highlight layer and free resources.
  63468. */
  63469. dispose(): void;
  63470. /**
  63471. * Gets the class name of the effect layer
  63472. * @returns the string with the class name of the effect layer
  63473. */
  63474. getClassName(): string;
  63475. /**
  63476. * Creates an effect layer from parsed effect layer data
  63477. * @param parsedEffectLayer defines effect layer data
  63478. * @param scene defines the current scene
  63479. * @param rootUrl defines the root URL containing the effect layer information
  63480. * @returns a parsed effect Layer
  63481. */
  63482. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  63483. }
  63484. }
  63485. declare module BABYLON {
  63486. interface AbstractScene {
  63487. /**
  63488. * The list of effect layers (highlights/glow) added to the scene
  63489. * @see https://doc.babylonjs.com/how_to/highlight_layer
  63490. * @see https://doc.babylonjs.com/how_to/glow_layer
  63491. */
  63492. effectLayers: Array<EffectLayer>;
  63493. /**
  63494. * Removes the given effect layer from this scene.
  63495. * @param toRemove defines the effect layer to remove
  63496. * @returns the index of the removed effect layer
  63497. */
  63498. removeEffectLayer(toRemove: EffectLayer): number;
  63499. /**
  63500. * Adds the given effect layer to this scene
  63501. * @param newEffectLayer defines the effect layer to add
  63502. */
  63503. addEffectLayer(newEffectLayer: EffectLayer): void;
  63504. }
  63505. /**
  63506. * Defines the layer scene component responsible to manage any effect layers
  63507. * in a given scene.
  63508. */
  63509. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  63510. /**
  63511. * The component name helpful to identify the component in the list of scene components.
  63512. */
  63513. readonly name: string;
  63514. /**
  63515. * The scene the component belongs to.
  63516. */
  63517. scene: Scene;
  63518. private _engine;
  63519. private _renderEffects;
  63520. private _needStencil;
  63521. private _previousStencilState;
  63522. /**
  63523. * Creates a new instance of the component for the given scene
  63524. * @param scene Defines the scene to register the component in
  63525. */
  63526. constructor(scene: Scene);
  63527. /**
  63528. * Registers the component in a given scene
  63529. */
  63530. register(): void;
  63531. /**
  63532. * Rebuilds the elements related to this component in case of
  63533. * context lost for instance.
  63534. */
  63535. rebuild(): void;
  63536. /**
  63537. * Serializes the component data to the specified json object
  63538. * @param serializationObject The object to serialize to
  63539. */
  63540. serialize(serializationObject: any): void;
  63541. /**
  63542. * Adds all the elements from the container to the scene
  63543. * @param container the container holding the elements
  63544. */
  63545. addFromContainer(container: AbstractScene): void;
  63546. /**
  63547. * Removes all the elements in the container from the scene
  63548. * @param container contains the elements to remove
  63549. * @param dispose if the removed element should be disposed (default: false)
  63550. */
  63551. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63552. /**
  63553. * Disposes the component and the associated resources.
  63554. */
  63555. dispose(): void;
  63556. private _isReadyForMesh;
  63557. private _renderMainTexture;
  63558. private _setStencil;
  63559. private _setStencilBack;
  63560. private _draw;
  63561. private _drawCamera;
  63562. private _drawRenderingGroup;
  63563. }
  63564. }
  63565. declare module BABYLON {
  63566. /** @hidden */
  63567. export var glowMapMergePixelShader: {
  63568. name: string;
  63569. shader: string;
  63570. };
  63571. }
  63572. declare module BABYLON {
  63573. /** @hidden */
  63574. export var glowMapMergeVertexShader: {
  63575. name: string;
  63576. shader: string;
  63577. };
  63578. }
  63579. declare module BABYLON {
  63580. interface AbstractScene {
  63581. /**
  63582. * Return a the first highlight layer of the scene with a given name.
  63583. * @param name The name of the highlight layer to look for.
  63584. * @return The highlight layer if found otherwise null.
  63585. */
  63586. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  63587. }
  63588. /**
  63589. * Glow layer options. This helps customizing the behaviour
  63590. * of the glow layer.
  63591. */
  63592. export interface IGlowLayerOptions {
  63593. /**
  63594. * Multiplication factor apply to the canvas size to compute the render target size
  63595. * used to generated the glowing objects (the smaller the faster).
  63596. */
  63597. mainTextureRatio: number;
  63598. /**
  63599. * Enforces a fixed size texture to ensure resize independent blur.
  63600. */
  63601. mainTextureFixedSize?: number;
  63602. /**
  63603. * How big is the kernel of the blur texture.
  63604. */
  63605. blurKernelSize: number;
  63606. /**
  63607. * The camera attached to the layer.
  63608. */
  63609. camera: Nullable<Camera>;
  63610. /**
  63611. * Enable MSAA by choosing the number of samples.
  63612. */
  63613. mainTextureSamples?: number;
  63614. /**
  63615. * The rendering group to draw the layer in.
  63616. */
  63617. renderingGroupId: number;
  63618. }
  63619. /**
  63620. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  63621. *
  63622. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  63623. *
  63624. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  63625. */
  63626. export class GlowLayer extends EffectLayer {
  63627. /**
  63628. * Effect Name of the layer.
  63629. */
  63630. static readonly EffectName: string;
  63631. /**
  63632. * The default blur kernel size used for the glow.
  63633. */
  63634. static DefaultBlurKernelSize: number;
  63635. /**
  63636. * The default texture size ratio used for the glow.
  63637. */
  63638. static DefaultTextureRatio: number;
  63639. /**
  63640. * Sets the kernel size of the blur.
  63641. */
  63642. set blurKernelSize(value: number);
  63643. /**
  63644. * Gets the kernel size of the blur.
  63645. */
  63646. get blurKernelSize(): number;
  63647. /**
  63648. * Sets the glow intensity.
  63649. */
  63650. set intensity(value: number);
  63651. /**
  63652. * Gets the glow intensity.
  63653. */
  63654. get intensity(): number;
  63655. private _options;
  63656. private _intensity;
  63657. private _horizontalBlurPostprocess1;
  63658. private _verticalBlurPostprocess1;
  63659. private _horizontalBlurPostprocess2;
  63660. private _verticalBlurPostprocess2;
  63661. private _blurTexture1;
  63662. private _blurTexture2;
  63663. private _postProcesses1;
  63664. private _postProcesses2;
  63665. private _includedOnlyMeshes;
  63666. private _excludedMeshes;
  63667. private _meshesUsingTheirOwnMaterials;
  63668. /**
  63669. * Callback used to let the user override the color selection on a per mesh basis
  63670. */
  63671. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63672. /**
  63673. * Callback used to let the user override the texture selection on a per mesh basis
  63674. */
  63675. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63676. /**
  63677. * Instantiates a new glow Layer and references it to the scene.
  63678. * @param name The name of the layer
  63679. * @param scene The scene to use the layer in
  63680. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63681. */
  63682. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63683. /**
  63684. * Get the effect name of the layer.
  63685. * @return The effect name
  63686. */
  63687. getEffectName(): string;
  63688. /**
  63689. * Create the merge effect. This is the shader use to blit the information back
  63690. * to the main canvas at the end of the scene rendering.
  63691. */
  63692. protected _createMergeEffect(): Effect;
  63693. /**
  63694. * Creates the render target textures and post processes used in the glow layer.
  63695. */
  63696. protected _createTextureAndPostProcesses(): void;
  63697. /**
  63698. * Checks for the readiness of the element composing the layer.
  63699. * @param subMesh the mesh to check for
  63700. * @param useInstances specify whether or not to use instances to render the mesh
  63701. * @param emissiveTexture the associated emissive texture used to generate the glow
  63702. * @return true if ready otherwise, false
  63703. */
  63704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63705. /**
  63706. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63707. */
  63708. needStencil(): boolean;
  63709. /**
  63710. * Returns true if the mesh can be rendered, otherwise false.
  63711. * @param mesh The mesh to render
  63712. * @param material The material used on the mesh
  63713. * @returns true if it can be rendered otherwise false
  63714. */
  63715. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63716. /**
  63717. * Implementation specific of rendering the generating effect on the main canvas.
  63718. * @param effect The effect used to render through
  63719. */
  63720. protected _internalRender(effect: Effect): void;
  63721. /**
  63722. * Sets the required values for both the emissive texture and and the main color.
  63723. */
  63724. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63725. /**
  63726. * Returns true if the mesh should render, otherwise false.
  63727. * @param mesh The mesh to render
  63728. * @returns true if it should render otherwise false
  63729. */
  63730. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63731. /**
  63732. * Adds specific effects defines.
  63733. * @param defines The defines to add specifics to.
  63734. */
  63735. protected _addCustomEffectDefines(defines: string[]): void;
  63736. /**
  63737. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63738. * @param mesh The mesh to exclude from the glow layer
  63739. */
  63740. addExcludedMesh(mesh: Mesh): void;
  63741. /**
  63742. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63743. * @param mesh The mesh to remove
  63744. */
  63745. removeExcludedMesh(mesh: Mesh): void;
  63746. /**
  63747. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63748. * @param mesh The mesh to include in the glow layer
  63749. */
  63750. addIncludedOnlyMesh(mesh: Mesh): void;
  63751. /**
  63752. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63753. * @param mesh The mesh to remove
  63754. */
  63755. removeIncludedOnlyMesh(mesh: Mesh): void;
  63756. /**
  63757. * Determine if a given mesh will be used in the glow layer
  63758. * @param mesh The mesh to test
  63759. * @returns true if the mesh will be highlighted by the current glow layer
  63760. */
  63761. hasMesh(mesh: AbstractMesh): boolean;
  63762. /**
  63763. * Defines whether the current material of the mesh should be use to render the effect.
  63764. * @param mesh defines the current mesh to render
  63765. */
  63766. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63767. /**
  63768. * Add a mesh to be rendered through its own material and not with emissive only.
  63769. * @param mesh The mesh for which we need to use its material
  63770. */
  63771. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63772. /**
  63773. * Remove a mesh from being rendered through its own material and not with emissive only.
  63774. * @param mesh The mesh for which we need to not use its material
  63775. */
  63776. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63777. /**
  63778. * Free any resources and references associated to a mesh.
  63779. * Internal use
  63780. * @param mesh The mesh to free.
  63781. * @hidden
  63782. */
  63783. _disposeMesh(mesh: Mesh): void;
  63784. /**
  63785. * Gets the class name of the effect layer
  63786. * @returns the string with the class name of the effect layer
  63787. */
  63788. getClassName(): string;
  63789. /**
  63790. * Serializes this glow layer
  63791. * @returns a serialized glow layer object
  63792. */
  63793. serialize(): any;
  63794. /**
  63795. * Creates a Glow Layer from parsed glow layer data
  63796. * @param parsedGlowLayer defines glow layer data
  63797. * @param scene defines the current scene
  63798. * @param rootUrl defines the root URL containing the glow layer information
  63799. * @returns a parsed Glow Layer
  63800. */
  63801. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63802. }
  63803. }
  63804. declare module BABYLON {
  63805. /** @hidden */
  63806. export var glowBlurPostProcessPixelShader: {
  63807. name: string;
  63808. shader: string;
  63809. };
  63810. }
  63811. declare module BABYLON {
  63812. interface AbstractScene {
  63813. /**
  63814. * Return a the first highlight layer of the scene with a given name.
  63815. * @param name The name of the highlight layer to look for.
  63816. * @return The highlight layer if found otherwise null.
  63817. */
  63818. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63819. }
  63820. /**
  63821. * Highlight layer options. This helps customizing the behaviour
  63822. * of the highlight layer.
  63823. */
  63824. export interface IHighlightLayerOptions {
  63825. /**
  63826. * Multiplication factor apply to the canvas size to compute the render target size
  63827. * used to generated the glowing objects (the smaller the faster).
  63828. */
  63829. mainTextureRatio: number;
  63830. /**
  63831. * Enforces a fixed size texture to ensure resize independent blur.
  63832. */
  63833. mainTextureFixedSize?: number;
  63834. /**
  63835. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63836. * of the picture to blur (the smaller the faster).
  63837. */
  63838. blurTextureSizeRatio: number;
  63839. /**
  63840. * How big in texel of the blur texture is the vertical blur.
  63841. */
  63842. blurVerticalSize: number;
  63843. /**
  63844. * How big in texel of the blur texture is the horizontal blur.
  63845. */
  63846. blurHorizontalSize: number;
  63847. /**
  63848. * Alpha blending mode used to apply the blur. Default is combine.
  63849. */
  63850. alphaBlendingMode: number;
  63851. /**
  63852. * The camera attached to the layer.
  63853. */
  63854. camera: Nullable<Camera>;
  63855. /**
  63856. * Should we display highlight as a solid stroke?
  63857. */
  63858. isStroke?: boolean;
  63859. /**
  63860. * The rendering group to draw the layer in.
  63861. */
  63862. renderingGroupId: number;
  63863. }
  63864. /**
  63865. * The highlight layer Helps adding a glow effect around a mesh.
  63866. *
  63867. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63868. * glowy meshes to your scene.
  63869. *
  63870. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63871. */
  63872. export class HighlightLayer extends EffectLayer {
  63873. name: string;
  63874. /**
  63875. * Effect Name of the highlight layer.
  63876. */
  63877. static readonly EffectName: string;
  63878. /**
  63879. * The neutral color used during the preparation of the glow effect.
  63880. * This is black by default as the blend operation is a blend operation.
  63881. */
  63882. static NeutralColor: Color4;
  63883. /**
  63884. * Stencil value used for glowing meshes.
  63885. */
  63886. static GlowingMeshStencilReference: number;
  63887. /**
  63888. * Stencil value used for the other meshes in the scene.
  63889. */
  63890. static NormalMeshStencilReference: number;
  63891. /**
  63892. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63893. */
  63894. innerGlow: boolean;
  63895. /**
  63896. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63897. */
  63898. outerGlow: boolean;
  63899. /**
  63900. * Specifies the horizontal size of the blur.
  63901. */
  63902. set blurHorizontalSize(value: number);
  63903. /**
  63904. * Specifies the vertical size of the blur.
  63905. */
  63906. set blurVerticalSize(value: number);
  63907. /**
  63908. * Gets the horizontal size of the blur.
  63909. */
  63910. get blurHorizontalSize(): number;
  63911. /**
  63912. * Gets the vertical size of the blur.
  63913. */
  63914. get blurVerticalSize(): number;
  63915. /**
  63916. * An event triggered when the highlight layer is being blurred.
  63917. */
  63918. onBeforeBlurObservable: Observable<HighlightLayer>;
  63919. /**
  63920. * An event triggered when the highlight layer has been blurred.
  63921. */
  63922. onAfterBlurObservable: Observable<HighlightLayer>;
  63923. private _instanceGlowingMeshStencilReference;
  63924. private _options;
  63925. private _downSamplePostprocess;
  63926. private _horizontalBlurPostprocess;
  63927. private _verticalBlurPostprocess;
  63928. private _blurTexture;
  63929. private _meshes;
  63930. private _excludedMeshes;
  63931. /**
  63932. * Instantiates a new highlight Layer and references it to the scene..
  63933. * @param name The name of the layer
  63934. * @param scene The scene to use the layer in
  63935. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63936. */
  63937. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63938. /**
  63939. * Get the effect name of the layer.
  63940. * @return The effect name
  63941. */
  63942. getEffectName(): string;
  63943. /**
  63944. * Create the merge effect. This is the shader use to blit the information back
  63945. * to the main canvas at the end of the scene rendering.
  63946. */
  63947. protected _createMergeEffect(): Effect;
  63948. /**
  63949. * Creates the render target textures and post processes used in the highlight layer.
  63950. */
  63951. protected _createTextureAndPostProcesses(): void;
  63952. /**
  63953. * Returns whether or not the layer needs stencil enabled during the mesh rendering.
  63954. */
  63955. needStencil(): boolean;
  63956. /**
  63957. * Checks for the readiness of the element composing the layer.
  63958. * @param subMesh the mesh to check for
  63959. * @param useInstances specify wether or not to use instances to render the mesh
  63960. * @param emissiveTexture the associated emissive texture used to generate the glow
  63961. * @return true if ready otherwise, false
  63962. */
  63963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63964. /**
  63965. * Implementation specific of rendering the generating effect on the main canvas.
  63966. * @param effect The effect used to render through
  63967. */
  63968. protected _internalRender(effect: Effect): void;
  63969. /**
  63970. * Returns true if the layer contains information to display, otherwise false.
  63971. */
  63972. shouldRender(): boolean;
  63973. /**
  63974. * Returns true if the mesh should render, otherwise false.
  63975. * @param mesh The mesh to render
  63976. * @returns true if it should render otherwise false
  63977. */
  63978. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63979. /**
  63980. * Returns true if the mesh can be rendered, otherwise false.
  63981. * @param mesh The mesh to render
  63982. * @param material The material used on the mesh
  63983. * @returns true if it can be rendered otherwise false
  63984. */
  63985. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63986. /**
  63987. * Adds specific effects defines.
  63988. * @param defines The defines to add specifics to.
  63989. */
  63990. protected _addCustomEffectDefines(defines: string[]): void;
  63991. /**
  63992. * Sets the required values for both the emissive texture and and the main color.
  63993. */
  63994. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63995. /**
  63996. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63997. * @param mesh The mesh to exclude from the highlight layer
  63998. */
  63999. addExcludedMesh(mesh: Mesh): void;
  64000. /**
  64001. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  64002. * @param mesh The mesh to highlight
  64003. */
  64004. removeExcludedMesh(mesh: Mesh): void;
  64005. /**
  64006. * Determine if a given mesh will be highlighted by the current HighlightLayer
  64007. * @param mesh mesh to test
  64008. * @returns true if the mesh will be highlighted by the current HighlightLayer
  64009. */
  64010. hasMesh(mesh: AbstractMesh): boolean;
  64011. /**
  64012. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  64013. * @param mesh The mesh to highlight
  64014. * @param color The color of the highlight
  64015. * @param glowEmissiveOnly Extract the glow from the emissive texture
  64016. */
  64017. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  64018. /**
  64019. * Remove a mesh from the highlight layer in order to make it stop glowing.
  64020. * @param mesh The mesh to highlight
  64021. */
  64022. removeMesh(mesh: Mesh): void;
  64023. /**
  64024. * Remove all the meshes currently referenced in the highlight layer
  64025. */
  64026. removeAllMeshes(): void;
  64027. /**
  64028. * Force the stencil to the normal expected value for none glowing parts
  64029. */
  64030. private _defaultStencilReference;
  64031. /**
  64032. * Free any resources and references associated to a mesh.
  64033. * Internal use
  64034. * @param mesh The mesh to free.
  64035. * @hidden
  64036. */
  64037. _disposeMesh(mesh: Mesh): void;
  64038. /**
  64039. * Dispose the highlight layer and free resources.
  64040. */
  64041. dispose(): void;
  64042. /**
  64043. * Gets the class name of the effect layer
  64044. * @returns the string with the class name of the effect layer
  64045. */
  64046. getClassName(): string;
  64047. /**
  64048. * Serializes this Highlight layer
  64049. * @returns a serialized Highlight layer object
  64050. */
  64051. serialize(): any;
  64052. /**
  64053. * Creates a Highlight layer from parsed Highlight layer data
  64054. * @param parsedHightlightLayer defines the Highlight layer data
  64055. * @param scene defines the current scene
  64056. * @param rootUrl defines the root URL containing the Highlight layer information
  64057. * @returns a parsed Highlight layer
  64058. */
  64059. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  64060. }
  64061. }
  64062. declare module BABYLON {
  64063. interface AbstractScene {
  64064. /**
  64065. * The list of layers (background and foreground) of the scene
  64066. */
  64067. layers: Array<Layer>;
  64068. }
  64069. /**
  64070. * Defines the layer scene component responsible to manage any layers
  64071. * in a given scene.
  64072. */
  64073. export class LayerSceneComponent implements ISceneComponent {
  64074. /**
  64075. * The component name helpful to identify the component in the list of scene components.
  64076. */
  64077. readonly name: string;
  64078. /**
  64079. * The scene the component belongs to.
  64080. */
  64081. scene: Scene;
  64082. private _engine;
  64083. /**
  64084. * Creates a new instance of the component for the given scene
  64085. * @param scene Defines the scene to register the component in
  64086. */
  64087. constructor(scene: Scene);
  64088. /**
  64089. * Registers the component in a given scene
  64090. */
  64091. register(): void;
  64092. /**
  64093. * Rebuilds the elements related to this component in case of
  64094. * context lost for instance.
  64095. */
  64096. rebuild(): void;
  64097. /**
  64098. * Disposes the component and the associated resources.
  64099. */
  64100. dispose(): void;
  64101. private _draw;
  64102. private _drawCameraPredicate;
  64103. private _drawCameraBackground;
  64104. private _drawCameraForeground;
  64105. private _drawRenderTargetPredicate;
  64106. private _drawRenderTargetBackground;
  64107. private _drawRenderTargetForeground;
  64108. /**
  64109. * Adds all the elements from the container to the scene
  64110. * @param container the container holding the elements
  64111. */
  64112. addFromContainer(container: AbstractScene): void;
  64113. /**
  64114. * Removes all the elements in the container from the scene
  64115. * @param container contains the elements to remove
  64116. * @param dispose if the removed element should be disposed (default: false)
  64117. */
  64118. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64119. }
  64120. }
  64121. declare module BABYLON {
  64122. /** @hidden */
  64123. export var layerPixelShader: {
  64124. name: string;
  64125. shader: string;
  64126. };
  64127. }
  64128. declare module BABYLON {
  64129. /** @hidden */
  64130. export var layerVertexShader: {
  64131. name: string;
  64132. shader: string;
  64133. };
  64134. }
  64135. declare module BABYLON {
  64136. /**
  64137. * This represents a full screen 2d layer.
  64138. * This can be useful to display a picture in the background of your scene for instance.
  64139. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64140. */
  64141. export class Layer {
  64142. /**
  64143. * Define the name of the layer.
  64144. */
  64145. name: string;
  64146. /**
  64147. * Define the texture the layer should display.
  64148. */
  64149. texture: Nullable<Texture>;
  64150. /**
  64151. * Is the layer in background or foreground.
  64152. */
  64153. isBackground: boolean;
  64154. /**
  64155. * Define the color of the layer (instead of texture).
  64156. */
  64157. color: Color4;
  64158. /**
  64159. * Define the scale of the layer in order to zoom in out of the texture.
  64160. */
  64161. scale: Vector2;
  64162. /**
  64163. * Define an offset for the layer in order to shift the texture.
  64164. */
  64165. offset: Vector2;
  64166. /**
  64167. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  64168. */
  64169. alphaBlendingMode: number;
  64170. /**
  64171. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  64172. * Alpha test will not mix with the background color in case of transparency.
  64173. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  64174. */
  64175. alphaTest: boolean;
  64176. /**
  64177. * Define a mask to restrict the layer to only some of the scene cameras.
  64178. */
  64179. layerMask: number;
  64180. /**
  64181. * Define the list of render target the layer is visible into.
  64182. */
  64183. renderTargetTextures: RenderTargetTexture[];
  64184. /**
  64185. * Define if the layer is only used in renderTarget or if it also
  64186. * renders in the main frame buffer of the canvas.
  64187. */
  64188. renderOnlyInRenderTargetTextures: boolean;
  64189. private _scene;
  64190. private _vertexBuffers;
  64191. private _indexBuffer;
  64192. private _effect;
  64193. private _previousDefines;
  64194. /**
  64195. * An event triggered when the layer is disposed.
  64196. */
  64197. onDisposeObservable: Observable<Layer>;
  64198. private _onDisposeObserver;
  64199. /**
  64200. * Back compatibility with callback before the onDisposeObservable existed.
  64201. * The set callback will be triggered when the layer has been disposed.
  64202. */
  64203. set onDispose(callback: () => void);
  64204. /**
  64205. * An event triggered before rendering the scene
  64206. */
  64207. onBeforeRenderObservable: Observable<Layer>;
  64208. private _onBeforeRenderObserver;
  64209. /**
  64210. * Back compatibility with callback before the onBeforeRenderObservable existed.
  64211. * The set callback will be triggered just before rendering the layer.
  64212. */
  64213. set onBeforeRender(callback: () => void);
  64214. /**
  64215. * An event triggered after rendering the scene
  64216. */
  64217. onAfterRenderObservable: Observable<Layer>;
  64218. private _onAfterRenderObserver;
  64219. /**
  64220. * Back compatibility with callback before the onAfterRenderObservable existed.
  64221. * The set callback will be triggered just after rendering the layer.
  64222. */
  64223. set onAfterRender(callback: () => void);
  64224. /**
  64225. * Instantiates a new layer.
  64226. * This represents a full screen 2d layer.
  64227. * This can be useful to display a picture in the background of your scene for instance.
  64228. * @see https://www.babylonjs-playground.com/#08A2BS#1
  64229. * @param name Define the name of the layer in the scene
  64230. * @param imgUrl Define the url of the texture to display in the layer
  64231. * @param scene Define the scene the layer belongs to
  64232. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  64233. * @param color Defines a color for the layer
  64234. */
  64235. constructor(
  64236. /**
  64237. * Define the name of the layer.
  64238. */
  64239. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  64240. private _createIndexBuffer;
  64241. /** @hidden */
  64242. _rebuild(): void;
  64243. /**
  64244. * Renders the layer in the scene.
  64245. */
  64246. render(): void;
  64247. /**
  64248. * Disposes and releases the associated resources.
  64249. */
  64250. dispose(): void;
  64251. }
  64252. }
  64253. declare module BABYLON {
  64254. /** @hidden */
  64255. export var lensFlarePixelShader: {
  64256. name: string;
  64257. shader: string;
  64258. };
  64259. }
  64260. declare module BABYLON {
  64261. /** @hidden */
  64262. export var lensFlareVertexShader: {
  64263. name: string;
  64264. shader: string;
  64265. };
  64266. }
  64267. declare module BABYLON {
  64268. /**
  64269. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64270. * It is usually composed of several `lensFlare`.
  64271. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64272. */
  64273. export class LensFlareSystem {
  64274. /**
  64275. * Define the name of the lens flare system
  64276. */
  64277. name: string;
  64278. /**
  64279. * List of lens flares used in this system.
  64280. */
  64281. lensFlares: LensFlare[];
  64282. /**
  64283. * Define a limit from the border the lens flare can be visible.
  64284. */
  64285. borderLimit: number;
  64286. /**
  64287. * Define a viewport border we do not want to see the lens flare in.
  64288. */
  64289. viewportBorder: number;
  64290. /**
  64291. * Define a predicate which could limit the list of meshes able to occlude the effect.
  64292. */
  64293. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  64294. /**
  64295. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  64296. */
  64297. layerMask: number;
  64298. /**
  64299. * Define the id of the lens flare system in the scene.
  64300. * (equal to name by default)
  64301. */
  64302. id: string;
  64303. private _scene;
  64304. private _emitter;
  64305. private _vertexBuffers;
  64306. private _indexBuffer;
  64307. private _effect;
  64308. private _positionX;
  64309. private _positionY;
  64310. private _isEnabled;
  64311. /** @hidden */
  64312. static _SceneComponentInitialization: (scene: Scene) => void;
  64313. /**
  64314. * Instantiates a lens flare system.
  64315. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  64316. * It is usually composed of several `lensFlare`.
  64317. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64318. * @param name Define the name of the lens flare system in the scene
  64319. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  64320. * @param scene Define the scene the lens flare system belongs to
  64321. */
  64322. constructor(
  64323. /**
  64324. * Define the name of the lens flare system
  64325. */
  64326. name: string, emitter: any, scene: Scene);
  64327. /**
  64328. * Define if the lens flare system is enabled.
  64329. */
  64330. get isEnabled(): boolean;
  64331. set isEnabled(value: boolean);
  64332. /**
  64333. * Get the scene the effects belongs to.
  64334. * @returns the scene holding the lens flare system
  64335. */
  64336. getScene(): Scene;
  64337. /**
  64338. * Get the emitter of the lens flare system.
  64339. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64340. * @returns the emitter of the lens flare system
  64341. */
  64342. getEmitter(): any;
  64343. /**
  64344. * Set the emitter of the lens flare system.
  64345. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  64346. * @param newEmitter Define the new emitter of the system
  64347. */
  64348. setEmitter(newEmitter: any): void;
  64349. /**
  64350. * Get the lens flare system emitter position.
  64351. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  64352. * @returns the position
  64353. */
  64354. getEmitterPosition(): Vector3;
  64355. /**
  64356. * @hidden
  64357. */
  64358. computeEffectivePosition(globalViewport: Viewport): boolean;
  64359. /** @hidden */
  64360. _isVisible(): boolean;
  64361. /**
  64362. * @hidden
  64363. */
  64364. render(): boolean;
  64365. /**
  64366. * Dispose and release the lens flare with its associated resources.
  64367. */
  64368. dispose(): void;
  64369. /**
  64370. * Parse a lens flare system from a JSON representation
  64371. * @param parsedLensFlareSystem Define the JSON to parse
  64372. * @param scene Define the scene the parsed system should be instantiated in
  64373. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  64374. * @returns the parsed system
  64375. */
  64376. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  64377. /**
  64378. * Serialize the current Lens Flare System into a JSON representation.
  64379. * @returns the serialized JSON
  64380. */
  64381. serialize(): any;
  64382. }
  64383. }
  64384. declare module BABYLON {
  64385. /**
  64386. * This represents one of the lens effect in a `lensFlareSystem`.
  64387. * It controls one of the individual texture used in the effect.
  64388. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64389. */
  64390. export class LensFlare {
  64391. /**
  64392. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64393. */
  64394. size: number;
  64395. /**
  64396. * 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.
  64397. */
  64398. position: number;
  64399. /**
  64400. * Define the lens color.
  64401. */
  64402. color: Color3;
  64403. /**
  64404. * Define the lens texture.
  64405. */
  64406. texture: Nullable<Texture>;
  64407. /**
  64408. * Define the alpha mode to render this particular lens.
  64409. */
  64410. alphaMode: number;
  64411. private _system;
  64412. /**
  64413. * Creates a new Lens Flare.
  64414. * This represents one of the lens effect in a `lensFlareSystem`.
  64415. * It controls one of the individual texture used in the effect.
  64416. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64417. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  64418. * @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.
  64419. * @param color Define the lens color
  64420. * @param imgUrl Define the lens texture url
  64421. * @param system Define the `lensFlareSystem` this flare is part of
  64422. * @returns The newly created Lens Flare
  64423. */
  64424. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  64425. /**
  64426. * Instantiates a new Lens Flare.
  64427. * This represents one of the lens effect in a `lensFlareSystem`.
  64428. * It controls one of the individual texture used in the effect.
  64429. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64430. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  64431. * @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.
  64432. * @param color Define the lens color
  64433. * @param imgUrl Define the lens texture url
  64434. * @param system Define the `lensFlareSystem` this flare is part of
  64435. */
  64436. constructor(
  64437. /**
  64438. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  64439. */
  64440. size: number,
  64441. /**
  64442. * 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.
  64443. */
  64444. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  64445. /**
  64446. * Dispose and release the lens flare with its associated resources.
  64447. */
  64448. dispose(): void;
  64449. }
  64450. }
  64451. declare module BABYLON {
  64452. interface AbstractScene {
  64453. /**
  64454. * The list of lens flare system added to the scene
  64455. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  64456. */
  64457. lensFlareSystems: Array<LensFlareSystem>;
  64458. /**
  64459. * Removes the given lens flare system from this scene.
  64460. * @param toRemove The lens flare system to remove
  64461. * @returns The index of the removed lens flare system
  64462. */
  64463. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  64464. /**
  64465. * Adds the given lens flare system to this scene
  64466. * @param newLensFlareSystem The lens flare system to add
  64467. */
  64468. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  64469. /**
  64470. * Gets a lens flare system using its name
  64471. * @param name defines the name to look for
  64472. * @returns the lens flare system or null if not found
  64473. */
  64474. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  64475. /**
  64476. * Gets a lens flare system using its id
  64477. * @param id defines the id to look for
  64478. * @returns the lens flare system or null if not found
  64479. */
  64480. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  64481. }
  64482. /**
  64483. * Defines the lens flare scene component responsible to manage any lens flares
  64484. * in a given scene.
  64485. */
  64486. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  64487. /**
  64488. * The component name helpful to identify the component in the list of scene components.
  64489. */
  64490. readonly name: string;
  64491. /**
  64492. * The scene the component belongs to.
  64493. */
  64494. scene: Scene;
  64495. /**
  64496. * Creates a new instance of the component for the given scene
  64497. * @param scene Defines the scene to register the component in
  64498. */
  64499. constructor(scene: Scene);
  64500. /**
  64501. * Registers the component in a given scene
  64502. */
  64503. register(): void;
  64504. /**
  64505. * Rebuilds the elements related to this component in case of
  64506. * context lost for instance.
  64507. */
  64508. rebuild(): void;
  64509. /**
  64510. * Adds all the elements from the container to the scene
  64511. * @param container the container holding the elements
  64512. */
  64513. addFromContainer(container: AbstractScene): void;
  64514. /**
  64515. * Removes all the elements in the container from the scene
  64516. * @param container contains the elements to remove
  64517. * @param dispose if the removed element should be disposed (default: false)
  64518. */
  64519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64520. /**
  64521. * Serializes the component data to the specified json object
  64522. * @param serializationObject The object to serialize to
  64523. */
  64524. serialize(serializationObject: any): void;
  64525. /**
  64526. * Disposes the component and the associated resources.
  64527. */
  64528. dispose(): void;
  64529. private _draw;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /** @hidden */
  64534. export var depthPixelShader: {
  64535. name: string;
  64536. shader: string;
  64537. };
  64538. }
  64539. declare module BABYLON {
  64540. /** @hidden */
  64541. export var depthVertexShader: {
  64542. name: string;
  64543. shader: string;
  64544. };
  64545. }
  64546. declare module BABYLON {
  64547. /**
  64548. * This represents a depth renderer in Babylon.
  64549. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64550. */
  64551. export class DepthRenderer {
  64552. private _scene;
  64553. private _depthMap;
  64554. private _effect;
  64555. private readonly _storeNonLinearDepth;
  64556. private readonly _clearColor;
  64557. /** Get if the depth renderer is using packed depth or not */
  64558. readonly isPacked: boolean;
  64559. private _cachedDefines;
  64560. private _camera;
  64561. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  64562. enabled: boolean;
  64563. /**
  64564. * Specifies that the depth renderer will only be used within
  64565. * the camera it is created for.
  64566. * This can help forcing its rendering during the camera processing.
  64567. */
  64568. useOnlyInActiveCamera: boolean;
  64569. /** @hidden */
  64570. static _SceneComponentInitialization: (scene: Scene) => void;
  64571. /**
  64572. * Instantiates a depth renderer
  64573. * @param scene The scene the renderer belongs to
  64574. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64575. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64576. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64577. */
  64578. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64579. /**
  64580. * Creates the depth rendering effect and checks if the effect is ready.
  64581. * @param subMesh The submesh to be used to render the depth map of
  64582. * @param useInstances If multiple world instances should be used
  64583. * @returns if the depth renderer is ready to render the depth map
  64584. */
  64585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64586. /**
  64587. * Gets the texture which the depth map will be written to.
  64588. * @returns The depth map texture
  64589. */
  64590. getDepthMap(): RenderTargetTexture;
  64591. /**
  64592. * Disposes of the depth renderer.
  64593. */
  64594. dispose(): void;
  64595. }
  64596. }
  64597. declare module BABYLON {
  64598. /** @hidden */
  64599. export var minmaxReduxPixelShader: {
  64600. name: string;
  64601. shader: string;
  64602. };
  64603. }
  64604. declare module BABYLON {
  64605. /**
  64606. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64607. * and maximum values from all values of the texture.
  64608. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64609. * The source values are read from the red channel of the texture.
  64610. */
  64611. export class MinMaxReducer {
  64612. /**
  64613. * Observable triggered when the computation has been performed
  64614. */
  64615. onAfterReductionPerformed: Observable<{
  64616. min: number;
  64617. max: number;
  64618. }>;
  64619. protected _camera: Camera;
  64620. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64621. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64622. protected _postProcessManager: PostProcessManager;
  64623. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64624. protected _forceFullscreenViewport: boolean;
  64625. /**
  64626. * Creates a min/max reducer
  64627. * @param camera The camera to use for the post processes
  64628. */
  64629. constructor(camera: Camera);
  64630. /**
  64631. * Gets the texture used to read the values from.
  64632. */
  64633. get sourceTexture(): Nullable<RenderTargetTexture>;
  64634. /**
  64635. * Sets the source texture to read the values from.
  64636. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64637. * because in such textures '1' value must not be taken into account to compute the maximum
  64638. * as this value is used to clear the texture.
  64639. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64640. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64641. * @param depthRedux Indicates if the texture is a depth texture or not
  64642. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64643. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64644. */
  64645. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64646. /**
  64647. * Defines the refresh rate of the computation.
  64648. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64649. */
  64650. get refreshRate(): number;
  64651. set refreshRate(value: number);
  64652. protected _activated: boolean;
  64653. /**
  64654. * Gets the activation status of the reducer
  64655. */
  64656. get activated(): boolean;
  64657. /**
  64658. * Activates the reduction computation.
  64659. * When activated, the observers registered in onAfterReductionPerformed are
  64660. * called after the computation is performed
  64661. */
  64662. activate(): void;
  64663. /**
  64664. * Deactivates the reduction computation.
  64665. */
  64666. deactivate(): void;
  64667. /**
  64668. * Disposes the min/max reducer
  64669. * @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.
  64670. */
  64671. dispose(disposeAll?: boolean): void;
  64672. }
  64673. }
  64674. declare module BABYLON {
  64675. /**
  64676. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64677. */
  64678. export class DepthReducer extends MinMaxReducer {
  64679. private _depthRenderer;
  64680. private _depthRendererId;
  64681. /**
  64682. * Gets the depth renderer used for the computation.
  64683. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64684. */
  64685. get depthRenderer(): Nullable<DepthRenderer>;
  64686. /**
  64687. * Creates a depth reducer
  64688. * @param camera The camera used to render the depth texture
  64689. */
  64690. constructor(camera: Camera);
  64691. /**
  64692. * Sets the depth renderer to use to generate the depth map
  64693. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64694. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64695. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64696. */
  64697. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64698. /** @hidden */
  64699. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64700. /**
  64701. * Activates the reduction computation.
  64702. * When activated, the observers registered in onAfterReductionPerformed are
  64703. * called after the computation is performed
  64704. */
  64705. activate(): void;
  64706. /**
  64707. * Deactivates the reduction computation.
  64708. */
  64709. deactivate(): void;
  64710. /**
  64711. * Disposes the depth reducer
  64712. * @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.
  64713. */
  64714. dispose(disposeAll?: boolean): void;
  64715. }
  64716. }
  64717. declare module BABYLON {
  64718. /**
  64719. * A CSM implementation allowing casting shadows on large scenes.
  64720. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64721. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64722. */
  64723. export class CascadedShadowGenerator extends ShadowGenerator {
  64724. private static readonly frustumCornersNDCSpace;
  64725. /**
  64726. * Name of the CSM class
  64727. */
  64728. static CLASSNAME: string;
  64729. /**
  64730. * Defines the default number of cascades used by the CSM.
  64731. */
  64732. static readonly DEFAULT_CASCADES_COUNT: number;
  64733. /**
  64734. * Defines the minimum number of cascades used by the CSM.
  64735. */
  64736. static readonly MIN_CASCADES_COUNT: number;
  64737. /**
  64738. * Defines the maximum number of cascades used by the CSM.
  64739. */
  64740. static readonly MAX_CASCADES_COUNT: number;
  64741. protected _validateFilter(filter: number): number;
  64742. /**
  64743. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64744. */
  64745. penumbraDarkness: number;
  64746. private _numCascades;
  64747. /**
  64748. * Gets or set the number of cascades used by the CSM.
  64749. */
  64750. get numCascades(): number;
  64751. set numCascades(value: number);
  64752. /**
  64753. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64754. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64755. */
  64756. stabilizeCascades: boolean;
  64757. private _freezeShadowCastersBoundingInfo;
  64758. private _freezeShadowCastersBoundingInfoObservable;
  64759. /**
  64760. * Enables or disables the shadow casters bounding info computation.
  64761. * If your shadow casters don't move, you can disable this feature.
  64762. * If it is enabled, the bounding box computation is done every frame.
  64763. */
  64764. get freezeShadowCastersBoundingInfo(): boolean;
  64765. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64766. private _scbiMin;
  64767. private _scbiMax;
  64768. protected _computeShadowCastersBoundingInfo(): void;
  64769. protected _shadowCastersBoundingInfo: BoundingInfo;
  64770. /**
  64771. * Gets or sets the shadow casters bounding info.
  64772. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64773. * so that the system won't overwrite the bounds you provide
  64774. */
  64775. get shadowCastersBoundingInfo(): BoundingInfo;
  64776. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64777. protected _breaksAreDirty: boolean;
  64778. protected _minDistance: number;
  64779. protected _maxDistance: number;
  64780. /**
  64781. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64782. *
  64783. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64784. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64785. * @param min minimal distance for the breaks (default to 0.)
  64786. * @param max maximal distance for the breaks (default to 1.)
  64787. */
  64788. setMinMaxDistance(min: number, max: number): void;
  64789. /** Gets the minimal distance used in the cascade break computation */
  64790. get minDistance(): number;
  64791. /** Gets the maximal distance used in the cascade break computation */
  64792. get maxDistance(): number;
  64793. /**
  64794. * Gets the class name of that object
  64795. * @returns "CascadedShadowGenerator"
  64796. */
  64797. getClassName(): string;
  64798. private _cascadeMinExtents;
  64799. private _cascadeMaxExtents;
  64800. /**
  64801. * Gets a cascade minimum extents
  64802. * @param cascadeIndex index of the cascade
  64803. * @returns the minimum cascade extents
  64804. */
  64805. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64806. /**
  64807. * Gets a cascade maximum extents
  64808. * @param cascadeIndex index of the cascade
  64809. * @returns the maximum cascade extents
  64810. */
  64811. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64812. private _cascades;
  64813. private _currentLayer;
  64814. private _viewSpaceFrustumsZ;
  64815. private _viewMatrices;
  64816. private _projectionMatrices;
  64817. private _transformMatrices;
  64818. private _transformMatricesAsArray;
  64819. private _frustumLengths;
  64820. private _lightSizeUVCorrection;
  64821. private _depthCorrection;
  64822. private _frustumCornersWorldSpace;
  64823. private _frustumCenter;
  64824. private _shadowCameraPos;
  64825. private _shadowMaxZ;
  64826. /**
  64827. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64828. * It defaults to camera.maxZ
  64829. */
  64830. get shadowMaxZ(): number;
  64831. /**
  64832. * Sets the shadow max z distance.
  64833. */
  64834. set shadowMaxZ(value: number);
  64835. protected _debug: boolean;
  64836. /**
  64837. * Gets or sets the debug flag.
  64838. * When enabled, the cascades are materialized by different colors on the screen.
  64839. */
  64840. get debug(): boolean;
  64841. set debug(dbg: boolean);
  64842. private _depthClamp;
  64843. /**
  64844. * Gets or sets the depth clamping value.
  64845. *
  64846. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64847. * to account for the shadow casters far away.
  64848. *
  64849. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64850. */
  64851. get depthClamp(): boolean;
  64852. set depthClamp(value: boolean);
  64853. private _cascadeBlendPercentage;
  64854. /**
  64855. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64856. * It defaults to 0.1 (10% blending).
  64857. */
  64858. get cascadeBlendPercentage(): number;
  64859. set cascadeBlendPercentage(value: number);
  64860. private _lambda;
  64861. /**
  64862. * Gets or set the lambda parameter.
  64863. * This parameter is used to split the camera frustum and create the cascades.
  64864. * 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.
  64865. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64866. */
  64867. get lambda(): number;
  64868. set lambda(value: number);
  64869. /**
  64870. * Gets the view matrix corresponding to a given cascade
  64871. * @param cascadeNum cascade to retrieve the view matrix from
  64872. * @returns the cascade view matrix
  64873. */
  64874. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64875. /**
  64876. * Gets the projection matrix corresponding to a given cascade
  64877. * @param cascadeNum cascade to retrieve the projection matrix from
  64878. * @returns the cascade projection matrix
  64879. */
  64880. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64881. /**
  64882. * Gets the transformation matrix corresponding to a given cascade
  64883. * @param cascadeNum cascade to retrieve the transformation matrix from
  64884. * @returns the cascade transformation matrix
  64885. */
  64886. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64887. private _depthRenderer;
  64888. /**
  64889. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64890. *
  64891. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64892. *
  64893. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64894. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64895. * @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
  64896. */
  64897. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64898. private _depthReducer;
  64899. private _autoCalcDepthBounds;
  64900. /**
  64901. * Gets or sets the autoCalcDepthBounds property.
  64902. *
  64903. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64904. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64905. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64906. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64907. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64908. */
  64909. get autoCalcDepthBounds(): boolean;
  64910. set autoCalcDepthBounds(value: boolean);
  64911. /**
  64912. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64913. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64914. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64915. * for setting the refresh rate on the renderer yourself!
  64916. */
  64917. get autoCalcDepthBoundsRefreshRate(): number;
  64918. set autoCalcDepthBoundsRefreshRate(value: number);
  64919. /**
  64920. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64921. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64922. * you change the camera near/far planes!
  64923. */
  64924. splitFrustum(): void;
  64925. private _splitFrustum;
  64926. private _computeMatrices;
  64927. private _computeFrustumInWorldSpace;
  64928. private _computeCascadeFrustum;
  64929. /**
  64930. * Support test.
  64931. */
  64932. static get IsSupported(): boolean;
  64933. /** @hidden */
  64934. static _SceneComponentInitialization: (scene: Scene) => void;
  64935. /**
  64936. * Creates a Cascaded Shadow Generator object.
  64937. * A ShadowGenerator is the required tool to use the shadows.
  64938. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64939. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64940. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64941. * @param light The directional light object generating the shadows.
  64942. * @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.
  64943. */
  64944. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64945. protected _initializeGenerator(): void;
  64946. protected _createTargetRenderTexture(): void;
  64947. protected _initializeShadowMap(): void;
  64948. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64949. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64950. /**
  64951. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64952. * @param defines Defines of the material we want to update
  64953. * @param lightIndex Index of the light in the enabled light list of the material
  64954. */
  64955. prepareDefines(defines: any, lightIndex: number): void;
  64956. /**
  64957. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64958. * defined in the generator but impacting the effect).
  64959. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64960. * @param effect The effect we are binfing the information for
  64961. */
  64962. bindShadowLight(lightIndex: string, effect: Effect): void;
  64963. /**
  64964. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64965. * (eq to view projection * shadow projection matrices)
  64966. * @returns The transform matrix used to create the shadow map
  64967. */
  64968. getTransformMatrix(): Matrix;
  64969. /**
  64970. * Disposes the ShadowGenerator.
  64971. * Returns nothing.
  64972. */
  64973. dispose(): void;
  64974. /**
  64975. * Serializes the shadow generator setup to a json object.
  64976. * @returns The serialized JSON object
  64977. */
  64978. serialize(): any;
  64979. /**
  64980. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64981. * @param parsedShadowGenerator The JSON object to parse
  64982. * @param scene The scene to create the shadow map for
  64983. * @returns The parsed shadow generator
  64984. */
  64985. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64986. }
  64987. }
  64988. declare module BABYLON {
  64989. /**
  64990. * Defines the shadow generator component responsible to manage any shadow generators
  64991. * in a given scene.
  64992. */
  64993. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64994. /**
  64995. * The component name helpful to identify the component in the list of scene components.
  64996. */
  64997. readonly name: string;
  64998. /**
  64999. * The scene the component belongs to.
  65000. */
  65001. scene: Scene;
  65002. /**
  65003. * Creates a new instance of the component for the given scene
  65004. * @param scene Defines the scene to register the component in
  65005. */
  65006. constructor(scene: Scene);
  65007. /**
  65008. * Registers the component in a given scene
  65009. */
  65010. register(): void;
  65011. /**
  65012. * Rebuilds the elements related to this component in case of
  65013. * context lost for instance.
  65014. */
  65015. rebuild(): void;
  65016. /**
  65017. * Serializes the component data to the specified json object
  65018. * @param serializationObject The object to serialize to
  65019. */
  65020. serialize(serializationObject: any): void;
  65021. /**
  65022. * Adds all the elements from the container to the scene
  65023. * @param container the container holding the elements
  65024. */
  65025. addFromContainer(container: AbstractScene): void;
  65026. /**
  65027. * Removes all the elements in the container from the scene
  65028. * @param container contains the elements to remove
  65029. * @param dispose if the removed element should be disposed (default: false)
  65030. */
  65031. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  65032. /**
  65033. * Rebuilds the elements related to this component in case of
  65034. * context lost for instance.
  65035. */
  65036. dispose(): void;
  65037. private _gatherRenderTargets;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * A point light is a light defined by an unique point in world space.
  65043. * The light is emitted in every direction from this point.
  65044. * A good example of a point light is a standard light bulb.
  65045. * Documentation: https://doc.babylonjs.com/babylon101/lights
  65046. */
  65047. export class PointLight extends ShadowLight {
  65048. private _shadowAngle;
  65049. /**
  65050. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65051. * This specifies what angle the shadow will use to be created.
  65052. *
  65053. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65054. */
  65055. get shadowAngle(): number;
  65056. /**
  65057. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65058. * This specifies what angle the shadow will use to be created.
  65059. *
  65060. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  65061. */
  65062. set shadowAngle(value: number);
  65063. /**
  65064. * Gets the direction if it has been set.
  65065. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65066. */
  65067. get direction(): Vector3;
  65068. /**
  65069. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  65070. */
  65071. set direction(value: Vector3);
  65072. /**
  65073. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  65074. * A PointLight emits the light in every direction.
  65075. * It can cast shadows.
  65076. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  65077. * ```javascript
  65078. * var pointLight = new PointLight("pl", camera.position, scene);
  65079. * ```
  65080. * Documentation : https://doc.babylonjs.com/babylon101/lights
  65081. * @param name The light friendly name
  65082. * @param position The position of the point light in the scene
  65083. * @param scene The scene the lights belongs to
  65084. */
  65085. constructor(name: string, position: Vector3, scene: Scene);
  65086. /**
  65087. * Returns the string "PointLight"
  65088. * @returns the class name
  65089. */
  65090. getClassName(): string;
  65091. /**
  65092. * Returns the integer 0.
  65093. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  65094. */
  65095. getTypeID(): number;
  65096. /**
  65097. * Specifies whether or not the shadowmap should be a cube texture.
  65098. * @returns true if the shadowmap needs to be a cube texture.
  65099. */
  65100. needCube(): boolean;
  65101. /**
  65102. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  65103. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65104. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65105. */
  65106. getShadowDirection(faceIndex?: number): Vector3;
  65107. /**
  65108. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  65109. * - fov = PI / 2
  65110. * - aspect ratio : 1.0
  65111. * - z-near and far equal to the active camera minZ and maxZ.
  65112. * Returns the PointLight.
  65113. */
  65114. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65115. protected _buildUniformLayout(): void;
  65116. /**
  65117. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  65118. * @param effect The effect to update
  65119. * @param lightIndex The index of the light in the effect to update
  65120. * @returns The point light
  65121. */
  65122. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  65123. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  65124. /**
  65125. * Prepares the list of defines specific to the light type.
  65126. * @param defines the list of defines
  65127. * @param lightIndex defines the index of the light for the effect
  65128. */
  65129. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Header information of HDR texture files.
  65135. */
  65136. export interface HDRInfo {
  65137. /**
  65138. * The height of the texture in pixels.
  65139. */
  65140. height: number;
  65141. /**
  65142. * The width of the texture in pixels.
  65143. */
  65144. width: number;
  65145. /**
  65146. * The index of the beginning of the data in the binary file.
  65147. */
  65148. dataPosition: number;
  65149. }
  65150. /**
  65151. * This groups tools to convert HDR texture to native colors array.
  65152. */
  65153. export class HDRTools {
  65154. private static Ldexp;
  65155. private static Rgbe2float;
  65156. private static readStringLine;
  65157. /**
  65158. * Reads header information from an RGBE texture stored in a native array.
  65159. * More information on this format are available here:
  65160. * https://en.wikipedia.org/wiki/RGBE_image_format
  65161. *
  65162. * @param uint8array The binary file stored in native array.
  65163. * @return The header information.
  65164. */
  65165. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  65166. /**
  65167. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  65168. * This RGBE texture needs to store the information as a panorama.
  65169. *
  65170. * More information on this format are available here:
  65171. * https://en.wikipedia.org/wiki/RGBE_image_format
  65172. *
  65173. * @param buffer The binary file stored in an array buffer.
  65174. * @param size The expected size of the extracted cubemap.
  65175. * @return The Cube Map information.
  65176. */
  65177. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  65178. /**
  65179. * Returns the pixels data extracted from an RGBE texture.
  65180. * This pixels will be stored left to right up to down in the R G B order in one array.
  65181. *
  65182. * More information on this format are available here:
  65183. * https://en.wikipedia.org/wiki/RGBE_image_format
  65184. *
  65185. * @param uint8array The binary file stored in an array buffer.
  65186. * @param hdrInfo The header information of the file.
  65187. * @return The pixels data in RGB right to left up to down order.
  65188. */
  65189. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  65190. private static RGBE_ReadPixels_RLE;
  65191. private static RGBE_ReadPixels_NOT_RLE;
  65192. }
  65193. }
  65194. declare module BABYLON {
  65195. /**
  65196. * Effect Render Options
  65197. */
  65198. export interface IEffectRendererOptions {
  65199. /**
  65200. * Defines the vertices positions.
  65201. */
  65202. positions?: number[];
  65203. /**
  65204. * Defines the indices.
  65205. */
  65206. indices?: number[];
  65207. }
  65208. /**
  65209. * Helper class to render one or more effects.
  65210. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  65211. */
  65212. export class EffectRenderer {
  65213. private engine;
  65214. private static _DefaultOptions;
  65215. private _vertexBuffers;
  65216. private _indexBuffer;
  65217. private _fullscreenViewport;
  65218. /**
  65219. * Creates an effect renderer
  65220. * @param engine the engine to use for rendering
  65221. * @param options defines the options of the effect renderer
  65222. */
  65223. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  65224. /**
  65225. * Sets the current viewport in normalized coordinates 0-1
  65226. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  65227. */
  65228. setViewport(viewport?: Viewport): void;
  65229. /**
  65230. * Binds the embedded attributes buffer to the effect.
  65231. * @param effect Defines the effect to bind the attributes for
  65232. */
  65233. bindBuffers(effect: Effect): void;
  65234. /**
  65235. * Sets the current effect wrapper to use during draw.
  65236. * The effect needs to be ready before calling this api.
  65237. * This also sets the default full screen position attribute.
  65238. * @param effectWrapper Defines the effect to draw with
  65239. */
  65240. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  65241. /**
  65242. * Restores engine states
  65243. */
  65244. restoreStates(): void;
  65245. /**
  65246. * Draws a full screen quad.
  65247. */
  65248. draw(): void;
  65249. private isRenderTargetTexture;
  65250. /**
  65251. * renders one or more effects to a specified texture
  65252. * @param effectWrapper the effect to renderer
  65253. * @param outputTexture texture to draw to, if null it will render to the screen.
  65254. */
  65255. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  65256. /**
  65257. * Disposes of the effect renderer
  65258. */
  65259. dispose(): void;
  65260. }
  65261. /**
  65262. * Options to create an EffectWrapper
  65263. */
  65264. interface EffectWrapperCreationOptions {
  65265. /**
  65266. * Engine to use to create the effect
  65267. */
  65268. engine: ThinEngine;
  65269. /**
  65270. * Fragment shader for the effect
  65271. */
  65272. fragmentShader: string;
  65273. /**
  65274. * Use the shader store instead of direct source code
  65275. */
  65276. useShaderStore?: boolean;
  65277. /**
  65278. * Vertex shader for the effect
  65279. */
  65280. vertexShader?: string;
  65281. /**
  65282. * Attributes to use in the shader
  65283. */
  65284. attributeNames?: Array<string>;
  65285. /**
  65286. * Uniforms to use in the shader
  65287. */
  65288. uniformNames?: Array<string>;
  65289. /**
  65290. * Texture sampler names to use in the shader
  65291. */
  65292. samplerNames?: Array<string>;
  65293. /**
  65294. * Defines to use in the shader
  65295. */
  65296. defines?: Array<string>;
  65297. /**
  65298. * Callback when effect is compiled
  65299. */
  65300. onCompiled?: Nullable<(effect: Effect) => void>;
  65301. /**
  65302. * The friendly name of the effect displayed in Spector.
  65303. */
  65304. name?: string;
  65305. }
  65306. /**
  65307. * Wraps an effect to be used for rendering
  65308. */
  65309. export class EffectWrapper {
  65310. /**
  65311. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  65312. */
  65313. onApplyObservable: Observable<{}>;
  65314. /**
  65315. * The underlying effect
  65316. */
  65317. effect: Effect;
  65318. /**
  65319. * Creates an effect to be renderer
  65320. * @param creationOptions options to create the effect
  65321. */
  65322. constructor(creationOptions: EffectWrapperCreationOptions);
  65323. /**
  65324. * Disposes of the effect wrapper
  65325. */
  65326. dispose(): void;
  65327. }
  65328. }
  65329. declare module BABYLON {
  65330. /** @hidden */
  65331. export var hdrFilteringVertexShader: {
  65332. name: string;
  65333. shader: string;
  65334. };
  65335. }
  65336. declare module BABYLON {
  65337. /** @hidden */
  65338. export var hdrFilteringPixelShader: {
  65339. name: string;
  65340. shader: string;
  65341. };
  65342. }
  65343. declare module BABYLON {
  65344. /**
  65345. * Options for texture filtering
  65346. */
  65347. interface IHDRFilteringOptions {
  65348. /**
  65349. * Scales pixel intensity for the input HDR map.
  65350. */
  65351. hdrScale?: number;
  65352. /**
  65353. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  65354. */
  65355. quality?: number;
  65356. }
  65357. /**
  65358. * Filters HDR maps to get correct renderings of PBR reflections
  65359. */
  65360. export class HDRFiltering {
  65361. private _engine;
  65362. private _effectRenderer;
  65363. private _effectWrapper;
  65364. private _lodGenerationOffset;
  65365. private _lodGenerationScale;
  65366. /**
  65367. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  65368. * you care about baking speed.
  65369. */
  65370. quality: number;
  65371. /**
  65372. * Scales pixel intensity for the input HDR map.
  65373. */
  65374. hdrScale: number;
  65375. /**
  65376. * Instantiates HDR filter for reflection maps
  65377. *
  65378. * @param engine Thin engine
  65379. * @param options Options
  65380. */
  65381. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  65382. private _createRenderTarget;
  65383. private _prefilterInternal;
  65384. private _createEffect;
  65385. /**
  65386. * Get a value indicating if the filter is ready to be used
  65387. * @param texture Texture to filter
  65388. * @returns true if the filter is ready
  65389. */
  65390. isReady(texture: BaseTexture): boolean;
  65391. /**
  65392. * Prefilters a cube texture to have mipmap levels representing roughness values.
  65393. * Prefiltering will be invoked at the end of next rendering pass.
  65394. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  65395. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  65396. * @param texture Texture to filter
  65397. * @param onFinished Callback when filtering is done
  65398. * @return Promise called when prefiltering is done
  65399. */
  65400. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  65401. }
  65402. }
  65403. declare module BABYLON {
  65404. /**
  65405. * This represents a texture coming from an HDR input.
  65406. *
  65407. * The only supported format is currently panorama picture stored in RGBE format.
  65408. * Example of such files can be found on HDRLib: http://hdrlib.com/
  65409. */
  65410. export class HDRCubeTexture extends BaseTexture {
  65411. private static _facesMapping;
  65412. private _generateHarmonics;
  65413. private _noMipmap;
  65414. private _prefilterOnLoad;
  65415. private _textureMatrix;
  65416. private _size;
  65417. private _onLoad;
  65418. private _onError;
  65419. /**
  65420. * The texture URL.
  65421. */
  65422. url: string;
  65423. protected _isBlocking: boolean;
  65424. /**
  65425. * Sets whether or not the texture is blocking during loading.
  65426. */
  65427. set isBlocking(value: boolean);
  65428. /**
  65429. * Gets whether or not the texture is blocking during loading.
  65430. */
  65431. get isBlocking(): boolean;
  65432. protected _rotationY: number;
  65433. /**
  65434. * Sets texture matrix rotation angle around Y axis in radians.
  65435. */
  65436. set rotationY(value: number);
  65437. /**
  65438. * Gets texture matrix rotation angle around Y axis radians.
  65439. */
  65440. get rotationY(): number;
  65441. /**
  65442. * Gets or sets the center of the bounding box associated with the cube texture
  65443. * It must define where the camera used to render the texture was set
  65444. */
  65445. boundingBoxPosition: Vector3;
  65446. private _boundingBoxSize;
  65447. /**
  65448. * Gets or sets the size of the bounding box associated with the cube texture
  65449. * When defined, the cubemap will switch to local mode
  65450. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65451. * @example https://www.babylonjs-playground.com/#RNASML
  65452. */
  65453. set boundingBoxSize(value: Vector3);
  65454. get boundingBoxSize(): Vector3;
  65455. /**
  65456. * Instantiates an HDRTexture from the following parameters.
  65457. *
  65458. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  65459. * @param sceneOrEngine The scene or engine the texture will be used in
  65460. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65461. * @param noMipmap Forces to not generate the mipmap if true
  65462. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  65463. * @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)
  65464. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  65465. */
  65466. 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>);
  65467. /**
  65468. * Get the current class name of the texture useful for serialization or dynamic coding.
  65469. * @returns "HDRCubeTexture"
  65470. */
  65471. getClassName(): string;
  65472. /**
  65473. * Occurs when the file is raw .hdr file.
  65474. */
  65475. private loadTexture;
  65476. clone(): HDRCubeTexture;
  65477. delayLoad(): void;
  65478. /**
  65479. * Get the texture reflection matrix used to rotate/transform the reflection.
  65480. * @returns the reflection matrix
  65481. */
  65482. getReflectionTextureMatrix(): Matrix;
  65483. /**
  65484. * Set the texture reflection matrix used to rotate/transform the reflection.
  65485. * @param value Define the reflection matrix to set
  65486. */
  65487. setReflectionTextureMatrix(value: Matrix): void;
  65488. /**
  65489. * Parses a JSON representation of an HDR Texture in order to create the texture
  65490. * @param parsedTexture Define the JSON representation
  65491. * @param scene Define the scene the texture should be created in
  65492. * @param rootUrl Define the root url in case we need to load relative dependencies
  65493. * @returns the newly created texture after parsing
  65494. */
  65495. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  65496. serialize(): any;
  65497. }
  65498. }
  65499. declare module BABYLON {
  65500. /**
  65501. * Class used to control physics engine
  65502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65503. */
  65504. export class PhysicsEngine implements IPhysicsEngine {
  65505. private _physicsPlugin;
  65506. /**
  65507. * Global value used to control the smallest number supported by the simulation
  65508. */
  65509. static Epsilon: number;
  65510. private _impostors;
  65511. private _joints;
  65512. private _subTimeStep;
  65513. /**
  65514. * Gets the gravity vector used by the simulation
  65515. */
  65516. gravity: Vector3;
  65517. /**
  65518. * Factory used to create the default physics plugin.
  65519. * @returns The default physics plugin
  65520. */
  65521. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65522. /**
  65523. * Creates a new Physics Engine
  65524. * @param gravity defines the gravity vector used by the simulation
  65525. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65526. */
  65527. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65528. /**
  65529. * Sets the gravity vector used by the simulation
  65530. * @param gravity defines the gravity vector to use
  65531. */
  65532. setGravity(gravity: Vector3): void;
  65533. /**
  65534. * Set the time step of the physics engine.
  65535. * Default is 1/60.
  65536. * To slow it down, enter 1/600 for example.
  65537. * To speed it up, 1/30
  65538. * @param newTimeStep defines the new timestep to apply to this world.
  65539. */
  65540. setTimeStep(newTimeStep?: number): void;
  65541. /**
  65542. * Get the time step of the physics engine.
  65543. * @returns the current time step
  65544. */
  65545. getTimeStep(): number;
  65546. /**
  65547. * Set the sub time step of the physics engine.
  65548. * Default is 0 meaning there is no sub steps
  65549. * To increase physics resolution precision, set a small value (like 1 ms)
  65550. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65551. */
  65552. setSubTimeStep(subTimeStep?: number): void;
  65553. /**
  65554. * Get the sub time step of the physics engine.
  65555. * @returns the current sub time step
  65556. */
  65557. getSubTimeStep(): number;
  65558. /**
  65559. * Release all resources
  65560. */
  65561. dispose(): void;
  65562. /**
  65563. * Gets the name of the current physics plugin
  65564. * @returns the name of the plugin
  65565. */
  65566. getPhysicsPluginName(): string;
  65567. /**
  65568. * Adding a new impostor for the impostor tracking.
  65569. * This will be done by the impostor itself.
  65570. * @param impostor the impostor to add
  65571. */
  65572. addImpostor(impostor: PhysicsImpostor): void;
  65573. /**
  65574. * Remove an impostor from the engine.
  65575. * This impostor and its mesh will not longer be updated by the physics engine.
  65576. * @param impostor the impostor to remove
  65577. */
  65578. removeImpostor(impostor: PhysicsImpostor): void;
  65579. /**
  65580. * Add a joint to the physics engine
  65581. * @param mainImpostor defines the main impostor to which the joint is added.
  65582. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65583. * @param joint defines the joint that will connect both impostors.
  65584. */
  65585. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65586. /**
  65587. * Removes a joint from the simulation
  65588. * @param mainImpostor defines the impostor used with the joint
  65589. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65590. * @param joint defines the joint to remove
  65591. */
  65592. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65593. /**
  65594. * Called by the scene. No need to call it.
  65595. * @param delta defines the timespan between frames
  65596. */
  65597. _step(delta: number): void;
  65598. /**
  65599. * Gets the current plugin used to run the simulation
  65600. * @returns current plugin
  65601. */
  65602. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65603. /**
  65604. * Gets the list of physic impostors
  65605. * @returns an array of PhysicsImpostor
  65606. */
  65607. getImpostors(): Array<PhysicsImpostor>;
  65608. /**
  65609. * Gets the impostor for a physics enabled object
  65610. * @param object defines the object impersonated by the impostor
  65611. * @returns the PhysicsImpostor or null if not found
  65612. */
  65613. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65614. /**
  65615. * Gets the impostor for a physics body object
  65616. * @param body defines physics body used by the impostor
  65617. * @returns the PhysicsImpostor or null if not found
  65618. */
  65619. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65620. /**
  65621. * Does a raycast in the physics world
  65622. * @param from when should the ray start?
  65623. * @param to when should the ray end?
  65624. * @returns PhysicsRaycastResult
  65625. */
  65626. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65627. }
  65628. }
  65629. declare module BABYLON {
  65630. /** @hidden */
  65631. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65632. private _useDeltaForWorldStep;
  65633. world: any;
  65634. name: string;
  65635. private _physicsMaterials;
  65636. private _fixedTimeStep;
  65637. private _cannonRaycastResult;
  65638. private _raycastResult;
  65639. private _physicsBodysToRemoveAfterStep;
  65640. private _firstFrame;
  65641. BJSCANNON: any;
  65642. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65643. setGravity(gravity: Vector3): void;
  65644. setTimeStep(timeStep: number): void;
  65645. getTimeStep(): number;
  65646. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65647. private _removeMarkedPhysicsBodiesFromWorld;
  65648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65651. private _processChildMeshes;
  65652. removePhysicsBody(impostor: PhysicsImpostor): void;
  65653. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65654. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65655. private _addMaterial;
  65656. private _checkWithEpsilon;
  65657. private _createShape;
  65658. private _createHeightmap;
  65659. private _minus90X;
  65660. private _plus90X;
  65661. private _tmpPosition;
  65662. private _tmpDeltaPosition;
  65663. private _tmpUnityRotation;
  65664. private _updatePhysicsBodyTransformation;
  65665. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65666. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65667. isSupported(): boolean;
  65668. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65669. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65670. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65671. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65672. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65673. getBodyMass(impostor: PhysicsImpostor): number;
  65674. getBodyFriction(impostor: PhysicsImpostor): number;
  65675. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65676. getBodyRestitution(impostor: PhysicsImpostor): number;
  65677. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65678. sleepBody(impostor: PhysicsImpostor): void;
  65679. wakeUpBody(impostor: PhysicsImpostor): void;
  65680. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65681. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65682. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65683. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65684. getRadius(impostor: PhysicsImpostor): number;
  65685. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65686. dispose(): void;
  65687. private _extendNamespace;
  65688. /**
  65689. * Does a raycast in the physics world
  65690. * @param from when should the ray start?
  65691. * @param to when should the ray end?
  65692. * @returns PhysicsRaycastResult
  65693. */
  65694. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65695. }
  65696. }
  65697. declare module BABYLON {
  65698. /** @hidden */
  65699. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65700. private _useDeltaForWorldStep;
  65701. world: any;
  65702. name: string;
  65703. BJSOIMO: any;
  65704. private _raycastResult;
  65705. private _fixedTimeStep;
  65706. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65707. setGravity(gravity: Vector3): void;
  65708. setTimeStep(timeStep: number): void;
  65709. getTimeStep(): number;
  65710. private _tmpImpostorsArray;
  65711. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65712. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65713. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65715. private _tmpPositionVector;
  65716. removePhysicsBody(impostor: PhysicsImpostor): void;
  65717. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65718. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65719. isSupported(): boolean;
  65720. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65721. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65722. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65723. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65724. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65725. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65726. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65727. getBodyMass(impostor: PhysicsImpostor): number;
  65728. getBodyFriction(impostor: PhysicsImpostor): number;
  65729. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65730. getBodyRestitution(impostor: PhysicsImpostor): number;
  65731. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65732. sleepBody(impostor: PhysicsImpostor): void;
  65733. wakeUpBody(impostor: PhysicsImpostor): void;
  65734. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65735. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65736. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65737. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65738. getRadius(impostor: PhysicsImpostor): number;
  65739. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65740. dispose(): void;
  65741. /**
  65742. * Does a raycast in the physics world
  65743. * @param from when should the ray start?
  65744. * @param to when should the ray end?
  65745. * @returns PhysicsRaycastResult
  65746. */
  65747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65748. }
  65749. }
  65750. declare module BABYLON {
  65751. /**
  65752. * AmmoJS Physics plugin
  65753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65754. * @see https://github.com/kripken/ammo.js/
  65755. */
  65756. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65757. private _useDeltaForWorldStep;
  65758. /**
  65759. * Reference to the Ammo library
  65760. */
  65761. bjsAMMO: any;
  65762. /**
  65763. * Created ammoJS world which physics bodies are added to
  65764. */
  65765. world: any;
  65766. /**
  65767. * Name of the plugin
  65768. */
  65769. name: string;
  65770. private _timeStep;
  65771. private _fixedTimeStep;
  65772. private _maxSteps;
  65773. private _tmpQuaternion;
  65774. private _tmpAmmoTransform;
  65775. private _tmpAmmoQuaternion;
  65776. private _tmpAmmoConcreteContactResultCallback;
  65777. private _collisionConfiguration;
  65778. private _dispatcher;
  65779. private _overlappingPairCache;
  65780. private _solver;
  65781. private _softBodySolver;
  65782. private _tmpAmmoVectorA;
  65783. private _tmpAmmoVectorB;
  65784. private _tmpAmmoVectorC;
  65785. private _tmpAmmoVectorD;
  65786. private _tmpContactCallbackResult;
  65787. private _tmpAmmoVectorRCA;
  65788. private _tmpAmmoVectorRCB;
  65789. private _raycastResult;
  65790. private _tmpContactPoint;
  65791. private static readonly DISABLE_COLLISION_FLAG;
  65792. private static readonly KINEMATIC_FLAG;
  65793. private static readonly DISABLE_DEACTIVATION_FLAG;
  65794. /**
  65795. * Initializes the ammoJS plugin
  65796. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65797. * @param ammoInjection can be used to inject your own ammo reference
  65798. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65799. */
  65800. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65801. /**
  65802. * Sets the gravity of the physics world (m/(s^2))
  65803. * @param gravity Gravity to set
  65804. */
  65805. setGravity(gravity: Vector3): void;
  65806. /**
  65807. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65808. * @param timeStep timestep to use in seconds
  65809. */
  65810. setTimeStep(timeStep: number): void;
  65811. /**
  65812. * 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)
  65813. * @param fixedTimeStep fixedTimeStep to use in seconds
  65814. */
  65815. setFixedTimeStep(fixedTimeStep: number): void;
  65816. /**
  65817. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65818. * @param maxSteps the maximum number of steps by the physics engine per frame
  65819. */
  65820. setMaxSteps(maxSteps: number): void;
  65821. /**
  65822. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65823. * @returns the current timestep in seconds
  65824. */
  65825. getTimeStep(): number;
  65826. /**
  65827. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65828. */
  65829. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65830. private _isImpostorInContact;
  65831. private _isImpostorPairInContact;
  65832. private _stepSimulation;
  65833. /**
  65834. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65835. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65836. * After the step the babylon meshes are set to the position of the physics imposters
  65837. * @param delta amount of time to step forward
  65838. * @param impostors array of imposters to update before/after the step
  65839. */
  65840. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65841. /**
  65842. * Update babylon mesh to match physics world object
  65843. * @param impostor imposter to match
  65844. */
  65845. private _afterSoftStep;
  65846. /**
  65847. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65848. * @param impostor imposter to match
  65849. */
  65850. private _ropeStep;
  65851. /**
  65852. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65853. * @param impostor imposter to match
  65854. */
  65855. private _softbodyOrClothStep;
  65856. private _tmpMatrix;
  65857. /**
  65858. * Applies an impulse on the imposter
  65859. * @param impostor imposter to apply impulse to
  65860. * @param force amount of force to be applied to the imposter
  65861. * @param contactPoint the location to apply the impulse on the imposter
  65862. */
  65863. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65864. /**
  65865. * Applies a force on the imposter
  65866. * @param impostor imposter to apply force
  65867. * @param force amount of force to be applied to the imposter
  65868. * @param contactPoint the location to apply the force on the imposter
  65869. */
  65870. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65871. /**
  65872. * Creates a physics body using the plugin
  65873. * @param impostor the imposter to create the physics body on
  65874. */
  65875. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65876. /**
  65877. * Removes the physics body from the imposter and disposes of the body's memory
  65878. * @param impostor imposter to remove the physics body from
  65879. */
  65880. removePhysicsBody(impostor: PhysicsImpostor): void;
  65881. /**
  65882. * Generates a joint
  65883. * @param impostorJoint the imposter joint to create the joint with
  65884. */
  65885. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65886. /**
  65887. * Removes a joint
  65888. * @param impostorJoint the imposter joint to remove the joint from
  65889. */
  65890. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65891. private _addMeshVerts;
  65892. /**
  65893. * Initialise the soft body vertices to match its object's (mesh) vertices
  65894. * Softbody vertices (nodes) are in world space and to match this
  65895. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65896. * @param impostor to create the softbody for
  65897. */
  65898. private _softVertexData;
  65899. /**
  65900. * Create an impostor's soft body
  65901. * @param impostor to create the softbody for
  65902. */
  65903. private _createSoftbody;
  65904. /**
  65905. * Create cloth for an impostor
  65906. * @param impostor to create the softbody for
  65907. */
  65908. private _createCloth;
  65909. /**
  65910. * Create rope for an impostor
  65911. * @param impostor to create the softbody for
  65912. */
  65913. private _createRope;
  65914. /**
  65915. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65916. * @param impostor to create the custom physics shape for
  65917. */
  65918. private _createCustom;
  65919. private _addHullVerts;
  65920. private _createShape;
  65921. /**
  65922. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65923. * @param impostor imposter containing the physics body and babylon object
  65924. */
  65925. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65926. /**
  65927. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65928. * @param impostor imposter containing the physics body and babylon object
  65929. * @param newPosition new position
  65930. * @param newRotation new rotation
  65931. */
  65932. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65933. /**
  65934. * If this plugin is supported
  65935. * @returns true if its supported
  65936. */
  65937. isSupported(): boolean;
  65938. /**
  65939. * Sets the linear velocity of the physics body
  65940. * @param impostor imposter to set the velocity on
  65941. * @param velocity velocity to set
  65942. */
  65943. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65944. /**
  65945. * Sets the angular velocity of the physics body
  65946. * @param impostor imposter to set the velocity on
  65947. * @param velocity velocity to set
  65948. */
  65949. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65950. /**
  65951. * gets the linear velocity
  65952. * @param impostor imposter to get linear velocity from
  65953. * @returns linear velocity
  65954. */
  65955. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65956. /**
  65957. * gets the angular velocity
  65958. * @param impostor imposter to get angular velocity from
  65959. * @returns angular velocity
  65960. */
  65961. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65962. /**
  65963. * Sets the mass of physics body
  65964. * @param impostor imposter to set the mass on
  65965. * @param mass mass to set
  65966. */
  65967. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65968. /**
  65969. * Gets the mass of the physics body
  65970. * @param impostor imposter to get the mass from
  65971. * @returns mass
  65972. */
  65973. getBodyMass(impostor: PhysicsImpostor): number;
  65974. /**
  65975. * Gets friction of the impostor
  65976. * @param impostor impostor to get friction from
  65977. * @returns friction value
  65978. */
  65979. getBodyFriction(impostor: PhysicsImpostor): number;
  65980. /**
  65981. * Sets friction of the impostor
  65982. * @param impostor impostor to set friction on
  65983. * @param friction friction value
  65984. */
  65985. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65986. /**
  65987. * Gets restitution of the impostor
  65988. * @param impostor impostor to get restitution from
  65989. * @returns restitution value
  65990. */
  65991. getBodyRestitution(impostor: PhysicsImpostor): number;
  65992. /**
  65993. * Sets restitution of the impostor
  65994. * @param impostor impostor to set resitution on
  65995. * @param restitution resitution value
  65996. */
  65997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65998. /**
  65999. * Gets pressure inside the impostor
  66000. * @param impostor impostor to get pressure from
  66001. * @returns pressure value
  66002. */
  66003. getBodyPressure(impostor: PhysicsImpostor): number;
  66004. /**
  66005. * Sets pressure inside a soft body impostor
  66006. * Cloth and rope must remain 0 pressure
  66007. * @param impostor impostor to set pressure on
  66008. * @param pressure pressure value
  66009. */
  66010. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  66011. /**
  66012. * Gets stiffness of the impostor
  66013. * @param impostor impostor to get stiffness from
  66014. * @returns pressure value
  66015. */
  66016. getBodyStiffness(impostor: PhysicsImpostor): number;
  66017. /**
  66018. * Sets stiffness of the impostor
  66019. * @param impostor impostor to set stiffness on
  66020. * @param stiffness stiffness value from 0 to 1
  66021. */
  66022. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  66023. /**
  66024. * Gets velocityIterations of the impostor
  66025. * @param impostor impostor to get velocity iterations from
  66026. * @returns velocityIterations value
  66027. */
  66028. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  66029. /**
  66030. * Sets velocityIterations of the impostor
  66031. * @param impostor impostor to set velocity iterations on
  66032. * @param velocityIterations velocityIterations value
  66033. */
  66034. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  66035. /**
  66036. * Gets positionIterations of the impostor
  66037. * @param impostor impostor to get position iterations from
  66038. * @returns positionIterations value
  66039. */
  66040. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  66041. /**
  66042. * Sets positionIterations of the impostor
  66043. * @param impostor impostor to set position on
  66044. * @param positionIterations positionIterations value
  66045. */
  66046. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  66047. /**
  66048. * Append an anchor to a cloth object
  66049. * @param impostor is the cloth impostor to add anchor to
  66050. * @param otherImpostor is the rigid impostor to anchor to
  66051. * @param width ratio across width from 0 to 1
  66052. * @param height ratio up height from 0 to 1
  66053. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
  66054. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66055. */
  66056. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66057. /**
  66058. * Append an hook to a rope object
  66059. * @param impostor is the rope impostor to add hook to
  66060. * @param otherImpostor is the rigid impostor to hook to
  66061. * @param length ratio along the rope from 0 to 1
  66062. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
  66063. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  66064. */
  66065. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  66066. /**
  66067. * Sleeps the physics body and stops it from being active
  66068. * @param impostor impostor to sleep
  66069. */
  66070. sleepBody(impostor: PhysicsImpostor): void;
  66071. /**
  66072. * Activates the physics body
  66073. * @param impostor impostor to activate
  66074. */
  66075. wakeUpBody(impostor: PhysicsImpostor): void;
  66076. /**
  66077. * Updates the distance parameters of the joint
  66078. * @param joint joint to update
  66079. * @param maxDistance maximum distance of the joint
  66080. * @param minDistance minimum distance of the joint
  66081. */
  66082. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  66083. /**
  66084. * Sets a motor on the joint
  66085. * @param joint joint to set motor on
  66086. * @param speed speed of the motor
  66087. * @param maxForce maximum force of the motor
  66088. * @param motorIndex index of the motor
  66089. */
  66090. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  66091. /**
  66092. * Sets the motors limit
  66093. * @param joint joint to set limit on
  66094. * @param upperLimit upper limit
  66095. * @param lowerLimit lower limit
  66096. */
  66097. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  66098. /**
  66099. * Syncs the position and rotation of a mesh with the impostor
  66100. * @param mesh mesh to sync
  66101. * @param impostor impostor to update the mesh with
  66102. */
  66103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  66104. /**
  66105. * Gets the radius of the impostor
  66106. * @param impostor impostor to get radius from
  66107. * @returns the radius
  66108. */
  66109. getRadius(impostor: PhysicsImpostor): number;
  66110. /**
  66111. * Gets the box size of the impostor
  66112. * @param impostor impostor to get box size from
  66113. * @param result the resulting box size
  66114. */
  66115. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  66116. /**
  66117. * Disposes of the impostor
  66118. */
  66119. dispose(): void;
  66120. /**
  66121. * Does a raycast in the physics world
  66122. * @param from when should the ray start?
  66123. * @param to when should the ray end?
  66124. * @returns PhysicsRaycastResult
  66125. */
  66126. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  66127. }
  66128. }
  66129. declare module BABYLON {
  66130. interface AbstractScene {
  66131. /**
  66132. * The list of reflection probes added to the scene
  66133. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66134. */
  66135. reflectionProbes: Array<ReflectionProbe>;
  66136. /**
  66137. * Removes the given reflection probe from this scene.
  66138. * @param toRemove The reflection probe to remove
  66139. * @returns The index of the removed reflection probe
  66140. */
  66141. removeReflectionProbe(toRemove: ReflectionProbe): number;
  66142. /**
  66143. * Adds the given reflection probe to this scene.
  66144. * @param newReflectionProbe The reflection probe to add
  66145. */
  66146. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  66147. }
  66148. /**
  66149. * Class used to generate realtime reflection / refraction cube textures
  66150. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  66151. */
  66152. export class ReflectionProbe {
  66153. /** defines the name of the probe */
  66154. name: string;
  66155. private _scene;
  66156. private _renderTargetTexture;
  66157. private _projectionMatrix;
  66158. private _viewMatrix;
  66159. private _target;
  66160. private _add;
  66161. private _attachedMesh;
  66162. private _invertYAxis;
  66163. /** Gets or sets probe position (center of the cube map) */
  66164. position: Vector3;
  66165. /**
  66166. * Creates a new reflection probe
  66167. * @param name defines the name of the probe
  66168. * @param size defines the texture resolution (for each face)
  66169. * @param scene defines the hosting scene
  66170. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  66171. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  66172. */
  66173. constructor(
  66174. /** defines the name of the probe */
  66175. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  66176. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  66177. get samples(): number;
  66178. set samples(value: number);
  66179. /** Gets or sets the refresh rate to use (on every frame by default) */
  66180. get refreshRate(): number;
  66181. set refreshRate(value: number);
  66182. /**
  66183. * Gets the hosting scene
  66184. * @returns a Scene
  66185. */
  66186. getScene(): Scene;
  66187. /** Gets the internal CubeTexture used to render to */
  66188. get cubeTexture(): RenderTargetTexture;
  66189. /** Gets the list of meshes to render */
  66190. get renderList(): Nullable<AbstractMesh[]>;
  66191. /**
  66192. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  66193. * @param mesh defines the mesh to attach to
  66194. */
  66195. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  66196. /**
  66197. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  66198. * @param renderingGroupId The rendering group id corresponding to its index
  66199. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  66200. */
  66201. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  66202. /**
  66203. * Clean all associated resources
  66204. */
  66205. dispose(): void;
  66206. /**
  66207. * Converts the reflection probe information to a readable string for debug purpose.
  66208. * @param fullDetails Supports for multiple levels of logging within scene loading
  66209. * @returns the human readable reflection probe info
  66210. */
  66211. toString(fullDetails?: boolean): string;
  66212. /**
  66213. * Get the class name of the refection probe.
  66214. * @returns "ReflectionProbe"
  66215. */
  66216. getClassName(): string;
  66217. /**
  66218. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  66219. * @returns The JSON representation of the texture
  66220. */
  66221. serialize(): any;
  66222. /**
  66223. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  66224. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  66225. * @param scene Define the scene the parsed reflection probe should be instantiated in
  66226. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  66227. * @returns The parsed reflection probe if successful
  66228. */
  66229. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  66230. }
  66231. }
  66232. declare module BABYLON {
  66233. /** @hidden */
  66234. export var _BabylonLoaderRegistered: boolean;
  66235. /**
  66236. * Helps setting up some configuration for the babylon file loader.
  66237. */
  66238. export class BabylonFileLoaderConfiguration {
  66239. /**
  66240. * The loader does not allow injecting custom physics engine into the plugins.
  66241. * Unfortunately in ES6, we need to manually inject them into the plugin.
  66242. * So you could set this variable to your engine import to make it work.
  66243. */
  66244. static LoaderInjectedPhysicsEngine: any;
  66245. }
  66246. }
  66247. declare module BABYLON {
  66248. /**
  66249. * A material to use for fast depth-only rendering.
  66250. */
  66251. export class OcclusionMaterial extends ShaderMaterial {
  66252. constructor(name: string, scene: Scene);
  66253. }
  66254. }
  66255. declare module BABYLON {
  66256. /**
  66257. * The Physically based simple base material of BJS.
  66258. *
  66259. * This enables better naming and convention enforcements on top of the pbrMaterial.
  66260. * It is used as the base class for both the specGloss and metalRough conventions.
  66261. */
  66262. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  66263. /**
  66264. * Number of Simultaneous lights allowed on the material.
  66265. */
  66266. maxSimultaneousLights: number;
  66267. /**
  66268. * If sets to true, disables all the lights affecting the material.
  66269. */
  66270. disableLighting: boolean;
  66271. /**
  66272. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  66273. */
  66274. environmentTexture: BaseTexture;
  66275. /**
  66276. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  66277. */
  66278. invertNormalMapX: boolean;
  66279. /**
  66280. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  66281. */
  66282. invertNormalMapY: boolean;
  66283. /**
  66284. * Normal map used in the model.
  66285. */
  66286. normalTexture: BaseTexture;
  66287. /**
  66288. * Emissivie color used to self-illuminate the model.
  66289. */
  66290. emissiveColor: Color3;
  66291. /**
  66292. * Emissivie texture used to self-illuminate the model.
  66293. */
  66294. emissiveTexture: BaseTexture;
  66295. /**
  66296. * Occlusion Channel Strength.
  66297. */
  66298. occlusionStrength: number;
  66299. /**
  66300. * Occlusion Texture of the material (adding extra occlusion effects).
  66301. */
  66302. occlusionTexture: BaseTexture;
  66303. /**
  66304. * Defines the alpha limits in alpha test mode.
  66305. */
  66306. alphaCutOff: number;
  66307. /**
  66308. * Gets the current double sided mode.
  66309. */
  66310. get doubleSided(): boolean;
  66311. /**
  66312. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  66313. */
  66314. set doubleSided(value: boolean);
  66315. /**
  66316. * Stores the pre-calculated light information of a mesh in a texture.
  66317. */
  66318. lightmapTexture: BaseTexture;
  66319. /**
  66320. * If true, the light map contains occlusion information instead of lighting info.
  66321. */
  66322. useLightmapAsShadowmap: boolean;
  66323. /**
  66324. * Instantiates a new PBRMaterial instance.
  66325. *
  66326. * @param name The material name
  66327. * @param scene The scene the material will be use in.
  66328. */
  66329. constructor(name: string, scene: Scene);
  66330. getClassName(): string;
  66331. }
  66332. }
  66333. declare module BABYLON {
  66334. /**
  66335. * The PBR material of BJS following the metal roughness convention.
  66336. *
  66337. * This fits to the PBR convention in the GLTF definition:
  66338. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  66339. */
  66340. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  66341. /**
  66342. * The base color has two different interpretations depending on the value of metalness.
  66343. * When the material is a metal, the base color is the specific measured reflectance value
  66344. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  66345. * of the material.
  66346. */
  66347. baseColor: Color3;
  66348. /**
  66349. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  66350. * well as opacity information in the alpha channel.
  66351. */
  66352. baseTexture: BaseTexture;
  66353. /**
  66354. * Specifies the metallic scalar value of the material.
  66355. * Can also be used to scale the metalness values of the metallic texture.
  66356. */
  66357. metallic: number;
  66358. /**
  66359. * Specifies the roughness scalar value of the material.
  66360. * Can also be used to scale the roughness values of the metallic texture.
  66361. */
  66362. roughness: number;
  66363. /**
  66364. * Texture containing both the metallic value in the B channel and the
  66365. * roughness value in the G channel to keep better precision.
  66366. */
  66367. metallicRoughnessTexture: BaseTexture;
  66368. /**
  66369. * Instantiates a new PBRMetalRoughnessMaterial instance.
  66370. *
  66371. * @param name The material name
  66372. * @param scene The scene the material will be use in.
  66373. */
  66374. constructor(name: string, scene: Scene);
  66375. /**
  66376. * Return the current class name of the material.
  66377. */
  66378. getClassName(): string;
  66379. /**
  66380. * Makes a duplicate of the current material.
  66381. * @param name - name to use for the new material.
  66382. */
  66383. clone(name: string): PBRMetallicRoughnessMaterial;
  66384. /**
  66385. * Serialize the material to a parsable JSON object.
  66386. */
  66387. serialize(): any;
  66388. /**
  66389. * Parses a JSON object corresponding to the serialize function.
  66390. */
  66391. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  66392. }
  66393. }
  66394. declare module BABYLON {
  66395. /**
  66396. * The PBR material of BJS following the specular glossiness convention.
  66397. *
  66398. * This fits to the PBR convention in the GLTF definition:
  66399. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  66400. */
  66401. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  66402. /**
  66403. * Specifies the diffuse color of the material.
  66404. */
  66405. diffuseColor: Color3;
  66406. /**
  66407. * Specifies the diffuse texture of the material. This can also contains the opacity value in its alpha
  66408. * channel.
  66409. */
  66410. diffuseTexture: BaseTexture;
  66411. /**
  66412. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  66413. */
  66414. specularColor: Color3;
  66415. /**
  66416. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  66417. */
  66418. glossiness: number;
  66419. /**
  66420. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  66421. */
  66422. specularGlossinessTexture: BaseTexture;
  66423. /**
  66424. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  66425. */
  66426. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  66427. /**
  66428. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  66429. *
  66430. * @param name The material name
  66431. * @param scene The scene the material will be use in.
  66432. */
  66433. constructor(name: string, scene: Scene);
  66434. /**
  66435. * Return the current class name of the material.
  66436. */
  66437. getClassName(): string;
  66438. /**
  66439. * Makes a duplicate of the current material.
  66440. * @param name - name to use for the new material.
  66441. */
  66442. clone(name: string): PBRSpecularGlossinessMaterial;
  66443. /**
  66444. * Serialize the material to a parsable JSON object.
  66445. */
  66446. serialize(): any;
  66447. /**
  66448. * Parses a JSON object corresponding to the serialize function.
  66449. */
  66450. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  66451. }
  66452. }
  66453. declare module BABYLON {
  66454. /**
  66455. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66456. * It can help converting any input color in a desired output one. This can then be used to create effects
  66457. * from sepia, black and white to sixties or futuristic rendering...
  66458. *
  66459. * The only supported format is currently 3dl.
  66460. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66461. */
  66462. export class ColorGradingTexture extends BaseTexture {
  66463. /**
  66464. * The texture URL.
  66465. */
  66466. url: string;
  66467. /**
  66468. * Empty line regex stored for GC.
  66469. */
  66470. private static _noneEmptyLineRegex;
  66471. private _textureMatrix;
  66472. private _onLoad;
  66473. /**
  66474. * Instantiates a ColorGradingTexture from the following parameters.
  66475. *
  66476. * @param url The location of the color grading data (currently only supporting 3dl)
  66477. * @param sceneOrEngine The scene or engine the texture will be used in
  66478. * @param onLoad defines a callback triggered when the texture has been loaded
  66479. */
  66480. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66481. /**
  66482. * Fires the onload event from the constructor if requested.
  66483. */
  66484. private _triggerOnLoad;
  66485. /**
  66486. * Returns the texture matrix used in most of the material.
  66487. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66488. */
  66489. getTextureMatrix(): Matrix;
  66490. /**
  66491. * Occurs when the file being loaded is a .3dl LUT file.
  66492. */
  66493. private load3dlTexture;
  66494. /**
  66495. * Starts the loading process of the texture.
  66496. */
  66497. private loadTexture;
  66498. /**
  66499. * Clones the color grading texture.
  66500. */
  66501. clone(): ColorGradingTexture;
  66502. /**
  66503. * Called during delayed load for textures.
  66504. */
  66505. delayLoad(): void;
  66506. /**
  66507. * Parses a color grading texture serialized by Babylon.
  66508. * @param parsedTexture The texture information being parsedTexture
  66509. * @param scene The scene to load the texture in
  66510. * @param rootUrl The root url of the data assets to load
  66511. * @return A color grading texture
  66512. */
  66513. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66514. /**
  66515. * Serializes the LUT texture to json format.
  66516. */
  66517. serialize(): any;
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. /**
  66522. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66523. */
  66524. export class EquiRectangularCubeTexture extends BaseTexture {
  66525. /** The six faces of the cube. */
  66526. private static _FacesMapping;
  66527. private _noMipmap;
  66528. private _onLoad;
  66529. private _onError;
  66530. /** The size of the cubemap. */
  66531. private _size;
  66532. /** The buffer of the image. */
  66533. private _buffer;
  66534. /** The width of the input image. */
  66535. private _width;
  66536. /** The height of the input image. */
  66537. private _height;
  66538. /** The URL to the image. */
  66539. url: string;
  66540. /**
  66541. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66542. * @param url The location of the image
  66543. * @param scene The scene the texture will be used in
  66544. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66545. * @param noMipmap Forces to not generate the mipmap if true
  66546. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66547. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66548. * @param onLoad — defines a callback called when texture is loaded
  66549. * @param onError — defines a callback called if there is an error
  66550. */
  66551. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66552. /**
  66553. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66554. */
  66555. private loadImage;
  66556. /**
  66557. * Convert the image buffer into a cubemap and create a CubeTexture.
  66558. */
  66559. private loadTexture;
  66560. /**
  66561. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66562. * @param buffer The ArrayBuffer that should be converted.
  66563. * @returns The buffer as Float32Array.
  66564. */
  66565. private getFloat32ArrayFromArrayBuffer;
  66566. /**
  66567. * Get the current class name of the texture useful for serialization or dynamic coding.
  66568. * @returns "EquiRectangularCubeTexture"
  66569. */
  66570. getClassName(): string;
  66571. /**
  66572. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66573. * @returns A clone of the current EquiRectangularCubeTexture.
  66574. */
  66575. clone(): EquiRectangularCubeTexture;
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. /**
  66580. * Defines the options related to the creation of an HtmlElementTexture
  66581. */
  66582. export interface IHtmlElementTextureOptions {
  66583. /**
  66584. * Defines whether mip maps should be created or not.
  66585. */
  66586. generateMipMaps?: boolean;
  66587. /**
  66588. * Defines the sampling mode of the texture.
  66589. */
  66590. samplingMode?: number;
  66591. /**
  66592. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66593. */
  66594. engine: Nullable<ThinEngine>;
  66595. /**
  66596. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66597. */
  66598. scene: Nullable<Scene>;
  66599. }
  66600. /**
  66601. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66602. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66603. * is automatically managed.
  66604. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66605. * in your application.
  66606. *
  66607. * As the update is not automatic, you need to call them manually.
  66608. */
  66609. export class HtmlElementTexture extends BaseTexture {
  66610. /**
  66611. * The texture URL.
  66612. */
  66613. element: HTMLVideoElement | HTMLCanvasElement;
  66614. private static readonly DefaultOptions;
  66615. private _textureMatrix;
  66616. private _isVideo;
  66617. private _generateMipMaps;
  66618. private _samplingMode;
  66619. /**
  66620. * Instantiates a HtmlElementTexture from the following parameters.
  66621. *
  66622. * @param name Defines the name of the texture
  66623. * @param element Defines the video or canvas the texture is filled with
  66624. * @param options Defines the other none mandatory texture creation options
  66625. */
  66626. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66627. private _createInternalTexture;
  66628. /**
  66629. * Returns the texture matrix used in most of the material.
  66630. */
  66631. getTextureMatrix(): Matrix;
  66632. /**
  66633. * Updates the content of the texture.
  66634. * @param invertY Defines whether the texture should be inverted on Y (false by default on video and true on canvas)
  66635. */
  66636. update(invertY?: Nullable<boolean>): void;
  66637. }
  66638. }
  66639. declare module BABYLON {
  66640. /**
  66641. * Based on jsTGALoader - Javascript loader for TGA file
  66642. * By Vincent Thibault
  66643. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66644. */
  66645. export class TGATools {
  66646. private static _TYPE_INDEXED;
  66647. private static _TYPE_RGB;
  66648. private static _TYPE_GREY;
  66649. private static _TYPE_RLE_INDEXED;
  66650. private static _TYPE_RLE_RGB;
  66651. private static _TYPE_RLE_GREY;
  66652. private static _ORIGIN_MASK;
  66653. private static _ORIGIN_SHIFT;
  66654. private static _ORIGIN_BL;
  66655. private static _ORIGIN_BR;
  66656. private static _ORIGIN_UL;
  66657. private static _ORIGIN_UR;
  66658. /**
  66659. * Gets the header of a TGA file
  66660. * @param data defines the TGA data
  66661. * @returns the header
  66662. */
  66663. static GetTGAHeader(data: Uint8Array): any;
  66664. /**
  66665. * Uploads TGA content to a Babylon Texture
  66666. * @hidden
  66667. */
  66668. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66669. /** @hidden */
  66670. 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;
  66671. /** @hidden */
  66672. 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;
  66673. /** @hidden */
  66674. 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;
  66675. /** @hidden */
  66676. 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;
  66677. /** @hidden */
  66678. 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;
  66679. /** @hidden */
  66680. 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;
  66681. }
  66682. }
  66683. declare module BABYLON {
  66684. /**
  66685. * Implementation of the TGA Texture Loader.
  66686. * @hidden
  66687. */
  66688. export class _TGATextureLoader implements IInternalTextureLoader {
  66689. /**
  66690. * Defines whether the loader supports cascade loading the different faces.
  66691. */
  66692. readonly supportCascades: boolean;
  66693. /**
  66694. * This returns if the loader support the current file information.
  66695. * @param extension defines the file extension of the file being loaded
  66696. * @returns true if the loader can load the specified file
  66697. */
  66698. canLoad(extension: string): boolean;
  66699. /**
  66700. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66701. * @param data contains the texture data
  66702. * @param texture defines the BabylonJS internal texture
  66703. * @param createPolynomials will be true if polynomials have been requested
  66704. * @param onLoad defines the callback to trigger once the texture is ready
  66705. * @param onError defines the callback to trigger in case of error
  66706. */
  66707. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66708. /**
  66709. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66710. * @param data contains the texture data
  66711. * @param texture defines the BabylonJS internal texture
  66712. * @param callback defines the method to call once ready to upload
  66713. */
  66714. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66715. }
  66716. }
  66717. declare module BABYLON {
  66718. /**
  66719. * Implementation of the HDR Texture Loader.
  66720. * @hidden
  66721. */
  66722. export class _HDRTextureLoader implements IInternalTextureLoader {
  66723. /**
  66724. * Defines whether the loader supports cascade loading the different faces.
  66725. */
  66726. readonly supportCascades: boolean;
  66727. /**
  66728. * This returns if the loader support the current file information.
  66729. * @param extension defines the file extension of the file being loaded
  66730. * @returns true if the loader can load the specified file
  66731. */
  66732. canLoad(extension: string): boolean;
  66733. /**
  66734. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66735. * @param data contains the texture data
  66736. * @param texture defines the BabylonJS internal texture
  66737. * @param createPolynomials will be true if polynomials have been requested
  66738. * @param onLoad defines the callback to trigger once the texture is ready
  66739. * @param onError defines the callback to trigger in case of error
  66740. */
  66741. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66742. /**
  66743. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66744. * @param data contains the texture data
  66745. * @param texture defines the BabylonJS internal texture
  66746. * @param callback defines the method to call once ready to upload
  66747. */
  66748. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66749. }
  66750. }
  66751. declare module BABYLON {
  66752. /**
  66753. * Info about the .basis files
  66754. */
  66755. class BasisFileInfo {
  66756. /**
  66757. * If the file has alpha
  66758. */
  66759. hasAlpha: boolean;
  66760. /**
  66761. * Info about each image of the basis file
  66762. */
  66763. images: Array<{
  66764. levels: Array<{
  66765. width: number;
  66766. height: number;
  66767. transcodedPixels: ArrayBufferView;
  66768. }>;
  66769. }>;
  66770. }
  66771. /**
  66772. * Result of transcoding a basis file
  66773. */
  66774. class TranscodeResult {
  66775. /**
  66776. * Info about the .basis file
  66777. */
  66778. fileInfo: BasisFileInfo;
  66779. /**
  66780. * Format to use when loading the file
  66781. */
  66782. format: number;
  66783. }
  66784. /**
  66785. * Configuration options for the Basis transcoder
  66786. */
  66787. export class BasisTranscodeConfiguration {
  66788. /**
  66789. * Supported compression formats used to determine the supported output format of the transcoder
  66790. */
  66791. supportedCompressionFormats?: {
  66792. /**
  66793. * etc1 compression format
  66794. */
  66795. etc1?: boolean;
  66796. /**
  66797. * s3tc compression format
  66798. */
  66799. s3tc?: boolean;
  66800. /**
  66801. * pvrtc compression format
  66802. */
  66803. pvrtc?: boolean;
  66804. /**
  66805. * etc2 compression format
  66806. */
  66807. etc2?: boolean;
  66808. };
  66809. /**
  66810. * If mipmap levels should be loaded for transcoded images (Default: true)
  66811. */
  66812. loadMipmapLevels?: boolean;
  66813. /**
  66814. * Index of a single image to load (Default: all images)
  66815. */
  66816. loadSingleImage?: number;
  66817. }
  66818. /**
  66819. * Used to load .Basis files
  66820. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66821. */
  66822. export class BasisTools {
  66823. private static _IgnoreSupportedFormats;
  66824. /**
  66825. * URL to use when loading the basis transcoder
  66826. */
  66827. static JSModuleURL: string;
  66828. /**
  66829. * URL to use when loading the wasm module for the transcoder
  66830. */
  66831. static WasmModuleURL: string;
  66832. /**
  66833. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66834. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66835. * @returns internal format corresponding to the Basis format
  66836. */
  66837. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66838. private static _WorkerPromise;
  66839. private static _Worker;
  66840. private static _actionId;
  66841. private static _CreateWorkerAsync;
  66842. /**
  66843. * Transcodes a loaded image file to compressed pixel data
  66844. * @param data image data to transcode
  66845. * @param config configuration options for the transcoding
  66846. * @returns a promise resulting in the transcoded image
  66847. */
  66848. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66849. /**
  66850. * Loads a texture from the transcode result
  66851. * @param texture texture load to
  66852. * @param transcodeResult the result of transcoding the basis file to load from
  66853. */
  66854. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66855. }
  66856. }
  66857. declare module BABYLON {
  66858. /**
  66859. * Loader for .basis file format
  66860. */
  66861. export class _BasisTextureLoader implements IInternalTextureLoader {
  66862. /**
  66863. * Defines whether the loader supports cascade loading the different faces.
  66864. */
  66865. readonly supportCascades: boolean;
  66866. /**
  66867. * This returns if the loader support the current file information.
  66868. * @param extension defines the file extension of the file being loaded
  66869. * @returns true if the loader can load the specified file
  66870. */
  66871. canLoad(extension: string): boolean;
  66872. /**
  66873. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66874. * @param data contains the texture data
  66875. * @param texture defines the BabylonJS internal texture
  66876. * @param createPolynomials will be true if polynomials have been requested
  66877. * @param onLoad defines the callback to trigger once the texture is ready
  66878. * @param onError defines the callback to trigger in case of error
  66879. */
  66880. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66881. /**
  66882. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66883. * @param data contains the texture data
  66884. * @param texture defines the BabylonJS internal texture
  66885. * @param callback defines the method to call once ready to upload
  66886. */
  66887. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66888. }
  66889. }
  66890. declare module BABYLON {
  66891. /**
  66892. * Defines the basic options interface of a TexturePacker Frame
  66893. */
  66894. export interface ITexturePackerFrame {
  66895. /**
  66896. * The frame ID
  66897. */
  66898. id: number;
  66899. /**
  66900. * The frames Scale
  66901. */
  66902. scale: Vector2;
  66903. /**
  66904. * The Frames offset
  66905. */
  66906. offset: Vector2;
  66907. }
  66908. /**
  66909. * This is a support class for frame Data on texture packer sets.
  66910. */
  66911. export class TexturePackerFrame implements ITexturePackerFrame {
  66912. /**
  66913. * The frame ID
  66914. */
  66915. id: number;
  66916. /**
  66917. * The frames Scale
  66918. */
  66919. scale: Vector2;
  66920. /**
  66921. * The Frames offset
  66922. */
  66923. offset: Vector2;
  66924. /**
  66925. * Initializes a texture package frame.
  66926. * @param id The numerical frame identifier
  66927. * @param scale Scalar Vector2 for UV frame
  66928. * @param offset Vector2 for the frame position in UV units.
  66929. * @returns TexturePackerFrame
  66930. */
  66931. constructor(id: number, scale: Vector2, offset: Vector2);
  66932. }
  66933. }
  66934. declare module BABYLON {
  66935. /**
  66936. * Defines the basic options interface of a TexturePacker
  66937. */
  66938. export interface ITexturePackerOptions {
  66939. /**
  66940. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66941. */
  66942. map?: string[];
  66943. /**
  66944. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66945. */
  66946. uvsIn?: string;
  66947. /**
  66948. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66949. */
  66950. uvsOut?: string;
  66951. /**
  66952. * number representing the layout style. Defaults to LAYOUT_STRIP
  66953. */
  66954. layout?: number;
  66955. /**
  66956. * number of columns if using custom column count layout(2). This defaults to 4.
  66957. */
  66958. colnum?: number;
  66959. /**
  66960. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66961. */
  66962. updateInputMeshes?: boolean;
  66963. /**
  66964. * boolean flag to dispose all the source textures. Defaults to true.
  66965. */
  66966. disposeSources?: boolean;
  66967. /**
  66968. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66969. */
  66970. fillBlanks?: boolean;
  66971. /**
  66972. * string value representing the context fill style color. Defaults to 'black'.
  66973. */
  66974. customFillColor?: string;
  66975. /**
  66976. * Width and Height Value of each Frame in the TexturePacker Sets
  66977. */
  66978. frameSize?: number;
  66979. /**
  66980. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66981. */
  66982. paddingRatio?: number;
  66983. /**
  66984. * Number that declares the fill method for the padding gutter.
  66985. */
  66986. paddingMode?: number;
  66987. /**
  66988. * If in SUBUV_COLOR padding mode what color to use.
  66989. */
  66990. paddingColor?: Color3 | Color4;
  66991. }
  66992. /**
  66993. * Defines the basic interface of a TexturePacker JSON File
  66994. */
  66995. export interface ITexturePackerJSON {
  66996. /**
  66997. * The frame ID
  66998. */
  66999. name: string;
  67000. /**
  67001. * The base64 channel data
  67002. */
  67003. sets: any;
  67004. /**
  67005. * The options of the Packer
  67006. */
  67007. options: ITexturePackerOptions;
  67008. /**
  67009. * The frame data of the Packer
  67010. */
  67011. frames: Array<number>;
  67012. }
  67013. /**
  67014. * This is a support class that generates a series of packed texture sets.
  67015. * @see https://doc.babylonjs.com/babylon101/materials
  67016. */
  67017. export class TexturePacker {
  67018. /** Packer Layout Constant 0 */
  67019. static readonly LAYOUT_STRIP: number;
  67020. /** Packer Layout Constant 1 */
  67021. static readonly LAYOUT_POWER2: number;
  67022. /** Packer Layout Constant 2 */
  67023. static readonly LAYOUT_COLNUM: number;
  67024. /** Packer Layout Constant 0 */
  67025. static readonly SUBUV_WRAP: number;
  67026. /** Packer Layout Constant 1 */
  67027. static readonly SUBUV_EXTEND: number;
  67028. /** Packer Layout Constant 2 */
  67029. static readonly SUBUV_COLOR: number;
  67030. /** The Name of the Texture Package */
  67031. name: string;
  67032. /** The scene scope of the TexturePacker */
  67033. scene: Scene;
  67034. /** The Meshes to target */
  67035. meshes: AbstractMesh[];
  67036. /** Arguments passed with the Constructor */
  67037. options: ITexturePackerOptions;
  67038. /** The promise that is started upon initialization */
  67039. promise: Nullable<Promise<TexturePacker | string>>;
  67040. /** The Container object for the channel sets that are generated */
  67041. sets: object;
  67042. /** The Container array for the frames that are generated */
  67043. frames: TexturePackerFrame[];
  67044. /** The expected number of textures the system is parsing. */
  67045. private _expecting;
  67046. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  67047. private _paddingValue;
  67048. /**
  67049. * Initializes a texture package series from an array of meshes or a single mesh.
  67050. * @param name The name of the package
  67051. * @param meshes The target meshes to compose the package from
  67052. * @param options The arguments that texture packer should follow while building.
  67053. * @param scene The scene which the textures are scoped to.
  67054. * @returns TexturePacker
  67055. */
  67056. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  67057. /**
  67058. * Starts the package process
  67059. * @param resolve The promises resolution function
  67060. * @returns TexturePacker
  67061. */
  67062. private _createFrames;
  67063. /**
  67064. * Calculates the Size of the Channel Sets
  67065. * @returns Vector2
  67066. */
  67067. private _calculateSize;
  67068. /**
  67069. * Calculates the UV data for the frames.
  67070. * @param baseSize the base frameSize
  67071. * @param padding the base frame padding
  67072. * @param dtSize size of the Dynamic Texture for that channel
  67073. * @param dtUnits is 1/dtSize
  67074. * @param update flag to update the input meshes
  67075. */
  67076. private _calculateMeshUVFrames;
  67077. /**
  67078. * Calculates the frames Offset.
  67079. * @param index of the frame
  67080. * @returns Vector2
  67081. */
  67082. private _getFrameOffset;
  67083. /**
  67084. * Updates a Mesh to the frame data
  67085. * @param mesh that is the target
  67086. * @param frameID or the frame index
  67087. */
  67088. private _updateMeshUV;
  67089. /**
  67090. * Updates a Meshes materials to use the texture packer channels
  67091. * @param m is the mesh to target
  67092. * @param force all channels on the packer to be set.
  67093. */
  67094. private _updateTextureReferences;
  67095. /**
  67096. * Public method to set a Mesh to a frame
  67097. * @param m that is the target
  67098. * @param frameID or the frame index
  67099. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  67100. */
  67101. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  67102. /**
  67103. * Starts the async promise to compile the texture packer.
  67104. * @returns Promise<void>
  67105. */
  67106. processAsync(): Promise<void>;
  67107. /**
  67108. * Disposes all textures associated with this packer
  67109. */
  67110. dispose(): void;
  67111. /**
  67112. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  67113. * @param imageType is the image type to use.
  67114. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  67115. */
  67116. download(imageType?: string, quality?: number): void;
  67117. /**
  67118. * Public method to load a texturePacker JSON file.
  67119. * @param data of the JSON file in string format.
  67120. */
  67121. updateFromJSON(data: string): void;
  67122. }
  67123. }
  67124. declare module BABYLON {
  67125. /**
  67126. * 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.
  67127. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67128. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67129. */
  67130. export class CustomProceduralTexture extends ProceduralTexture {
  67131. private _animate;
  67132. private _time;
  67133. private _config;
  67134. private _texturePath;
  67135. /**
  67136. * Instantiates a new Custom Procedural Texture.
  67137. * 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.
  67138. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  67139. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  67140. * @param name Define the name of the texture
  67141. * @param texturePath Define the folder path containing all the custom texture related files (config, shaders...)
  67142. * @param size Define the size of the texture to create
  67143. * @param scene Define the scene the texture belongs to
  67144. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  67145. * @param generateMipMaps Define if the texture should creates mip maps or not
  67146. */
  67147. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67148. private _loadJson;
  67149. /**
  67150. * Is the texture ready to be used ? (rendered at least once)
  67151. * @returns true if ready, otherwise, false.
  67152. */
  67153. isReady(): boolean;
  67154. /**
  67155. * Render the texture to its associated render target.
  67156. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  67157. */
  67158. render(useCameraPostProcess?: boolean): void;
  67159. /**
  67160. * Update the list of dependant textures samplers in the shader.
  67161. */
  67162. updateTextures(): void;
  67163. /**
  67164. * Update the uniform values of the procedural texture in the shader.
  67165. */
  67166. updateShaderUniforms(): void;
  67167. /**
  67168. * Define if the texture animates or not.
  67169. */
  67170. get animate(): boolean;
  67171. set animate(value: boolean);
  67172. }
  67173. }
  67174. declare module BABYLON {
  67175. /** @hidden */
  67176. export var noisePixelShader: {
  67177. name: string;
  67178. shader: string;
  67179. };
  67180. }
  67181. declare module BABYLON {
  67182. /**
  67183. * Class used to generate noise procedural textures
  67184. */
  67185. export class NoiseProceduralTexture extends ProceduralTexture {
  67186. /** Gets or sets the start time (default is 0) */
  67187. time: number;
  67188. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  67189. brightness: number;
  67190. /** Defines the number of octaves to process */
  67191. octaves: number;
  67192. /** Defines the level of persistence (0.8 by default) */
  67193. persistence: number;
  67194. /** Gets or sets animation speed factor (default is 1) */
  67195. animationSpeedFactor: number;
  67196. /**
  67197. * Creates a new NoiseProceduralTexture
  67198. * @param name defines the name fo the texture
  67199. * @param size defines the size of the texture (default is 256)
  67200. * @param scene defines the hosting scene
  67201. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  67202. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  67203. */
  67204. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  67205. private _updateShaderUniforms;
  67206. protected _getDefines(): string;
  67207. /** Generate the current state of the procedural texture */
  67208. render(useCameraPostProcess?: boolean): void;
  67209. /**
  67210. * Serializes this noise procedural texture
  67211. * @returns a serialized noise procedural texture object
  67212. */
  67213. serialize(): any;
  67214. /**
  67215. * Clone the texture.
  67216. * @returns the cloned texture
  67217. */
  67218. clone(): NoiseProceduralTexture;
  67219. /**
  67220. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  67221. * @param parsedTexture defines parsed texture data
  67222. * @param scene defines the current scene
  67223. * @param rootUrl defines the root URL containing noise procedural texture information
  67224. * @returns a parsed NoiseProceduralTexture
  67225. */
  67226. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  67227. }
  67228. }
  67229. declare module BABYLON {
  67230. /**
  67231. * Raw cube texture where the raw buffers are passed in
  67232. */
  67233. export class RawCubeTexture extends CubeTexture {
  67234. /**
  67235. * Creates a cube texture where the raw buffers are passed in.
  67236. * @param scene defines the scene the texture is attached to
  67237. * @param data defines the array of data to use to create each face
  67238. * @param size defines the size of the textures
  67239. * @param format defines the format of the data
  67240. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  67241. * @param generateMipMaps defines if the engine should generate the mip levels
  67242. * @param invertY defines if data must be stored with Y axis inverted
  67243. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  67244. * @param compression defines the compression used (null by default)
  67245. */
  67246. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  67247. /**
  67248. * Updates the raw cube texture.
  67249. * @param data defines the data to store
  67250. * @param format defines the data format
  67251. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67252. * @param invertY defines if data must be stored with Y axis inverted
  67253. * @param compression defines the compression used (null by default)
  67254. * @param level defines which level of the texture to update
  67255. */
  67256. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  67257. /**
  67258. * Updates a raw cube texture with RGBD encoded data.
  67259. * @param data defines the array of data [mipmap][face] to use to create each face
  67260. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  67261. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67262. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67263. * @returns a promise that resolves when the operation is complete
  67264. */
  67265. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  67266. /**
  67267. * Clones the raw cube texture.
  67268. * @return a new cube texture
  67269. */
  67270. clone(): CubeTexture;
  67271. /** @hidden */
  67272. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  67273. }
  67274. }
  67275. declare module BABYLON {
  67276. /**
  67277. * Class used to store 3D textures containing user data
  67278. */
  67279. export class RawTexture3D extends Texture {
  67280. /** Gets or sets the texture format to use */
  67281. format: number;
  67282. /**
  67283. * Create a new RawTexture3D
  67284. * @param data defines the data of the texture
  67285. * @param width defines the width of the texture
  67286. * @param height defines the height of the texture
  67287. * @param depth defines the depth of the texture
  67288. * @param format defines the texture format to use
  67289. * @param scene defines the hosting scene
  67290. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  67291. * @param invertY defines if texture must be stored with Y axis inverted
  67292. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67293. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  67294. */
  67295. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  67296. /** Gets or sets the texture format to use */
  67297. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  67298. /**
  67299. * Update the texture with new data
  67300. * @param data defines the data to store in the texture
  67301. */
  67302. update(data: ArrayBufferView): void;
  67303. }
  67304. }
  67305. declare module BABYLON {
  67306. /**
  67307. * Creates a refraction texture used by refraction channel of the standard material.
  67308. * It is like a mirror but to see through a material.
  67309. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67310. */
  67311. export class RefractionTexture extends RenderTargetTexture {
  67312. /**
  67313. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  67314. * 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.
  67315. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67316. */
  67317. refractionPlane: Plane;
  67318. /**
  67319. * Define how deep under the surface we should see.
  67320. */
  67321. depth: number;
  67322. /**
  67323. * Creates a refraction texture used by refraction channel of the standard material.
  67324. * It is like a mirror but to see through a material.
  67325. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  67326. * @param name Define the texture name
  67327. * @param size Define the size of the underlying texture
  67328. * @param scene Define the scene the refraction belongs to
  67329. * @param generateMipMaps Define if we need to generate mips level for the refraction
  67330. */
  67331. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  67332. /**
  67333. * Clone the refraction texture.
  67334. * @returns the cloned texture
  67335. */
  67336. clone(): RefractionTexture;
  67337. /**
  67338. * Serialize the texture to a JSON representation you could use in Parse later on
  67339. * @returns the serialized JSON representation
  67340. */
  67341. serialize(): any;
  67342. }
  67343. }
  67344. declare module BABYLON {
  67345. /**
  67346. * Block used to add support for vertex skinning (bones)
  67347. */
  67348. export class BonesBlock extends NodeMaterialBlock {
  67349. /**
  67350. * Creates a new BonesBlock
  67351. * @param name defines the block name
  67352. */
  67353. constructor(name: string);
  67354. /**
  67355. * Initialize the block and prepare the context for build
  67356. * @param state defines the state that will be used for the build
  67357. */
  67358. initialize(state: NodeMaterialBuildState): void;
  67359. /**
  67360. * Gets the current class name
  67361. * @returns the class name
  67362. */
  67363. getClassName(): string;
  67364. /**
  67365. * Gets the matrix indices input component
  67366. */
  67367. get matricesIndices(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the matrix weights input component
  67370. */
  67371. get matricesWeights(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the extra matrix indices input component
  67374. */
  67375. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the extra matrix weights input component
  67378. */
  67379. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the world input component
  67382. */
  67383. get world(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the output component
  67386. */
  67387. get output(): NodeMaterialConnectionPoint;
  67388. autoConfigure(material: NodeMaterial): void;
  67389. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67392. protected _buildBlock(state: NodeMaterialBuildState): this;
  67393. }
  67394. }
  67395. declare module BABYLON {
  67396. /**
  67397. * Block used to add support for instances
  67398. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67399. */
  67400. export class InstancesBlock extends NodeMaterialBlock {
  67401. /**
  67402. * Creates a new InstancesBlock
  67403. * @param name defines the block name
  67404. */
  67405. constructor(name: string);
  67406. /**
  67407. * Gets the current class name
  67408. * @returns the class name
  67409. */
  67410. getClassName(): string;
  67411. /**
  67412. * Gets the first world row input component
  67413. */
  67414. get world0(): NodeMaterialConnectionPoint;
  67415. /**
  67416. * Gets the second world row input component
  67417. */
  67418. get world1(): NodeMaterialConnectionPoint;
  67419. /**
  67420. * Gets the third world row input component
  67421. */
  67422. get world2(): NodeMaterialConnectionPoint;
  67423. /**
  67424. * Gets the forth world row input component
  67425. */
  67426. get world3(): NodeMaterialConnectionPoint;
  67427. /**
  67428. * Gets the world input component
  67429. */
  67430. get world(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the output component
  67433. */
  67434. get output(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the instanceID component
  67437. */
  67438. get instanceID(): NodeMaterialConnectionPoint;
  67439. autoConfigure(material: NodeMaterial): void;
  67440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67441. protected _buildBlock(state: NodeMaterialBuildState): this;
  67442. }
  67443. }
  67444. declare module BABYLON {
  67445. /**
  67446. * Block used to add morph targets support to vertex shader
  67447. */
  67448. export class MorphTargetsBlock extends NodeMaterialBlock {
  67449. private _repeatableContentAnchor;
  67450. /**
  67451. * Create a new MorphTargetsBlock
  67452. * @param name defines the block name
  67453. */
  67454. constructor(name: string);
  67455. /**
  67456. * Gets the current class name
  67457. * @returns the class name
  67458. */
  67459. getClassName(): string;
  67460. /**
  67461. * Gets the position input component
  67462. */
  67463. get position(): NodeMaterialConnectionPoint;
  67464. /**
  67465. * Gets the normal input component
  67466. */
  67467. get normal(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the tangent input component
  67470. */
  67471. get tangent(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the tangent input component
  67474. */
  67475. get uv(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the position output component
  67478. */
  67479. get positionOutput(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the normal output component
  67482. */
  67483. get normalOutput(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the tangent output component
  67486. */
  67487. get tangentOutput(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the tangent output component
  67490. */
  67491. get uvOutput(): NodeMaterialConnectionPoint;
  67492. initialize(state: NodeMaterialBuildState): void;
  67493. autoConfigure(material: NodeMaterial): void;
  67494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67495. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67496. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67497. protected _buildBlock(state: NodeMaterialBuildState): this;
  67498. }
  67499. }
  67500. declare module BABYLON {
  67501. /**
  67502. * Block used to get data information from a light
  67503. */
  67504. export class LightInformationBlock extends NodeMaterialBlock {
  67505. private _lightDataUniformName;
  67506. private _lightColorUniformName;
  67507. private _lightTypeDefineName;
  67508. /**
  67509. * Gets or sets the light associated with this block
  67510. */
  67511. light: Nullable<Light>;
  67512. /**
  67513. * Creates a new LightInformationBlock
  67514. * @param name defines the block name
  67515. */
  67516. constructor(name: string);
  67517. /**
  67518. * Gets the current class name
  67519. * @returns the class name
  67520. */
  67521. getClassName(): string;
  67522. /**
  67523. * Gets the world position input component
  67524. */
  67525. get worldPosition(): NodeMaterialConnectionPoint;
  67526. /**
  67527. * Gets the direction output component
  67528. */
  67529. get direction(): NodeMaterialConnectionPoint;
  67530. /**
  67531. * Gets the direction output component
  67532. */
  67533. get color(): NodeMaterialConnectionPoint;
  67534. /**
  67535. * Gets the direction output component
  67536. */
  67537. get intensity(): NodeMaterialConnectionPoint;
  67538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67540. protected _buildBlock(state: NodeMaterialBuildState): this;
  67541. serialize(): any;
  67542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67543. }
  67544. }
  67545. declare module BABYLON {
  67546. /**
  67547. * Block used to add image processing support to fragment shader
  67548. */
  67549. export class ImageProcessingBlock extends NodeMaterialBlock {
  67550. /**
  67551. * Create a new ImageProcessingBlock
  67552. * @param name defines the block name
  67553. */
  67554. constructor(name: string);
  67555. /**
  67556. * Gets the current class name
  67557. * @returns the class name
  67558. */
  67559. getClassName(): string;
  67560. /**
  67561. * Gets the color input component
  67562. */
  67563. get color(): NodeMaterialConnectionPoint;
  67564. /**
  67565. * Gets the output component
  67566. */
  67567. get output(): NodeMaterialConnectionPoint;
  67568. /**
  67569. * Initialize the block and prepare the context for build
  67570. * @param state defines the state that will be used for the build
  67571. */
  67572. initialize(state: NodeMaterialBuildState): void;
  67573. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67576. protected _buildBlock(state: NodeMaterialBuildState): this;
  67577. }
  67578. }
  67579. declare module BABYLON {
  67580. /**
  67581. * Block used to perturb normals based on a normal map
  67582. */
  67583. export class PerturbNormalBlock extends NodeMaterialBlock {
  67584. private _tangentSpaceParameterName;
  67585. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67586. invertX: boolean;
  67587. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67588. invertY: boolean;
  67589. /**
  67590. * Create a new PerturbNormalBlock
  67591. * @param name defines the block name
  67592. */
  67593. constructor(name: string);
  67594. /**
  67595. * Gets the current class name
  67596. * @returns the class name
  67597. */
  67598. getClassName(): string;
  67599. /**
  67600. * Gets the world position input component
  67601. */
  67602. get worldPosition(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the world normal input component
  67605. */
  67606. get worldNormal(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the world tangent input component
  67609. */
  67610. get worldTangent(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the uv input component
  67613. */
  67614. get uv(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the normal map color input component
  67617. */
  67618. get normalMapColor(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the strength input component
  67621. */
  67622. get strength(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the output component
  67625. */
  67626. get output(): NodeMaterialConnectionPoint;
  67627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67629. autoConfigure(material: NodeMaterial): void;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. protected _dumpPropertiesCode(): string;
  67632. serialize(): any;
  67633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /**
  67638. * Block used to discard a pixel if a value is smaller than a cutoff
  67639. */
  67640. export class DiscardBlock extends NodeMaterialBlock {
  67641. /**
  67642. * Create a new DiscardBlock
  67643. * @param name defines the block name
  67644. */
  67645. constructor(name: string);
  67646. /**
  67647. * Gets the current class name
  67648. * @returns the class name
  67649. */
  67650. getClassName(): string;
  67651. /**
  67652. * Gets the color input component
  67653. */
  67654. get value(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the cutoff input component
  67657. */
  67658. get cutoff(): NodeMaterialConnectionPoint;
  67659. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67660. }
  67661. }
  67662. declare module BABYLON {
  67663. /**
  67664. * Block used to test if the fragment shader is front facing
  67665. */
  67666. export class FrontFacingBlock extends NodeMaterialBlock {
  67667. /**
  67668. * Creates a new FrontFacingBlock
  67669. * @param name defines the block name
  67670. */
  67671. constructor(name: string);
  67672. /**
  67673. * Gets the current class name
  67674. * @returns the class name
  67675. */
  67676. getClassName(): string;
  67677. /**
  67678. * Gets the output component
  67679. */
  67680. get output(): NodeMaterialConnectionPoint;
  67681. protected _buildBlock(state: NodeMaterialBuildState): this;
  67682. }
  67683. }
  67684. declare module BABYLON {
  67685. /**
  67686. * Block used to get the derivative value on x and y of a given input
  67687. */
  67688. export class DerivativeBlock extends NodeMaterialBlock {
  67689. /**
  67690. * Create a new DerivativeBlock
  67691. * @param name defines the block name
  67692. */
  67693. constructor(name: string);
  67694. /**
  67695. * Gets the current class name
  67696. * @returns the class name
  67697. */
  67698. getClassName(): string;
  67699. /**
  67700. * Gets the input component
  67701. */
  67702. get input(): NodeMaterialConnectionPoint;
  67703. /**
  67704. * Gets the derivative output on x
  67705. */
  67706. get dx(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the derivative output on y
  67709. */
  67710. get dy(): NodeMaterialConnectionPoint;
  67711. protected _buildBlock(state: NodeMaterialBuildState): this;
  67712. }
  67713. }
  67714. declare module BABYLON {
  67715. /**
  67716. * Block used to make gl_FragCoord available
  67717. */
  67718. export class FragCoordBlock extends NodeMaterialBlock {
  67719. /**
  67720. * Creates a new FragCoordBlock
  67721. * @param name defines the block name
  67722. */
  67723. constructor(name: string);
  67724. /**
  67725. * Gets the current class name
  67726. * @returns the class name
  67727. */
  67728. getClassName(): string;
  67729. /**
  67730. * Gets the xy component
  67731. */
  67732. get xy(): NodeMaterialConnectionPoint;
  67733. /**
  67734. * Gets the xyz component
  67735. */
  67736. get xyz(): NodeMaterialConnectionPoint;
  67737. /**
  67738. * Gets the xyzw component
  67739. */
  67740. get xyzw(): NodeMaterialConnectionPoint;
  67741. /**
  67742. * Gets the x component
  67743. */
  67744. get x(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the y component
  67747. */
  67748. get y(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the z component
  67751. */
  67752. get z(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the w component
  67755. */
  67756. get output(): NodeMaterialConnectionPoint;
  67757. protected writeOutputs(state: NodeMaterialBuildState): string;
  67758. protected _buildBlock(state: NodeMaterialBuildState): this;
  67759. }
  67760. }
  67761. declare module BABYLON {
  67762. /**
  67763. * Block used to get the screen sizes
  67764. */
  67765. export class ScreenSizeBlock extends NodeMaterialBlock {
  67766. private _varName;
  67767. private _scene;
  67768. /**
  67769. * Creates a new ScreenSizeBlock
  67770. * @param name defines the block name
  67771. */
  67772. constructor(name: string);
  67773. /**
  67774. * Gets the current class name
  67775. * @returns the class name
  67776. */
  67777. getClassName(): string;
  67778. /**
  67779. * Gets the xy component
  67780. */
  67781. get xy(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the x component
  67784. */
  67785. get x(): NodeMaterialConnectionPoint;
  67786. /**
  67787. * Gets the y component
  67788. */
  67789. get y(): NodeMaterialConnectionPoint;
  67790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67791. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67792. protected _buildBlock(state: NodeMaterialBuildState): this;
  67793. }
  67794. }
  67795. declare module BABYLON {
  67796. /**
  67797. * Block used to add support for scene fog
  67798. */
  67799. export class FogBlock extends NodeMaterialBlock {
  67800. private _fogDistanceName;
  67801. private _fogParameters;
  67802. /**
  67803. * Create a new FogBlock
  67804. * @param name defines the block name
  67805. */
  67806. constructor(name: string);
  67807. /**
  67808. * Gets the current class name
  67809. * @returns the class name
  67810. */
  67811. getClassName(): string;
  67812. /**
  67813. * Gets the world position input component
  67814. */
  67815. get worldPosition(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the view input component
  67818. */
  67819. get view(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the color input component
  67822. */
  67823. get input(): NodeMaterialConnectionPoint;
  67824. /**
  67825. * Gets the fog color input component
  67826. */
  67827. get fogColor(): NodeMaterialConnectionPoint;
  67828. /**
  67829. * Gets the output component
  67830. */
  67831. get output(): NodeMaterialConnectionPoint;
  67832. autoConfigure(material: NodeMaterial): void;
  67833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67835. protected _buildBlock(state: NodeMaterialBuildState): this;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /**
  67840. * Block used to add light in the fragment shader
  67841. */
  67842. export class LightBlock extends NodeMaterialBlock {
  67843. private _lightId;
  67844. /**
  67845. * Gets or sets the light associated with this block
  67846. */
  67847. light: Nullable<Light>;
  67848. /**
  67849. * Create a new LightBlock
  67850. * @param name defines the block name
  67851. */
  67852. constructor(name: string);
  67853. /**
  67854. * Gets the current class name
  67855. * @returns the class name
  67856. */
  67857. getClassName(): string;
  67858. /**
  67859. * Gets the world position input component
  67860. */
  67861. get worldPosition(): NodeMaterialConnectionPoint;
  67862. /**
  67863. * Gets the world normal input component
  67864. */
  67865. get worldNormal(): NodeMaterialConnectionPoint;
  67866. /**
  67867. * Gets the camera (or eye) position component
  67868. */
  67869. get cameraPosition(): NodeMaterialConnectionPoint;
  67870. /**
  67871. * Gets the glossiness component
  67872. */
  67873. get glossiness(): NodeMaterialConnectionPoint;
  67874. /**
  67875. * Gets the glossiness power component
  67876. */
  67877. get glossPower(): NodeMaterialConnectionPoint;
  67878. /**
  67879. * Gets the diffuse color component
  67880. */
  67881. get diffuseColor(): NodeMaterialConnectionPoint;
  67882. /**
  67883. * Gets the specular color component
  67884. */
  67885. get specularColor(): NodeMaterialConnectionPoint;
  67886. /**
  67887. * Gets the view matrix component
  67888. */
  67889. get view(): NodeMaterialConnectionPoint;
  67890. /**
  67891. * Gets the diffuse output component
  67892. */
  67893. get diffuseOutput(): NodeMaterialConnectionPoint;
  67894. /**
  67895. * Gets the specular output component
  67896. */
  67897. get specularOutput(): NodeMaterialConnectionPoint;
  67898. /**
  67899. * Gets the shadow output component
  67900. */
  67901. get shadow(): NodeMaterialConnectionPoint;
  67902. autoConfigure(material: NodeMaterial): void;
  67903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67904. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67906. private _injectVertexCode;
  67907. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67908. serialize(): any;
  67909. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /**
  67914. * Block used to read a reflection texture from a sampler
  67915. */
  67916. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67917. /**
  67918. * Create a new ReflectionTextureBlock
  67919. * @param name defines the block name
  67920. */
  67921. constructor(name: string);
  67922. /**
  67923. * Gets the current class name
  67924. * @returns the class name
  67925. */
  67926. getClassName(): string;
  67927. /**
  67928. * Gets the world position input component
  67929. */
  67930. get position(): NodeMaterialConnectionPoint;
  67931. /**
  67932. * Gets the world position input component
  67933. */
  67934. get worldPosition(): NodeMaterialConnectionPoint;
  67935. /**
  67936. * Gets the world normal input component
  67937. */
  67938. get worldNormal(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the world input component
  67941. */
  67942. get world(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the camera (or eye) position component
  67945. */
  67946. get cameraPosition(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the view input component
  67949. */
  67950. get view(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the rgb output component
  67953. */
  67954. get rgb(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the rgba output component
  67957. */
  67958. get rgba(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the r output component
  67961. */
  67962. get r(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the g output component
  67965. */
  67966. get g(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the b output component
  67969. */
  67970. get b(): NodeMaterialConnectionPoint;
  67971. /**
  67972. * Gets the a output component
  67973. */
  67974. get a(): NodeMaterialConnectionPoint;
  67975. autoConfigure(material: NodeMaterial): void;
  67976. protected _buildBlock(state: NodeMaterialBuildState): this;
  67977. }
  67978. }
  67979. declare module BABYLON {
  67980. /**
  67981. * Block used to add 2 vectors
  67982. */
  67983. export class AddBlock extends NodeMaterialBlock {
  67984. /**
  67985. * Creates a new AddBlock
  67986. * @param name defines the block name
  67987. */
  67988. constructor(name: string);
  67989. /**
  67990. * Gets the current class name
  67991. * @returns the class name
  67992. */
  67993. getClassName(): string;
  67994. /**
  67995. * Gets the left operand input component
  67996. */
  67997. get left(): NodeMaterialConnectionPoint;
  67998. /**
  67999. * Gets the right operand input component
  68000. */
  68001. get right(): NodeMaterialConnectionPoint;
  68002. /**
  68003. * Gets the output component
  68004. */
  68005. get output(): NodeMaterialConnectionPoint;
  68006. protected _buildBlock(state: NodeMaterialBuildState): this;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /**
  68011. * Block used to scale a vector by a float
  68012. */
  68013. export class ScaleBlock extends NodeMaterialBlock {
  68014. /**
  68015. * Creates a new ScaleBlock
  68016. * @param name defines the block name
  68017. */
  68018. constructor(name: string);
  68019. /**
  68020. * Gets the current class name
  68021. * @returns the class name
  68022. */
  68023. getClassName(): string;
  68024. /**
  68025. * Gets the input component
  68026. */
  68027. get input(): NodeMaterialConnectionPoint;
  68028. /**
  68029. * Gets the factor input component
  68030. */
  68031. get factor(): NodeMaterialConnectionPoint;
  68032. /**
  68033. * Gets the output component
  68034. */
  68035. get output(): NodeMaterialConnectionPoint;
  68036. protected _buildBlock(state: NodeMaterialBuildState): this;
  68037. }
  68038. }
  68039. declare module BABYLON {
  68040. /**
  68041. * Block used to clamp a float
  68042. */
  68043. export class ClampBlock extends NodeMaterialBlock {
  68044. /** Gets or sets the minimum range */
  68045. minimum: number;
  68046. /** Gets or sets the maximum range */
  68047. maximum: number;
  68048. /**
  68049. * Creates a new ClampBlock
  68050. * @param name defines the block name
  68051. */
  68052. constructor(name: string);
  68053. /**
  68054. * Gets the current class name
  68055. * @returns the class name
  68056. */
  68057. getClassName(): string;
  68058. /**
  68059. * Gets the value input component
  68060. */
  68061. get value(): NodeMaterialConnectionPoint;
  68062. /**
  68063. * Gets the output component
  68064. */
  68065. get output(): NodeMaterialConnectionPoint;
  68066. protected _buildBlock(state: NodeMaterialBuildState): this;
  68067. protected _dumpPropertiesCode(): string;
  68068. serialize(): any;
  68069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68070. }
  68071. }
  68072. declare module BABYLON {
  68073. /**
  68074. * Block used to apply a cross product between 2 vectors
  68075. */
  68076. export class CrossBlock extends NodeMaterialBlock {
  68077. /**
  68078. * Creates a new CrossBlock
  68079. * @param name defines the block name
  68080. */
  68081. constructor(name: string);
  68082. /**
  68083. * Gets the current class name
  68084. * @returns the class name
  68085. */
  68086. getClassName(): string;
  68087. /**
  68088. * Gets the left operand input component
  68089. */
  68090. get left(): NodeMaterialConnectionPoint;
  68091. /**
  68092. * Gets the right operand input component
  68093. */
  68094. get right(): NodeMaterialConnectionPoint;
  68095. /**
  68096. * Gets the output component
  68097. */
  68098. get output(): NodeMaterialConnectionPoint;
  68099. protected _buildBlock(state: NodeMaterialBuildState): this;
  68100. }
  68101. }
  68102. declare module BABYLON {
  68103. /**
  68104. * Block used to apply a dot product between 2 vectors
  68105. */
  68106. export class DotBlock extends NodeMaterialBlock {
  68107. /**
  68108. * Creates a new DotBlock
  68109. * @param name defines the block name
  68110. */
  68111. constructor(name: string);
  68112. /**
  68113. * Gets the current class name
  68114. * @returns the class name
  68115. */
  68116. getClassName(): string;
  68117. /**
  68118. * Gets the left operand input component
  68119. */
  68120. get left(): NodeMaterialConnectionPoint;
  68121. /**
  68122. * Gets the right operand input component
  68123. */
  68124. get right(): NodeMaterialConnectionPoint;
  68125. /**
  68126. * Gets the output component
  68127. */
  68128. get output(): NodeMaterialConnectionPoint;
  68129. protected _buildBlock(state: NodeMaterialBuildState): this;
  68130. }
  68131. }
  68132. declare module BABYLON {
  68133. /**
  68134. * Block used to normalize a vector
  68135. */
  68136. export class NormalizeBlock extends NodeMaterialBlock {
  68137. /**
  68138. * Creates a new NormalizeBlock
  68139. * @param name defines the block name
  68140. */
  68141. constructor(name: string);
  68142. /**
  68143. * Gets the current class name
  68144. * @returns the class name
  68145. */
  68146. getClassName(): string;
  68147. /**
  68148. * Gets the input component
  68149. */
  68150. get input(): NodeMaterialConnectionPoint;
  68151. /**
  68152. * Gets the output component
  68153. */
  68154. get output(): NodeMaterialConnectionPoint;
  68155. protected _buildBlock(state: NodeMaterialBuildState): this;
  68156. }
  68157. }
  68158. declare module BABYLON {
  68159. /**
  68160. * Block used to create a Color3/4 out of individual inputs (one for each component)
  68161. */
  68162. export class ColorMergerBlock extends NodeMaterialBlock {
  68163. /**
  68164. * Create a new ColorMergerBlock
  68165. * @param name defines the block name
  68166. */
  68167. constructor(name: string);
  68168. /**
  68169. * Gets the current class name
  68170. * @returns the class name
  68171. */
  68172. getClassName(): string;
  68173. /**
  68174. * Gets the rgb component (input)
  68175. */
  68176. get rgbIn(): NodeMaterialConnectionPoint;
  68177. /**
  68178. * Gets the r component (input)
  68179. */
  68180. get r(): NodeMaterialConnectionPoint;
  68181. /**
  68182. * Gets the g component (input)
  68183. */
  68184. get g(): NodeMaterialConnectionPoint;
  68185. /**
  68186. * Gets the b component (input)
  68187. */
  68188. get b(): NodeMaterialConnectionPoint;
  68189. /**
  68190. * Gets the a component (input)
  68191. */
  68192. get a(): NodeMaterialConnectionPoint;
  68193. /**
  68194. * Gets the rgba component (output)
  68195. */
  68196. get rgba(): NodeMaterialConnectionPoint;
  68197. /**
  68198. * Gets the rgb component (output)
  68199. */
  68200. get rgbOut(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the rgb component (output)
  68203. * @deprecated Please use rgbOut instead.
  68204. */
  68205. get rgb(): NodeMaterialConnectionPoint;
  68206. protected _buildBlock(state: NodeMaterialBuildState): this;
  68207. }
  68208. }
  68209. declare module BABYLON {
  68210. /**
  68211. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68212. */
  68213. export class VectorSplitterBlock extends NodeMaterialBlock {
  68214. /**
  68215. * Create a new VectorSplitterBlock
  68216. * @param name defines the block name
  68217. */
  68218. constructor(name: string);
  68219. /**
  68220. * Gets the current class name
  68221. * @returns the class name
  68222. */
  68223. getClassName(): string;
  68224. /**
  68225. * Gets the xyzw component (input)
  68226. */
  68227. get xyzw(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the xyz component (input)
  68230. */
  68231. get xyzIn(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the xy component (input)
  68234. */
  68235. get xyIn(): NodeMaterialConnectionPoint;
  68236. /**
  68237. * Gets the xyz component (output)
  68238. */
  68239. get xyzOut(): NodeMaterialConnectionPoint;
  68240. /**
  68241. * Gets the xy component (output)
  68242. */
  68243. get xyOut(): NodeMaterialConnectionPoint;
  68244. /**
  68245. * Gets the x component (output)
  68246. */
  68247. get x(): NodeMaterialConnectionPoint;
  68248. /**
  68249. * Gets the y component (output)
  68250. */
  68251. get y(): NodeMaterialConnectionPoint;
  68252. /**
  68253. * Gets the z component (output)
  68254. */
  68255. get z(): NodeMaterialConnectionPoint;
  68256. /**
  68257. * Gets the w component (output)
  68258. */
  68259. get w(): NodeMaterialConnectionPoint;
  68260. protected _inputRename(name: string): string;
  68261. protected _outputRename(name: string): string;
  68262. protected _buildBlock(state: NodeMaterialBuildState): this;
  68263. }
  68264. }
  68265. declare module BABYLON {
  68266. /**
  68267. * Block used to lerp between 2 values
  68268. */
  68269. export class LerpBlock extends NodeMaterialBlock {
  68270. /**
  68271. * Creates a new LerpBlock
  68272. * @param name defines the block name
  68273. */
  68274. constructor(name: string);
  68275. /**
  68276. * Gets the current class name
  68277. * @returns the class name
  68278. */
  68279. getClassName(): string;
  68280. /**
  68281. * Gets the left operand input component
  68282. */
  68283. get left(): NodeMaterialConnectionPoint;
  68284. /**
  68285. * Gets the right operand input component
  68286. */
  68287. get right(): NodeMaterialConnectionPoint;
  68288. /**
  68289. * Gets the gradient operand input component
  68290. */
  68291. get gradient(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the output component
  68294. */
  68295. get output(): NodeMaterialConnectionPoint;
  68296. protected _buildBlock(state: NodeMaterialBuildState): this;
  68297. }
  68298. }
  68299. declare module BABYLON {
  68300. /**
  68301. * Block used to divide 2 vectors
  68302. */
  68303. export class DivideBlock extends NodeMaterialBlock {
  68304. /**
  68305. * Creates a new DivideBlock
  68306. * @param name defines the block name
  68307. */
  68308. constructor(name: string);
  68309. /**
  68310. * Gets the current class name
  68311. * @returns the class name
  68312. */
  68313. getClassName(): string;
  68314. /**
  68315. * Gets the left operand input component
  68316. */
  68317. get left(): NodeMaterialConnectionPoint;
  68318. /**
  68319. * Gets the right operand input component
  68320. */
  68321. get right(): NodeMaterialConnectionPoint;
  68322. /**
  68323. * Gets the output component
  68324. */
  68325. get output(): NodeMaterialConnectionPoint;
  68326. protected _buildBlock(state: NodeMaterialBuildState): this;
  68327. }
  68328. }
  68329. declare module BABYLON {
  68330. /**
  68331. * Block used to subtract 2 vectors
  68332. */
  68333. export class SubtractBlock extends NodeMaterialBlock {
  68334. /**
  68335. * Creates a new SubtractBlock
  68336. * @param name defines the block name
  68337. */
  68338. constructor(name: string);
  68339. /**
  68340. * Gets the current class name
  68341. * @returns the class name
  68342. */
  68343. getClassName(): string;
  68344. /**
  68345. * Gets the left operand input component
  68346. */
  68347. get left(): NodeMaterialConnectionPoint;
  68348. /**
  68349. * Gets the right operand input component
  68350. */
  68351. get right(): NodeMaterialConnectionPoint;
  68352. /**
  68353. * Gets the output component
  68354. */
  68355. get output(): NodeMaterialConnectionPoint;
  68356. protected _buildBlock(state: NodeMaterialBuildState): this;
  68357. }
  68358. }
  68359. declare module BABYLON {
  68360. /**
  68361. * Block used to step a value
  68362. */
  68363. export class StepBlock extends NodeMaterialBlock {
  68364. /**
  68365. * Creates a new StepBlock
  68366. * @param name defines the block name
  68367. */
  68368. constructor(name: string);
  68369. /**
  68370. * Gets the current class name
  68371. * @returns the class name
  68372. */
  68373. getClassName(): string;
  68374. /**
  68375. * Gets the value operand input component
  68376. */
  68377. get value(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the edge operand input component
  68380. */
  68381. get edge(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the output component
  68384. */
  68385. get output(): NodeMaterialConnectionPoint;
  68386. protected _buildBlock(state: NodeMaterialBuildState): this;
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /**
  68391. * Block used to get the opposite (1 - x) of a value
  68392. */
  68393. export class OneMinusBlock extends NodeMaterialBlock {
  68394. /**
  68395. * Creates a new OneMinusBlock
  68396. * @param name defines the block name
  68397. */
  68398. constructor(name: string);
  68399. /**
  68400. * Gets the current class name
  68401. * @returns the class name
  68402. */
  68403. getClassName(): string;
  68404. /**
  68405. * Gets the input component
  68406. */
  68407. get input(): NodeMaterialConnectionPoint;
  68408. /**
  68409. * Gets the output component
  68410. */
  68411. get output(): NodeMaterialConnectionPoint;
  68412. protected _buildBlock(state: NodeMaterialBuildState): this;
  68413. }
  68414. }
  68415. declare module BABYLON {
  68416. /**
  68417. * Block used to get the view direction
  68418. */
  68419. export class ViewDirectionBlock extends NodeMaterialBlock {
  68420. /**
  68421. * Creates a new ViewDirectionBlock
  68422. * @param name defines the block name
  68423. */
  68424. constructor(name: string);
  68425. /**
  68426. * Gets the current class name
  68427. * @returns the class name
  68428. */
  68429. getClassName(): string;
  68430. /**
  68431. * Gets the world position component
  68432. */
  68433. get worldPosition(): NodeMaterialConnectionPoint;
  68434. /**
  68435. * Gets the camera position component
  68436. */
  68437. get cameraPosition(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Gets the output component
  68440. */
  68441. get output(): NodeMaterialConnectionPoint;
  68442. autoConfigure(material: NodeMaterial): void;
  68443. protected _buildBlock(state: NodeMaterialBuildState): this;
  68444. }
  68445. }
  68446. declare module BABYLON {
  68447. /**
  68448. * Block used to compute fresnel value
  68449. */
  68450. export class FresnelBlock extends NodeMaterialBlock {
  68451. /**
  68452. * Create a new FresnelBlock
  68453. * @param name defines the block name
  68454. */
  68455. constructor(name: string);
  68456. /**
  68457. * Gets the current class name
  68458. * @returns the class name
  68459. */
  68460. getClassName(): string;
  68461. /**
  68462. * Gets the world normal input component
  68463. */
  68464. get worldNormal(): NodeMaterialConnectionPoint;
  68465. /**
  68466. * Gets the view direction input component
  68467. */
  68468. get viewDirection(): NodeMaterialConnectionPoint;
  68469. /**
  68470. * Gets the bias input component
  68471. */
  68472. get bias(): NodeMaterialConnectionPoint;
  68473. /**
  68474. * Gets the camera (or eye) position component
  68475. */
  68476. get power(): NodeMaterialConnectionPoint;
  68477. /**
  68478. * Gets the fresnel output component
  68479. */
  68480. get fresnel(): NodeMaterialConnectionPoint;
  68481. autoConfigure(material: NodeMaterial): void;
  68482. protected _buildBlock(state: NodeMaterialBuildState): this;
  68483. }
  68484. }
  68485. declare module BABYLON {
  68486. /**
  68487. * Block used to get the max of 2 values
  68488. */
  68489. export class MaxBlock extends NodeMaterialBlock {
  68490. /**
  68491. * Creates a new MaxBlock
  68492. * @param name defines the block name
  68493. */
  68494. constructor(name: string);
  68495. /**
  68496. * Gets the current class name
  68497. * @returns the class name
  68498. */
  68499. getClassName(): string;
  68500. /**
  68501. * Gets the left operand input component
  68502. */
  68503. get left(): NodeMaterialConnectionPoint;
  68504. /**
  68505. * Gets the right operand input component
  68506. */
  68507. get right(): NodeMaterialConnectionPoint;
  68508. /**
  68509. * Gets the output component
  68510. */
  68511. get output(): NodeMaterialConnectionPoint;
  68512. protected _buildBlock(state: NodeMaterialBuildState): this;
  68513. }
  68514. }
  68515. declare module BABYLON {
  68516. /**
  68517. * Block used to get the min of 2 values
  68518. */
  68519. export class MinBlock extends NodeMaterialBlock {
  68520. /**
  68521. * Creates a new MinBlock
  68522. * @param name defines the block name
  68523. */
  68524. constructor(name: string);
  68525. /**
  68526. * Gets the current class name
  68527. * @returns the class name
  68528. */
  68529. getClassName(): string;
  68530. /**
  68531. * Gets the left operand input component
  68532. */
  68533. get left(): NodeMaterialConnectionPoint;
  68534. /**
  68535. * Gets the right operand input component
  68536. */
  68537. get right(): NodeMaterialConnectionPoint;
  68538. /**
  68539. * Gets the output component
  68540. */
  68541. get output(): NodeMaterialConnectionPoint;
  68542. protected _buildBlock(state: NodeMaterialBuildState): this;
  68543. }
  68544. }
  68545. declare module BABYLON {
  68546. /**
  68547. * Block used to get the distance between 2 values
  68548. */
  68549. export class DistanceBlock extends NodeMaterialBlock {
  68550. /**
  68551. * Creates a new DistanceBlock
  68552. * @param name defines the block name
  68553. */
  68554. constructor(name: string);
  68555. /**
  68556. * Gets the current class name
  68557. * @returns the class name
  68558. */
  68559. getClassName(): string;
  68560. /**
  68561. * Gets the left operand input component
  68562. */
  68563. get left(): NodeMaterialConnectionPoint;
  68564. /**
  68565. * Gets the right operand input component
  68566. */
  68567. get right(): NodeMaterialConnectionPoint;
  68568. /**
  68569. * Gets the output component
  68570. */
  68571. get output(): NodeMaterialConnectionPoint;
  68572. protected _buildBlock(state: NodeMaterialBuildState): this;
  68573. }
  68574. }
  68575. declare module BABYLON {
  68576. /**
  68577. * Block used to get the length of a vector
  68578. */
  68579. export class LengthBlock extends NodeMaterialBlock {
  68580. /**
  68581. * Creates a new LengthBlock
  68582. * @param name defines the block name
  68583. */
  68584. constructor(name: string);
  68585. /**
  68586. * Gets the current class name
  68587. * @returns the class name
  68588. */
  68589. getClassName(): string;
  68590. /**
  68591. * Gets the value input component
  68592. */
  68593. get value(): NodeMaterialConnectionPoint;
  68594. /**
  68595. * Gets the output component
  68596. */
  68597. get output(): NodeMaterialConnectionPoint;
  68598. protected _buildBlock(state: NodeMaterialBuildState): this;
  68599. }
  68600. }
  68601. declare module BABYLON {
  68602. /**
  68603. * Block used to get negative version of a value (i.e. x * -1)
  68604. */
  68605. export class NegateBlock extends NodeMaterialBlock {
  68606. /**
  68607. * Creates a new NegateBlock
  68608. * @param name defines the block name
  68609. */
  68610. constructor(name: string);
  68611. /**
  68612. * Gets the current class name
  68613. * @returns the class name
  68614. */
  68615. getClassName(): string;
  68616. /**
  68617. * Gets the value input component
  68618. */
  68619. get value(): NodeMaterialConnectionPoint;
  68620. /**
  68621. * Gets the output component
  68622. */
  68623. get output(): NodeMaterialConnectionPoint;
  68624. protected _buildBlock(state: NodeMaterialBuildState): this;
  68625. }
  68626. }
  68627. declare module BABYLON {
  68628. /**
  68629. * Block used to get the value of the first parameter raised to the power of the second
  68630. */
  68631. export class PowBlock extends NodeMaterialBlock {
  68632. /**
  68633. * Creates a new PowBlock
  68634. * @param name defines the block name
  68635. */
  68636. constructor(name: string);
  68637. /**
  68638. * Gets the current class name
  68639. * @returns the class name
  68640. */
  68641. getClassName(): string;
  68642. /**
  68643. * Gets the value operand input component
  68644. */
  68645. get value(): NodeMaterialConnectionPoint;
  68646. /**
  68647. * Gets the power operand input component
  68648. */
  68649. get power(): NodeMaterialConnectionPoint;
  68650. /**
  68651. * Gets the output component
  68652. */
  68653. get output(): NodeMaterialConnectionPoint;
  68654. protected _buildBlock(state: NodeMaterialBuildState): this;
  68655. }
  68656. }
  68657. declare module BABYLON {
  68658. /**
  68659. * Block used to get a random number
  68660. */
  68661. export class RandomNumberBlock extends NodeMaterialBlock {
  68662. /**
  68663. * Creates a new RandomNumberBlock
  68664. * @param name defines the block name
  68665. */
  68666. constructor(name: string);
  68667. /**
  68668. * Gets the current class name
  68669. * @returns the class name
  68670. */
  68671. getClassName(): string;
  68672. /**
  68673. * Gets the seed input component
  68674. */
  68675. get seed(): NodeMaterialConnectionPoint;
  68676. /**
  68677. * Gets the output component
  68678. */
  68679. get output(): NodeMaterialConnectionPoint;
  68680. protected _buildBlock(state: NodeMaterialBuildState): this;
  68681. }
  68682. }
  68683. declare module BABYLON {
  68684. /**
  68685. * Block used to compute arc tangent of 2 values
  68686. */
  68687. export class ArcTan2Block extends NodeMaterialBlock {
  68688. /**
  68689. * Creates a new ArcTan2Block
  68690. * @param name defines the block name
  68691. */
  68692. constructor(name: string);
  68693. /**
  68694. * Gets the current class name
  68695. * @returns the class name
  68696. */
  68697. getClassName(): string;
  68698. /**
  68699. * Gets the x operand input component
  68700. */
  68701. get x(): NodeMaterialConnectionPoint;
  68702. /**
  68703. * Gets the y operand input component
  68704. */
  68705. get y(): NodeMaterialConnectionPoint;
  68706. /**
  68707. * Gets the output component
  68708. */
  68709. get output(): NodeMaterialConnectionPoint;
  68710. protected _buildBlock(state: NodeMaterialBuildState): this;
  68711. }
  68712. }
  68713. declare module BABYLON {
  68714. /**
  68715. * Block used to smooth step a value
  68716. */
  68717. export class SmoothStepBlock extends NodeMaterialBlock {
  68718. /**
  68719. * Creates a new SmoothStepBlock
  68720. * @param name defines the block name
  68721. */
  68722. constructor(name: string);
  68723. /**
  68724. * Gets the current class name
  68725. * @returns the class name
  68726. */
  68727. getClassName(): string;
  68728. /**
  68729. * Gets the value operand input component
  68730. */
  68731. get value(): NodeMaterialConnectionPoint;
  68732. /**
  68733. * Gets the first edge operand input component
  68734. */
  68735. get edge0(): NodeMaterialConnectionPoint;
  68736. /**
  68737. * Gets the second edge operand input component
  68738. */
  68739. get edge1(): NodeMaterialConnectionPoint;
  68740. /**
  68741. * Gets the output component
  68742. */
  68743. get output(): NodeMaterialConnectionPoint;
  68744. protected _buildBlock(state: NodeMaterialBuildState): this;
  68745. }
  68746. }
  68747. declare module BABYLON {
  68748. /**
  68749. * Block used to get the reciprocal (1 / x) of a value
  68750. */
  68751. export class ReciprocalBlock extends NodeMaterialBlock {
  68752. /**
  68753. * Creates a new ReciprocalBlock
  68754. * @param name defines the block name
  68755. */
  68756. constructor(name: string);
  68757. /**
  68758. * Gets the current class name
  68759. * @returns the class name
  68760. */
  68761. getClassName(): string;
  68762. /**
  68763. * Gets the input component
  68764. */
  68765. get input(): NodeMaterialConnectionPoint;
  68766. /**
  68767. * Gets the output component
  68768. */
  68769. get output(): NodeMaterialConnectionPoint;
  68770. protected _buildBlock(state: NodeMaterialBuildState): this;
  68771. }
  68772. }
  68773. declare module BABYLON {
  68774. /**
  68775. * Block used to replace a color by another one
  68776. */
  68777. export class ReplaceColorBlock extends NodeMaterialBlock {
  68778. /**
  68779. * Creates a new ReplaceColorBlock
  68780. * @param name defines the block name
  68781. */
  68782. constructor(name: string);
  68783. /**
  68784. * Gets the current class name
  68785. * @returns the class name
  68786. */
  68787. getClassName(): string;
  68788. /**
  68789. * Gets the value input component
  68790. */
  68791. get value(): NodeMaterialConnectionPoint;
  68792. /**
  68793. * Gets the reference input component
  68794. */
  68795. get reference(): NodeMaterialConnectionPoint;
  68796. /**
  68797. * Gets the distance input component
  68798. */
  68799. get distance(): NodeMaterialConnectionPoint;
  68800. /**
  68801. * Gets the replacement input component
  68802. */
  68803. get replacement(): NodeMaterialConnectionPoint;
  68804. /**
  68805. * Gets the output component
  68806. */
  68807. get output(): NodeMaterialConnectionPoint;
  68808. protected _buildBlock(state: NodeMaterialBuildState): this;
  68809. }
  68810. }
  68811. declare module BABYLON {
  68812. /**
  68813. * Block used to posterize a value
  68814. * @see https://en.wikipedia.org/wiki/Posterization
  68815. */
  68816. export class PosterizeBlock extends NodeMaterialBlock {
  68817. /**
  68818. * Creates a new PosterizeBlock
  68819. * @param name defines the block name
  68820. */
  68821. constructor(name: string);
  68822. /**
  68823. * Gets the current class name
  68824. * @returns the class name
  68825. */
  68826. getClassName(): string;
  68827. /**
  68828. * Gets the value input component
  68829. */
  68830. get value(): NodeMaterialConnectionPoint;
  68831. /**
  68832. * Gets the steps input component
  68833. */
  68834. get steps(): NodeMaterialConnectionPoint;
  68835. /**
  68836. * Gets the output component
  68837. */
  68838. get output(): NodeMaterialConnectionPoint;
  68839. protected _buildBlock(state: NodeMaterialBuildState): this;
  68840. }
  68841. }
  68842. declare module BABYLON {
  68843. /**
  68844. * Operations supported by the Wave block
  68845. */
  68846. export enum WaveBlockKind {
  68847. /** SawTooth */
  68848. SawTooth = 0,
  68849. /** Square */
  68850. Square = 1,
  68851. /** Triangle */
  68852. Triangle = 2
  68853. }
  68854. /**
  68855. * Block used to apply wave operation to floats
  68856. */
  68857. export class WaveBlock extends NodeMaterialBlock {
  68858. /**
  68859. * Gets or sets the kibnd of wave to be applied by the block
  68860. */
  68861. kind: WaveBlockKind;
  68862. /**
  68863. * Creates a new WaveBlock
  68864. * @param name defines the block name
  68865. */
  68866. constructor(name: string);
  68867. /**
  68868. * Gets the current class name
  68869. * @returns the class name
  68870. */
  68871. getClassName(): string;
  68872. /**
  68873. * Gets the input component
  68874. */
  68875. get input(): NodeMaterialConnectionPoint;
  68876. /**
  68877. * Gets the output component
  68878. */
  68879. get output(): NodeMaterialConnectionPoint;
  68880. protected _buildBlock(state: NodeMaterialBuildState): this;
  68881. serialize(): any;
  68882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68883. }
  68884. }
  68885. declare module BABYLON {
  68886. /**
  68887. * Class used to store a color step for the GradientBlock
  68888. */
  68889. export class GradientBlockColorStep {
  68890. private _step;
  68891. /**
  68892. * Gets value indicating which step this color is associated with (between 0 and 1)
  68893. */
  68894. get step(): number;
  68895. /**
  68896. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68897. */
  68898. set step(val: number);
  68899. private _color;
  68900. /**
  68901. * Gets the color associated with this step
  68902. */
  68903. get color(): Color3;
  68904. /**
  68905. * Sets the color associated with this step
  68906. */
  68907. set color(val: Color3);
  68908. /**
  68909. * Creates a new GradientBlockColorStep
  68910. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68911. * @param color defines the color associated with this step
  68912. */
  68913. constructor(step: number, color: Color3);
  68914. }
  68915. /**
  68916. * Block used to return a color from a gradient based on an input value between 0 and 1
  68917. */
  68918. export class GradientBlock extends NodeMaterialBlock {
  68919. /**
  68920. * Gets or sets the list of color steps
  68921. */
  68922. colorSteps: GradientBlockColorStep[];
  68923. /** Gets an observable raised when the value is changed */
  68924. onValueChangedObservable: Observable<GradientBlock>;
  68925. /** calls observable when the value is changed*/
  68926. colorStepsUpdated(): void;
  68927. /**
  68928. * Creates a new GradientBlock
  68929. * @param name defines the block name
  68930. */
  68931. constructor(name: string);
  68932. /**
  68933. * Gets the current class name
  68934. * @returns the class name
  68935. */
  68936. getClassName(): string;
  68937. /**
  68938. * Gets the gradient input component
  68939. */
  68940. get gradient(): NodeMaterialConnectionPoint;
  68941. /**
  68942. * Gets the output component
  68943. */
  68944. get output(): NodeMaterialConnectionPoint;
  68945. private _writeColorConstant;
  68946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68947. serialize(): any;
  68948. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68949. protected _dumpPropertiesCode(): string;
  68950. }
  68951. }
  68952. declare module BABYLON {
  68953. /**
  68954. * Block used to normalize lerp between 2 values
  68955. */
  68956. export class NLerpBlock extends NodeMaterialBlock {
  68957. /**
  68958. * Creates a new NLerpBlock
  68959. * @param name defines the block name
  68960. */
  68961. constructor(name: string);
  68962. /**
  68963. * Gets the current class name
  68964. * @returns the class name
  68965. */
  68966. getClassName(): string;
  68967. /**
  68968. * Gets the left operand input component
  68969. */
  68970. get left(): NodeMaterialConnectionPoint;
  68971. /**
  68972. * Gets the right operand input component
  68973. */
  68974. get right(): NodeMaterialConnectionPoint;
  68975. /**
  68976. * Gets the gradient operand input component
  68977. */
  68978. get gradient(): NodeMaterialConnectionPoint;
  68979. /**
  68980. * Gets the output component
  68981. */
  68982. get output(): NodeMaterialConnectionPoint;
  68983. protected _buildBlock(state: NodeMaterialBuildState): this;
  68984. }
  68985. }
  68986. declare module BABYLON {
  68987. /**
  68988. * block used to Generate a Worley Noise 3D Noise Pattern
  68989. */
  68990. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68991. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68992. manhattanDistance: boolean;
  68993. /**
  68994. * Creates a new WorleyNoise3DBlock
  68995. * @param name defines the block name
  68996. */
  68997. constructor(name: string);
  68998. /**
  68999. * Gets the current class name
  69000. * @returns the class name
  69001. */
  69002. getClassName(): string;
  69003. /**
  69004. * Gets the seed input component
  69005. */
  69006. get seed(): NodeMaterialConnectionPoint;
  69007. /**
  69008. * Gets the jitter input component
  69009. */
  69010. get jitter(): NodeMaterialConnectionPoint;
  69011. /**
  69012. * Gets the output component
  69013. */
  69014. get output(): NodeMaterialConnectionPoint;
  69015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69016. /**
  69017. * Exposes the properties to the UI?
  69018. */
  69019. protected _dumpPropertiesCode(): string;
  69020. /**
  69021. * Exposes the properties to the Serialize?
  69022. */
  69023. serialize(): any;
  69024. /**
  69025. * Exposes the properties to the deserialize?
  69026. */
  69027. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /**
  69032. * block used to Generate a Simplex Perlin 3d Noise Pattern
  69033. */
  69034. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  69035. /**
  69036. * Creates a new SimplexPerlin3DBlock
  69037. * @param name defines the block name
  69038. */
  69039. constructor(name: string);
  69040. /**
  69041. * Gets the current class name
  69042. * @returns the class name
  69043. */
  69044. getClassName(): string;
  69045. /**
  69046. * Gets the seed operand input component
  69047. */
  69048. get seed(): NodeMaterialConnectionPoint;
  69049. /**
  69050. * Gets the output component
  69051. */
  69052. get output(): NodeMaterialConnectionPoint;
  69053. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  69054. }
  69055. }
  69056. declare module BABYLON {
  69057. /**
  69058. * Block used to blend normals
  69059. */
  69060. export class NormalBlendBlock extends NodeMaterialBlock {
  69061. /**
  69062. * Creates a new NormalBlendBlock
  69063. * @param name defines the block name
  69064. */
  69065. constructor(name: string);
  69066. /**
  69067. * Gets the current class name
  69068. * @returns the class name
  69069. */
  69070. getClassName(): string;
  69071. /**
  69072. * Gets the first input component
  69073. */
  69074. get normalMap0(): NodeMaterialConnectionPoint;
  69075. /**
  69076. * Gets the second input component
  69077. */
  69078. get normalMap1(): NodeMaterialConnectionPoint;
  69079. /**
  69080. * Gets the output component
  69081. */
  69082. get output(): NodeMaterialConnectionPoint;
  69083. protected _buildBlock(state: NodeMaterialBuildState): this;
  69084. }
  69085. }
  69086. declare module BABYLON {
  69087. /**
  69088. * Block used to rotate a 2d vector by a given angle
  69089. */
  69090. export class Rotate2dBlock extends NodeMaterialBlock {
  69091. /**
  69092. * Creates a new Rotate2dBlock
  69093. * @param name defines the block name
  69094. */
  69095. constructor(name: string);
  69096. /**
  69097. * Gets the current class name
  69098. * @returns the class name
  69099. */
  69100. getClassName(): string;
  69101. /**
  69102. * Gets the input vector
  69103. */
  69104. get input(): NodeMaterialConnectionPoint;
  69105. /**
  69106. * Gets the input angle
  69107. */
  69108. get angle(): NodeMaterialConnectionPoint;
  69109. /**
  69110. * Gets the output component
  69111. */
  69112. get output(): NodeMaterialConnectionPoint;
  69113. autoConfigure(material: NodeMaterial): void;
  69114. protected _buildBlock(state: NodeMaterialBuildState): this;
  69115. }
  69116. }
  69117. declare module BABYLON {
  69118. /**
  69119. * Block used to get the reflected vector from a direction and a normal
  69120. */
  69121. export class ReflectBlock extends NodeMaterialBlock {
  69122. /**
  69123. * Creates a new ReflectBlock
  69124. * @param name defines the block name
  69125. */
  69126. constructor(name: string);
  69127. /**
  69128. * Gets the current class name
  69129. * @returns the class name
  69130. */
  69131. getClassName(): string;
  69132. /**
  69133. * Gets the incident component
  69134. */
  69135. get incident(): NodeMaterialConnectionPoint;
  69136. /**
  69137. * Gets the normal component
  69138. */
  69139. get normal(): NodeMaterialConnectionPoint;
  69140. /**
  69141. * Gets the output component
  69142. */
  69143. get output(): NodeMaterialConnectionPoint;
  69144. protected _buildBlock(state: NodeMaterialBuildState): this;
  69145. }
  69146. }
  69147. declare module BABYLON {
  69148. /**
  69149. * Block used to get the refracted vector from a direction and a normal
  69150. */
  69151. export class RefractBlock extends NodeMaterialBlock {
  69152. /**
  69153. * Creates a new RefractBlock
  69154. * @param name defines the block name
  69155. */
  69156. constructor(name: string);
  69157. /**
  69158. * Gets the current class name
  69159. * @returns the class name
  69160. */
  69161. getClassName(): string;
  69162. /**
  69163. * Gets the incident component
  69164. */
  69165. get incident(): NodeMaterialConnectionPoint;
  69166. /**
  69167. * Gets the normal component
  69168. */
  69169. get normal(): NodeMaterialConnectionPoint;
  69170. /**
  69171. * Gets the index of refraction component
  69172. */
  69173. get ior(): NodeMaterialConnectionPoint;
  69174. /**
  69175. * Gets the output component
  69176. */
  69177. get output(): NodeMaterialConnectionPoint;
  69178. protected _buildBlock(state: NodeMaterialBuildState): this;
  69179. }
  69180. }
  69181. declare module BABYLON {
  69182. /**
  69183. * Block used to desaturate a color
  69184. */
  69185. export class DesaturateBlock extends NodeMaterialBlock {
  69186. /**
  69187. * Creates a new DesaturateBlock
  69188. * @param name defines the block name
  69189. */
  69190. constructor(name: string);
  69191. /**
  69192. * Gets the current class name
  69193. * @returns the class name
  69194. */
  69195. getClassName(): string;
  69196. /**
  69197. * Gets the color operand input component
  69198. */
  69199. get color(): NodeMaterialConnectionPoint;
  69200. /**
  69201. * Gets the level operand input component
  69202. */
  69203. get level(): NodeMaterialConnectionPoint;
  69204. /**
  69205. * Gets the output component
  69206. */
  69207. get output(): NodeMaterialConnectionPoint;
  69208. protected _buildBlock(state: NodeMaterialBuildState): this;
  69209. }
  69210. }
  69211. declare module BABYLON {
  69212. /**
  69213. * Block used to implement the reflection module of the PBR material
  69214. */
  69215. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69216. /** @hidden */
  69217. _defineLODReflectionAlpha: string;
  69218. /** @hidden */
  69219. _defineLinearSpecularReflection: string;
  69220. private _vEnvironmentIrradianceName;
  69221. /** @hidden */
  69222. _vReflectionMicrosurfaceInfosName: string;
  69223. /** @hidden */
  69224. _vReflectionInfosName: string;
  69225. /** @hidden */
  69226. _vReflectionFilteringInfoName: string;
  69227. private _scene;
  69228. /**
  69229. * The properties below are set by the main PBR block prior to calling methods of this class.
  69230. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69231. * It's less burden on the user side in the editor part.
  69232. */
  69233. /** @hidden */
  69234. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69235. /** @hidden */
  69236. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69237. /** @hidden */
  69238. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69239. /** @hidden */
  69240. viewConnectionPoint: NodeMaterialConnectionPoint;
  69241. /**
  69242. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69243. * diffuse part of the IBL.
  69244. */
  69245. useSphericalHarmonics: boolean;
  69246. /**
  69247. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69248. */
  69249. forceIrradianceInFragment: boolean;
  69250. /**
  69251. * Create a new ReflectionBlock
  69252. * @param name defines the block name
  69253. */
  69254. constructor(name: string);
  69255. /**
  69256. * Gets the current class name
  69257. * @returns the class name
  69258. */
  69259. getClassName(): string;
  69260. /**
  69261. * Gets the position input component
  69262. */
  69263. get position(): NodeMaterialConnectionPoint;
  69264. /**
  69265. * Gets the world position input component
  69266. */
  69267. get worldPosition(): NodeMaterialConnectionPoint;
  69268. /**
  69269. * Gets the world normal input component
  69270. */
  69271. get worldNormal(): NodeMaterialConnectionPoint;
  69272. /**
  69273. * Gets the world input component
  69274. */
  69275. get world(): NodeMaterialConnectionPoint;
  69276. /**
  69277. * Gets the camera (or eye) position component
  69278. */
  69279. get cameraPosition(): NodeMaterialConnectionPoint;
  69280. /**
  69281. * Gets the view input component
  69282. */
  69283. get view(): NodeMaterialConnectionPoint;
  69284. /**
  69285. * Gets the color input component
  69286. */
  69287. get color(): NodeMaterialConnectionPoint;
  69288. /**
  69289. * Gets the reflection object output component
  69290. */
  69291. get reflection(): NodeMaterialConnectionPoint;
  69292. /**
  69293. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69294. */
  69295. get hasTexture(): boolean;
  69296. /**
  69297. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69298. */
  69299. get reflectionColor(): string;
  69300. protected _getTexture(): Nullable<BaseTexture>;
  69301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69302. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69303. /**
  69304. * Gets the code to inject in the vertex shader
  69305. * @param state current state of the node material building
  69306. * @returns the shader code
  69307. */
  69308. handleVertexSide(state: NodeMaterialBuildState): string;
  69309. /**
  69310. * Gets the main code of the block (fragment side)
  69311. * @param state current state of the node material building
  69312. * @param normalVarName name of the existing variable corresponding to the normal
  69313. * @returns the shader code
  69314. */
  69315. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69316. protected _buildBlock(state: NodeMaterialBuildState): this;
  69317. protected _dumpPropertiesCode(): string;
  69318. serialize(): any;
  69319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69320. }
  69321. }
  69322. declare module BABYLON {
  69323. /**
  69324. * Block used to implement the sheen module of the PBR material
  69325. */
  69326. export class SheenBlock extends NodeMaterialBlock {
  69327. /**
  69328. * Create a new SheenBlock
  69329. * @param name defines the block name
  69330. */
  69331. constructor(name: string);
  69332. /**
  69333. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69334. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69335. * making it easier to setup and tweak the effect
  69336. */
  69337. albedoScaling: boolean;
  69338. /**
  69339. * Defines if the sheen is linked to the sheen color.
  69340. */
  69341. linkSheenWithAlbedo: boolean;
  69342. /**
  69343. * Initialize the block and prepare the context for build
  69344. * @param state defines the state that will be used for the build
  69345. */
  69346. initialize(state: NodeMaterialBuildState): void;
  69347. /**
  69348. * Gets the current class name
  69349. * @returns the class name
  69350. */
  69351. getClassName(): string;
  69352. /**
  69353. * Gets the intensity input component
  69354. */
  69355. get intensity(): NodeMaterialConnectionPoint;
  69356. /**
  69357. * Gets the color input component
  69358. */
  69359. get color(): NodeMaterialConnectionPoint;
  69360. /**
  69361. * Gets the roughness input component
  69362. */
  69363. get roughness(): NodeMaterialConnectionPoint;
  69364. /**
  69365. * Gets the sheen object output component
  69366. */
  69367. get sheen(): NodeMaterialConnectionPoint;
  69368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69369. /**
  69370. * Gets the main code of the block (fragment side)
  69371. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69372. * @returns the shader code
  69373. */
  69374. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69375. protected _buildBlock(state: NodeMaterialBuildState): this;
  69376. protected _dumpPropertiesCode(): string;
  69377. serialize(): any;
  69378. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69379. }
  69380. }
  69381. declare module BABYLON {
  69382. /**
  69383. * Block used to implement the anisotropy module of the PBR material
  69384. */
  69385. export class AnisotropyBlock extends NodeMaterialBlock {
  69386. /**
  69387. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69388. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69389. * It's less burden on the user side in the editor part.
  69390. */
  69391. /** @hidden */
  69392. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69393. /** @hidden */
  69394. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69395. /**
  69396. * Create a new AnisotropyBlock
  69397. * @param name defines the block name
  69398. */
  69399. constructor(name: string);
  69400. /**
  69401. * Initialize the block and prepare the context for build
  69402. * @param state defines the state that will be used for the build
  69403. */
  69404. initialize(state: NodeMaterialBuildState): void;
  69405. /**
  69406. * Gets the current class name
  69407. * @returns the class name
  69408. */
  69409. getClassName(): string;
  69410. /**
  69411. * Gets the intensity input component
  69412. */
  69413. get intensity(): NodeMaterialConnectionPoint;
  69414. /**
  69415. * Gets the direction input component
  69416. */
  69417. get direction(): NodeMaterialConnectionPoint;
  69418. /**
  69419. * Gets the uv input component
  69420. */
  69421. get uv(): NodeMaterialConnectionPoint;
  69422. /**
  69423. * Gets the worldTangent input component
  69424. */
  69425. get worldTangent(): NodeMaterialConnectionPoint;
  69426. /**
  69427. * Gets the anisotropy object output component
  69428. */
  69429. get anisotropy(): NodeMaterialConnectionPoint;
  69430. private _generateTBNSpace;
  69431. /**
  69432. * Gets the main code of the block (fragment side)
  69433. * @param state current state of the node material building
  69434. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69435. * @returns the shader code
  69436. */
  69437. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69439. protected _buildBlock(state: NodeMaterialBuildState): this;
  69440. }
  69441. }
  69442. declare module BABYLON {
  69443. /**
  69444. * Block used to implement the clear coat module of the PBR material
  69445. */
  69446. export class ClearCoatBlock extends NodeMaterialBlock {
  69447. private _scene;
  69448. /**
  69449. * Create a new ClearCoatBlock
  69450. * @param name defines the block name
  69451. */
  69452. constructor(name: string);
  69453. /**
  69454. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69455. */
  69456. remapF0OnInterfaceChange: boolean;
  69457. /**
  69458. * Initialize the block and prepare the context for build
  69459. * @param state defines the state that will be used for the build
  69460. */
  69461. initialize(state: NodeMaterialBuildState): void;
  69462. /**
  69463. * Gets the current class name
  69464. * @returns the class name
  69465. */
  69466. getClassName(): string;
  69467. /**
  69468. * Gets the intensity input component
  69469. */
  69470. get intensity(): NodeMaterialConnectionPoint;
  69471. /**
  69472. * Gets the roughness input component
  69473. */
  69474. get roughness(): NodeMaterialConnectionPoint;
  69475. /**
  69476. * Gets the ior input component
  69477. */
  69478. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69479. /**
  69480. * Gets the bump texture input component
  69481. */
  69482. get normalMapColor(): NodeMaterialConnectionPoint;
  69483. /**
  69484. * Gets the uv input component
  69485. */
  69486. get uv(): NodeMaterialConnectionPoint;
  69487. /**
  69488. * Gets the tint color input component
  69489. */
  69490. get tintColor(): NodeMaterialConnectionPoint;
  69491. /**
  69492. * Gets the tint "at distance" input component
  69493. */
  69494. get tintAtDistance(): NodeMaterialConnectionPoint;
  69495. /**
  69496. * Gets the tint thickness input component
  69497. */
  69498. get tintThickness(): NodeMaterialConnectionPoint;
  69499. /**
  69500. * Gets the world tangent input component
  69501. */
  69502. get worldTangent(): NodeMaterialConnectionPoint;
  69503. /**
  69504. * Gets the clear coat object output component
  69505. */
  69506. get clearcoat(): NodeMaterialConnectionPoint;
  69507. autoConfigure(material: NodeMaterial): void;
  69508. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69509. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69510. private _generateTBNSpace;
  69511. /**
  69512. * Gets the main code of the block (fragment side)
  69513. * @param state current state of the node material building
  69514. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69515. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69516. * @param worldPosVarName name of the variable holding the world position
  69517. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69518. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69519. * @param worldNormalVarName name of the variable holding the world normal
  69520. * @returns the shader code
  69521. */
  69522. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69523. protected _buildBlock(state: NodeMaterialBuildState): this;
  69524. protected _dumpPropertiesCode(): string;
  69525. serialize(): any;
  69526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /**
  69531. * Block used to implement the sub surface module of the PBR material
  69532. */
  69533. export class SubSurfaceBlock extends NodeMaterialBlock {
  69534. /**
  69535. * Create a new SubSurfaceBlock
  69536. * @param name defines the block name
  69537. */
  69538. constructor(name: string);
  69539. /**
  69540. * Initialize the block and prepare the context for build
  69541. * @param state defines the state that will be used for the build
  69542. */
  69543. initialize(state: NodeMaterialBuildState): void;
  69544. /**
  69545. * Gets the current class name
  69546. * @returns the class name
  69547. */
  69548. getClassName(): string;
  69549. /**
  69550. * Gets the thickness component
  69551. */
  69552. get thickness(): NodeMaterialConnectionPoint;
  69553. /**
  69554. * Gets the tint color input component
  69555. */
  69556. get tintColor(): NodeMaterialConnectionPoint;
  69557. /**
  69558. * Gets the translucency intensity input component
  69559. */
  69560. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69561. /**
  69562. * Gets the translucency diffusion distance input component
  69563. */
  69564. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69565. /**
  69566. * Gets the refraction object parameters
  69567. */
  69568. get refraction(): NodeMaterialConnectionPoint;
  69569. /**
  69570. * Gets the sub surface object output component
  69571. */
  69572. get subsurface(): NodeMaterialConnectionPoint;
  69573. autoConfigure(material: NodeMaterial): void;
  69574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69575. /**
  69576. * Gets the main code of the block (fragment side)
  69577. * @param state current state of the node material building
  69578. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69579. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69580. * @param worldPosVarName name of the variable holding the world position
  69581. * @returns the shader code
  69582. */
  69583. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69584. protected _buildBlock(state: NodeMaterialBuildState): this;
  69585. }
  69586. }
  69587. declare module BABYLON {
  69588. /**
  69589. * Block used to implement the PBR metallic/roughness model
  69590. */
  69591. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69592. /**
  69593. * Gets or sets the light associated with this block
  69594. */
  69595. light: Nullable<Light>;
  69596. private _lightId;
  69597. private _scene;
  69598. private _environmentBRDFTexture;
  69599. private _environmentBrdfSamplerName;
  69600. private _vNormalWName;
  69601. private _invertNormalName;
  69602. private _metallicReflectanceColor;
  69603. private _metallicF0Factor;
  69604. private _vMetallicReflectanceFactorsName;
  69605. /**
  69606. * Create a new ReflectionBlock
  69607. * @param name defines the block name
  69608. */
  69609. constructor(name: string);
  69610. /**
  69611. * Intensity of the direct lights e.g. the four lights available in your scene.
  69612. * This impacts both the direct diffuse and specular highlights.
  69613. */
  69614. directIntensity: number;
  69615. /**
  69616. * Intensity of the environment e.g. how much the environment will light the object
  69617. * either through harmonics for rough material or through the reflection for shiny ones.
  69618. */
  69619. environmentIntensity: number;
  69620. /**
  69621. * This is a special control allowing the reduction of the specular highlights coming from the
  69622. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69623. */
  69624. specularIntensity: number;
  69625. /**
  69626. * Defines the falloff type used in this material.
  69627. * It by default is Physical.
  69628. */
  69629. lightFalloff: number;
  69630. /**
  69631. * Specifies that alpha test should be used
  69632. */
  69633. useAlphaTest: boolean;
  69634. /**
  69635. * Defines the alpha limits in alpha test mode.
  69636. */
  69637. alphaTestCutoff: number;
  69638. /**
  69639. * Specifies that alpha blending should be used
  69640. */
  69641. useAlphaBlending: boolean;
  69642. /**
  69643. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69644. * A car glass is a good example of that. When the street lights reflects on it you can not see what is behind.
  69645. */
  69646. useRadianceOverAlpha: boolean;
  69647. /**
  69648. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69649. * A car glass is a good example of that. When sun reflects on it you can not see what is behind.
  69650. */
  69651. useSpecularOverAlpha: boolean;
  69652. /**
  69653. * Enables specular anti aliasing in the PBR shader.
  69654. * It will both interacts on the Geometry for analytical and IBL lighting.
  69655. * It also prefilter the roughness map based on the bump values.
  69656. */
  69657. enableSpecularAntiAliasing: boolean;
  69658. /**
  69659. * Enables realtime filtering on the texture.
  69660. */
  69661. realTimeFiltering: boolean;
  69662. /**
  69663. * Quality switch for realtime filtering
  69664. */
  69665. realTimeFilteringQuality: number;
  69666. /**
  69667. * Defines if the material uses energy conservation.
  69668. */
  69669. useEnergyConservation: boolean;
  69670. /**
  69671. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69672. * too much the area relying on ambient texture to define their ambient occlusion.
  69673. */
  69674. useRadianceOcclusion: boolean;
  69675. /**
  69676. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69677. * makes the reflect vector face the model (under horizon).
  69678. */
  69679. useHorizonOcclusion: boolean;
  69680. /**
  69681. * If set to true, no lighting calculations will be applied.
  69682. */
  69683. unlit: boolean;
  69684. /**
  69685. * Force normal to face away from face.
  69686. */
  69687. forceNormalForward: boolean;
  69688. /**
  69689. * Defines the material debug mode.
  69690. * It helps seeing only some components of the material while troubleshooting.
  69691. */
  69692. debugMode: number;
  69693. /**
  69694. * Specify from where on screen the debug mode should start.
  69695. * The value goes from -1 (full screen) to 1 (not visible)
  69696. * It helps with side by side comparison against the final render
  69697. * This defaults to 0
  69698. */
  69699. debugLimit: number;
  69700. /**
  69701. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69702. * You can use the factor to better multiply the final value.
  69703. */
  69704. debugFactor: number;
  69705. /**
  69706. * Initialize the block and prepare the context for build
  69707. * @param state defines the state that will be used for the build
  69708. */
  69709. initialize(state: NodeMaterialBuildState): void;
  69710. /**
  69711. * Gets the current class name
  69712. * @returns the class name
  69713. */
  69714. getClassName(): string;
  69715. /**
  69716. * Gets the world position input component
  69717. */
  69718. get worldPosition(): NodeMaterialConnectionPoint;
  69719. /**
  69720. * Gets the world normal input component
  69721. */
  69722. get worldNormal(): NodeMaterialConnectionPoint;
  69723. /**
  69724. * Gets the view matrix parameter
  69725. */
  69726. get view(): NodeMaterialConnectionPoint;
  69727. /**
  69728. * Gets the camera position input component
  69729. */
  69730. get cameraPosition(): NodeMaterialConnectionPoint;
  69731. /**
  69732. * Gets the perturbed normal input component
  69733. */
  69734. get perturbedNormal(): NodeMaterialConnectionPoint;
  69735. /**
  69736. * Gets the base color input component
  69737. */
  69738. get baseColor(): NodeMaterialConnectionPoint;
  69739. /**
  69740. * Gets the metallic input component
  69741. */
  69742. get metallic(): NodeMaterialConnectionPoint;
  69743. /**
  69744. * Gets the roughness input component
  69745. */
  69746. get roughness(): NodeMaterialConnectionPoint;
  69747. /**
  69748. * Gets the ambient occlusion input component
  69749. */
  69750. get ambientOcc(): NodeMaterialConnectionPoint;
  69751. /**
  69752. * Gets the opacity input component
  69753. */
  69754. get opacity(): NodeMaterialConnectionPoint;
  69755. /**
  69756. * Gets the index of refraction input component
  69757. */
  69758. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69759. /**
  69760. * Gets the ambient color input component
  69761. */
  69762. get ambientColor(): NodeMaterialConnectionPoint;
  69763. /**
  69764. * Gets the reflection object parameters
  69765. */
  69766. get reflection(): NodeMaterialConnectionPoint;
  69767. /**
  69768. * Gets the clear coat object parameters
  69769. */
  69770. get clearcoat(): NodeMaterialConnectionPoint;
  69771. /**
  69772. * Gets the sheen object parameters
  69773. */
  69774. get sheen(): NodeMaterialConnectionPoint;
  69775. /**
  69776. * Gets the sub surface object parameters
  69777. */
  69778. get subsurface(): NodeMaterialConnectionPoint;
  69779. /**
  69780. * Gets the anisotropy object parameters
  69781. */
  69782. get anisotropy(): NodeMaterialConnectionPoint;
  69783. /**
  69784. * Gets the ambient output component
  69785. */
  69786. get ambientClr(): NodeMaterialConnectionPoint;
  69787. /**
  69788. * Gets the diffuse output component
  69789. */
  69790. get diffuseDir(): NodeMaterialConnectionPoint;
  69791. /**
  69792. * Gets the specular output component
  69793. */
  69794. get specularDir(): NodeMaterialConnectionPoint;
  69795. /**
  69796. * Gets the clear coat output component
  69797. */
  69798. get clearcoatDir(): NodeMaterialConnectionPoint;
  69799. /**
  69800. * Gets the sheen output component
  69801. */
  69802. get sheenDir(): NodeMaterialConnectionPoint;
  69803. /**
  69804. * Gets the indirect diffuse output component
  69805. */
  69806. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69807. /**
  69808. * Gets the indirect specular output component
  69809. */
  69810. get specularIndirect(): NodeMaterialConnectionPoint;
  69811. /**
  69812. * Gets the indirect clear coat output component
  69813. */
  69814. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69815. /**
  69816. * Gets the indirect sheen output component
  69817. */
  69818. get sheenIndirect(): NodeMaterialConnectionPoint;
  69819. /**
  69820. * Gets the refraction output component
  69821. */
  69822. get refraction(): NodeMaterialConnectionPoint;
  69823. /**
  69824. * Gets the global lighting output component
  69825. */
  69826. get lighting(): NodeMaterialConnectionPoint;
  69827. /**
  69828. * Gets the shadow output component
  69829. */
  69830. get shadow(): NodeMaterialConnectionPoint;
  69831. /**
  69832. * Gets the alpha output component
  69833. */
  69834. get alpha(): NodeMaterialConnectionPoint;
  69835. autoConfigure(material: NodeMaterial): void;
  69836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69837. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69838. isReady(): boolean;
  69839. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69840. private _injectVertexCode;
  69841. private _getAlbedoOpacityCode;
  69842. private _getAmbientOcclusionCode;
  69843. private _getReflectivityCode;
  69844. protected _buildBlock(state: NodeMaterialBuildState): this;
  69845. protected _dumpPropertiesCode(): string;
  69846. serialize(): any;
  69847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69848. }
  69849. }
  69850. declare module BABYLON {
  69851. /**
  69852. * Block used to compute value of one parameter modulo another
  69853. */
  69854. export class ModBlock extends NodeMaterialBlock {
  69855. /**
  69856. * Creates a new ModBlock
  69857. * @param name defines the block name
  69858. */
  69859. constructor(name: string);
  69860. /**
  69861. * Gets the current class name
  69862. * @returns the class name
  69863. */
  69864. getClassName(): string;
  69865. /**
  69866. * Gets the left operand input component
  69867. */
  69868. get left(): NodeMaterialConnectionPoint;
  69869. /**
  69870. * Gets the right operand input component
  69871. */
  69872. get right(): NodeMaterialConnectionPoint;
  69873. /**
  69874. * Gets the output component
  69875. */
  69876. get output(): NodeMaterialConnectionPoint;
  69877. protected _buildBlock(state: NodeMaterialBuildState): this;
  69878. }
  69879. }
  69880. declare module BABYLON {
  69881. /**
  69882. * Configuration for Draco compression
  69883. */
  69884. export interface IDracoCompressionConfiguration {
  69885. /**
  69886. * Configuration for the decoder.
  69887. */
  69888. decoder: {
  69889. /**
  69890. * The url to the WebAssembly module.
  69891. */
  69892. wasmUrl?: string;
  69893. /**
  69894. * The url to the WebAssembly binary.
  69895. */
  69896. wasmBinaryUrl?: string;
  69897. /**
  69898. * The url to the fallback JavaScript module.
  69899. */
  69900. fallbackUrl?: string;
  69901. };
  69902. }
  69903. /**
  69904. * Draco compression (https://google.github.io/draco/)
  69905. *
  69906. * This class wraps the Draco module.
  69907. *
  69908. * **Encoder**
  69909. *
  69910. * The encoder is not currently implemented.
  69911. *
  69912. * **Decoder**
  69913. *
  69914. * 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.
  69915. *
  69916. * To update the configuration, use the following code:
  69917. * ```javascript
  69918. * DracoCompression.Configuration = {
  69919. * decoder: {
  69920. * wasmUrl: "<url to the WebAssembly library>",
  69921. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69922. * fallbackUrl: "<url to the fallback JavaScript library>",
  69923. * }
  69924. * };
  69925. * ```
  69926. *
  69927. * 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.
  69928. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69929. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69930. *
  69931. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69932. * ```javascript
  69933. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69934. * ```
  69935. *
  69936. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69937. */
  69938. export class DracoCompression implements IDisposable {
  69939. private _workerPoolPromise?;
  69940. private _decoderModulePromise?;
  69941. /**
  69942. * The configuration. Defaults to the following urls:
  69943. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69944. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69945. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69946. */
  69947. static Configuration: IDracoCompressionConfiguration;
  69948. /**
  69949. * Returns true if the decoder configuration is available.
  69950. */
  69951. static get DecoderAvailable(): boolean;
  69952. /**
  69953. * Default number of workers to create when creating the draco compression object.
  69954. */
  69955. static DefaultNumWorkers: number;
  69956. private static GetDefaultNumWorkers;
  69957. private static _Default;
  69958. /**
  69959. * Default instance for the draco compression object.
  69960. */
  69961. static get Default(): DracoCompression;
  69962. /**
  69963. * Constructor
  69964. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69965. */
  69966. constructor(numWorkers?: number);
  69967. /**
  69968. * Stop all async operations and release resources.
  69969. */
  69970. dispose(): void;
  69971. /**
  69972. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69973. * @returns a promise that resolves when ready
  69974. */
  69975. whenReadyAsync(): Promise<void>;
  69976. /**
  69977. * Decode Draco compressed mesh data to vertex data.
  69978. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69979. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69980. * @returns A promise that resolves with the decoded vertex data
  69981. */
  69982. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69983. [kind: string]: number;
  69984. }): Promise<VertexData>;
  69985. }
  69986. }
  69987. declare module BABYLON {
  69988. /**
  69989. * Class for building Constructive Solid Geometry
  69990. */
  69991. export class CSG {
  69992. private polygons;
  69993. /**
  69994. * The world matrix
  69995. */
  69996. matrix: Matrix;
  69997. /**
  69998. * Stores the position
  69999. */
  70000. position: Vector3;
  70001. /**
  70002. * Stores the rotation
  70003. */
  70004. rotation: Vector3;
  70005. /**
  70006. * Stores the rotation quaternion
  70007. */
  70008. rotationQuaternion: Nullable<Quaternion>;
  70009. /**
  70010. * Stores the scaling vector
  70011. */
  70012. scaling: Vector3;
  70013. /**
  70014. * Convert the Mesh to CSG
  70015. * @param mesh The Mesh to convert to CSG
  70016. * @returns A new CSG from the Mesh
  70017. */
  70018. static FromMesh(mesh: Mesh): CSG;
  70019. /**
  70020. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70021. * @param polygons Polygons used to construct a CSG solid
  70022. */
  70023. private static FromPolygons;
  70024. /**
  70025. * Clones, or makes a deep copy, of the CSG
  70026. * @returns A new CSG
  70027. */
  70028. clone(): CSG;
  70029. /**
  70030. * Unions this CSG with another CSG
  70031. * @param csg The CSG to union against this CSG
  70032. * @returns The unioned CSG
  70033. */
  70034. union(csg: CSG): CSG;
  70035. /**
  70036. * Unions this CSG with another CSG in place
  70037. * @param csg The CSG to union against this CSG
  70038. */
  70039. unionInPlace(csg: CSG): void;
  70040. /**
  70041. * Subtracts this CSG with another CSG
  70042. * @param csg The CSG to subtract against this CSG
  70043. * @returns A new CSG
  70044. */
  70045. subtract(csg: CSG): CSG;
  70046. /**
  70047. * Subtracts this CSG with another CSG in place
  70048. * @param csg The CSG to subtract against this CSG
  70049. */
  70050. subtractInPlace(csg: CSG): void;
  70051. /**
  70052. * Intersect this CSG with another CSG
  70053. * @param csg The CSG to intersect against this CSG
  70054. * @returns A new CSG
  70055. */
  70056. intersect(csg: CSG): CSG;
  70057. /**
  70058. * Intersects this CSG with another CSG in place
  70059. * @param csg The CSG to intersect against this CSG
  70060. */
  70061. intersectInPlace(csg: CSG): void;
  70062. /**
  70063. * Return a new CSG solid with solid and empty space switched. This solid is
  70064. * not modified.
  70065. * @returns A new CSG solid with solid and empty space switched
  70066. */
  70067. inverse(): CSG;
  70068. /**
  70069. * Inverses the CSG in place
  70070. */
  70071. inverseInPlace(): void;
  70072. /**
  70073. * This is used to keep meshes transformations so they can be restored
  70074. * when we build back a Babylon Mesh
  70075. * NB : All CSG operations are performed in world coordinates
  70076. * @param csg The CSG to copy the transform attributes from
  70077. * @returns This CSG
  70078. */
  70079. copyTransformAttributes(csg: CSG): CSG;
  70080. /**
  70081. * Build Raw mesh from CSG
  70082. * Coordinates here are in world space
  70083. * @param name The name of the mesh geometry
  70084. * @param scene The Scene
  70085. * @param keepSubMeshes Specifies if the submeshes should be kept
  70086. * @returns A new Mesh
  70087. */
  70088. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70089. /**
  70090. * Build Mesh from CSG taking material and transforms into account
  70091. * @param name The name of the Mesh
  70092. * @param material The material of the Mesh
  70093. * @param scene The Scene
  70094. * @param keepSubMeshes Specifies if submeshes should be kept
  70095. * @returns The new Mesh
  70096. */
  70097. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70098. }
  70099. }
  70100. declare module BABYLON {
  70101. /**
  70102. * Class used to create a trail following a mesh
  70103. */
  70104. export class TrailMesh extends Mesh {
  70105. private _generator;
  70106. private _autoStart;
  70107. private _running;
  70108. private _diameter;
  70109. private _length;
  70110. private _sectionPolygonPointsCount;
  70111. private _sectionVectors;
  70112. private _sectionNormalVectors;
  70113. private _beforeRenderObserver;
  70114. /**
  70115. * @constructor
  70116. * @param name The value used by scene.getMeshByName() to do a lookup.
  70117. * @param generator The mesh or transform node to generate a trail.
  70118. * @param scene The scene to add this mesh to.
  70119. * @param diameter Diameter of trailing mesh. Default is 1.
  70120. * @param length Length of trailing mesh. Default is 60.
  70121. * @param autoStart Automatically start trailing mesh. Default true.
  70122. */
  70123. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70124. /**
  70125. * "TrailMesh"
  70126. * @returns "TrailMesh"
  70127. */
  70128. getClassName(): string;
  70129. private _createMesh;
  70130. /**
  70131. * Start trailing mesh.
  70132. */
  70133. start(): void;
  70134. /**
  70135. * Stop trailing mesh.
  70136. */
  70137. stop(): void;
  70138. /**
  70139. * Update trailing mesh geometry.
  70140. */
  70141. update(): void;
  70142. /**
  70143. * Returns a new TrailMesh object.
  70144. * @param name is a string, the name given to the new mesh
  70145. * @param newGenerator use new generator object for cloned trail mesh
  70146. * @returns a new mesh
  70147. */
  70148. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70149. /**
  70150. * Serializes this trail mesh
  70151. * @param serializationObject object to write serialization to
  70152. */
  70153. serialize(serializationObject: any): void;
  70154. /**
  70155. * Parses a serialized trail mesh
  70156. * @param parsedMesh the serialized mesh
  70157. * @param scene the scene to create the trail mesh in
  70158. * @returns the created trail mesh
  70159. */
  70160. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70161. }
  70162. }
  70163. declare module BABYLON {
  70164. /**
  70165. * Class containing static functions to help procedurally build meshes
  70166. */
  70167. export class TiledBoxBuilder {
  70168. /**
  70169. * Creates a box mesh
  70170. * 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)
  70171. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70173. * * 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
  70174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70175. * @param name defines the name of the mesh
  70176. * @param options defines the options used to create the mesh
  70177. * @param scene defines the hosting scene
  70178. * @returns the box mesh
  70179. */
  70180. static CreateTiledBox(name: string, options: {
  70181. pattern?: number;
  70182. width?: number;
  70183. height?: number;
  70184. depth?: number;
  70185. tileSize?: number;
  70186. tileWidth?: number;
  70187. tileHeight?: number;
  70188. alignHorizontal?: number;
  70189. alignVertical?: number;
  70190. faceUV?: Vector4[];
  70191. faceColors?: Color4[];
  70192. sideOrientation?: number;
  70193. updatable?: boolean;
  70194. }, scene?: Nullable<Scene>): Mesh;
  70195. }
  70196. }
  70197. declare module BABYLON {
  70198. /**
  70199. * Class containing static functions to help procedurally build meshes
  70200. */
  70201. export class TorusKnotBuilder {
  70202. /**
  70203. * Creates a torus knot mesh
  70204. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70205. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70206. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70207. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70209. * * 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
  70210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70211. * @param name defines the name of the mesh
  70212. * @param options defines the options used to create the mesh
  70213. * @param scene defines the hosting scene
  70214. * @returns the torus knot mesh
  70215. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70216. */
  70217. static CreateTorusKnot(name: string, options: {
  70218. radius?: number;
  70219. tube?: number;
  70220. radialSegments?: number;
  70221. tubularSegments?: number;
  70222. p?: number;
  70223. q?: number;
  70224. updatable?: boolean;
  70225. sideOrientation?: number;
  70226. frontUVs?: Vector4;
  70227. backUVs?: Vector4;
  70228. }, scene: any): Mesh;
  70229. }
  70230. }
  70231. declare module BABYLON {
  70232. /**
  70233. * Polygon
  70234. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70235. */
  70236. export class Polygon {
  70237. /**
  70238. * Creates a rectangle
  70239. * @param xmin bottom X coord
  70240. * @param ymin bottom Y coord
  70241. * @param xmax top X coord
  70242. * @param ymax top Y coord
  70243. * @returns points that make the resulting rectangle
  70244. */
  70245. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70246. /**
  70247. * Creates a circle
  70248. * @param radius radius of circle
  70249. * @param cx scale in x
  70250. * @param cy scale in y
  70251. * @param numberOfSides number of sides that make up the circle
  70252. * @returns points that make the resulting circle
  70253. */
  70254. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70255. /**
  70256. * Creates a polygon from input string
  70257. * @param input Input polygon data
  70258. * @returns the parsed points
  70259. */
  70260. static Parse(input: string): Vector2[];
  70261. /**
  70262. * Starts building a polygon from x and y coordinates
  70263. * @param x x coordinate
  70264. * @param y y coordinate
  70265. * @returns the started path2
  70266. */
  70267. static StartingAt(x: number, y: number): Path2;
  70268. }
  70269. /**
  70270. * Builds a polygon
  70271. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70272. */
  70273. export class PolygonMeshBuilder {
  70274. private _points;
  70275. private _outlinepoints;
  70276. private _holes;
  70277. private _name;
  70278. private _scene;
  70279. private _epoints;
  70280. private _eholes;
  70281. private _addToepoint;
  70282. /**
  70283. * Babylon reference to the earcut plugin.
  70284. */
  70285. bjsEarcut: any;
  70286. /**
  70287. * Creates a PolygonMeshBuilder
  70288. * @param name name of the builder
  70289. * @param contours Path of the polygon
  70290. * @param scene scene to add to when creating the mesh
  70291. * @param earcutInjection can be used to inject your own earcut reference
  70292. */
  70293. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70294. /**
  70295. * Adds a hole within the polygon
  70296. * @param hole Array of points defining the hole
  70297. * @returns this
  70298. */
  70299. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70300. /**
  70301. * Creates the polygon
  70302. * @param updatable If the mesh should be updatable
  70303. * @param depth The depth of the mesh created
  70304. * @param smoothingThreshold Dot product threshold for smoothed normals
  70305. * @returns the created mesh
  70306. */
  70307. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  70308. /**
  70309. * Creates the polygon
  70310. * @param depth The depth of the mesh created
  70311. * @param smoothingThreshold Dot product threshold for smoothed normals
  70312. * @returns the created VertexData
  70313. */
  70314. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  70315. /**
  70316. * Adds a side to the polygon
  70317. * @param positions points that make the polygon
  70318. * @param normals normals of the polygon
  70319. * @param uvs uvs of the polygon
  70320. * @param indices indices of the polygon
  70321. * @param bounds bounds of the polygon
  70322. * @param points points of the polygon
  70323. * @param depth depth of the polygon
  70324. * @param flip flip of the polygon
  70325. */
  70326. private addSide;
  70327. }
  70328. }
  70329. declare module BABYLON {
  70330. /**
  70331. * Class containing static functions to help procedurally build meshes
  70332. */
  70333. export class PolygonBuilder {
  70334. /**
  70335. * Creates a polygon mesh
  70336. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70337. * * 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
  70338. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70340. * * 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)
  70341. * * Remember you can only change the shape positions, not their number when updating a polygon
  70342. * @param name defines the name of the mesh
  70343. * @param options defines the options used to create the mesh
  70344. * @param scene defines the hosting scene
  70345. * @param earcutInjection can be used to inject your own earcut reference
  70346. * @returns the polygon mesh
  70347. */
  70348. static CreatePolygon(name: string, options: {
  70349. shape: Vector3[];
  70350. holes?: Vector3[][];
  70351. depth?: number;
  70352. smoothingThreshold?: number;
  70353. faceUV?: Vector4[];
  70354. faceColors?: Color4[];
  70355. updatable?: boolean;
  70356. sideOrientation?: number;
  70357. frontUVs?: Vector4;
  70358. backUVs?: Vector4;
  70359. wrap?: boolean;
  70360. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70361. /**
  70362. * Creates an extruded polygon mesh, with depth in the Y direction.
  70363. * * 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)
  70364. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70365. * @param name defines the name of the mesh
  70366. * @param options defines the options used to create the mesh
  70367. * @param scene defines the hosting scene
  70368. * @param earcutInjection can be used to inject your own earcut reference
  70369. * @returns the polygon mesh
  70370. */
  70371. static ExtrudePolygon(name: string, options: {
  70372. shape: Vector3[];
  70373. holes?: Vector3[][];
  70374. depth?: number;
  70375. faceUV?: Vector4[];
  70376. faceColors?: Color4[];
  70377. updatable?: boolean;
  70378. sideOrientation?: number;
  70379. frontUVs?: Vector4;
  70380. backUVs?: Vector4;
  70381. wrap?: boolean;
  70382. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70383. }
  70384. }
  70385. declare module BABYLON {
  70386. /**
  70387. * Class containing static functions to help procedurally build meshes
  70388. */
  70389. export class LatheBuilder {
  70390. /**
  70391. * Creates lathe mesh.
  70392. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70393. * * 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
  70394. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70395. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70396. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70397. * * 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
  70398. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70399. * * 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
  70400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70401. * * 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
  70402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70404. * @param name defines the name of the mesh
  70405. * @param options defines the options used to create the mesh
  70406. * @param scene defines the hosting scene
  70407. * @returns the lathe mesh
  70408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70409. */
  70410. static CreateLathe(name: string, options: {
  70411. shape: Vector3[];
  70412. radius?: number;
  70413. tessellation?: number;
  70414. clip?: number;
  70415. arc?: number;
  70416. closed?: boolean;
  70417. updatable?: boolean;
  70418. sideOrientation?: number;
  70419. frontUVs?: Vector4;
  70420. backUVs?: Vector4;
  70421. cap?: number;
  70422. invertUV?: boolean;
  70423. }, scene?: Nullable<Scene>): Mesh;
  70424. }
  70425. }
  70426. declare module BABYLON {
  70427. /**
  70428. * Class containing static functions to help procedurally build meshes
  70429. */
  70430. export class TiledPlaneBuilder {
  70431. /**
  70432. * Creates a tiled plane mesh
  70433. * * The parameter `pattern` will, depending on value, do nothing or
  70434. * * * flip (reflect about central vertical) alternate tiles across and up
  70435. * * * flip every tile on alternate rows
  70436. * * * rotate (180 degs) alternate tiles across and up
  70437. * * * rotate every tile on alternate rows
  70438. * * * flip and rotate alternate tiles across and up
  70439. * * * flip and rotate every tile on alternate rows
  70440. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70441. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70442. * * 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
  70443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70444. * * 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)
  70445. * * 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)
  70446. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70447. * @param name defines the name of the mesh
  70448. * @param options defines the options used to create the mesh
  70449. * @param scene defines the hosting scene
  70450. * @returns the box mesh
  70451. */
  70452. static CreateTiledPlane(name: string, options: {
  70453. pattern?: number;
  70454. tileSize?: number;
  70455. tileWidth?: number;
  70456. tileHeight?: number;
  70457. size?: number;
  70458. width?: number;
  70459. height?: number;
  70460. alignHorizontal?: number;
  70461. alignVertical?: number;
  70462. sideOrientation?: number;
  70463. frontUVs?: Vector4;
  70464. backUVs?: Vector4;
  70465. updatable?: boolean;
  70466. }, scene?: Nullable<Scene>): Mesh;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * Class containing static functions to help procedurally build meshes
  70472. */
  70473. export class TubeBuilder {
  70474. /**
  70475. * Creates a tube mesh.
  70476. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70477. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70478. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70479. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70480. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  70481. * * 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)
  70482. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70483. * * 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
  70484. * * 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
  70485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70486. * * 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
  70487. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70489. * @param name defines the name of the mesh
  70490. * @param options defines the options used to create the mesh
  70491. * @param scene defines the hosting scene
  70492. * @returns the tube mesh
  70493. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70494. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70495. */
  70496. static CreateTube(name: string, options: {
  70497. path: Vector3[];
  70498. radius?: number;
  70499. tessellation?: number;
  70500. radiusFunction?: {
  70501. (i: number, distance: number): number;
  70502. };
  70503. cap?: number;
  70504. arc?: number;
  70505. updatable?: boolean;
  70506. sideOrientation?: number;
  70507. frontUVs?: Vector4;
  70508. backUVs?: Vector4;
  70509. instance?: Mesh;
  70510. invertUV?: boolean;
  70511. }, scene?: Nullable<Scene>): Mesh;
  70512. }
  70513. }
  70514. declare module BABYLON {
  70515. /**
  70516. * Class containing static functions to help procedurally build meshes
  70517. */
  70518. export class IcoSphereBuilder {
  70519. /**
  70520. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70521. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70522. * * 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`)
  70523. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70524. * * 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
  70525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70526. * * 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
  70527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70528. * @param name defines the name of the mesh
  70529. * @param options defines the options used to create the mesh
  70530. * @param scene defines the hosting scene
  70531. * @returns the icosahedron mesh
  70532. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70533. */
  70534. static CreateIcoSphere(name: string, options: {
  70535. radius?: number;
  70536. radiusX?: number;
  70537. radiusY?: number;
  70538. radiusZ?: number;
  70539. flat?: boolean;
  70540. subdivisions?: number;
  70541. sideOrientation?: number;
  70542. frontUVs?: Vector4;
  70543. backUVs?: Vector4;
  70544. updatable?: boolean;
  70545. }, scene?: Nullable<Scene>): Mesh;
  70546. }
  70547. }
  70548. declare module BABYLON {
  70549. /**
  70550. * Class containing static functions to help procedurally build meshes
  70551. */
  70552. export class DecalBuilder {
  70553. /**
  70554. * Creates a decal mesh.
  70555. * 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
  70556. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70557. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70558. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70559. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70560. * @param name defines the name of the mesh
  70561. * @param sourceMesh defines the mesh where the decal must be applied
  70562. * @param options defines the options used to create the mesh
  70563. * @param scene defines the hosting scene
  70564. * @returns the decal mesh
  70565. * @see https://doc.babylonjs.com/how_to/decals
  70566. */
  70567. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70568. position?: Vector3;
  70569. normal?: Vector3;
  70570. size?: Vector3;
  70571. angle?: number;
  70572. }): Mesh;
  70573. }
  70574. }
  70575. declare module BABYLON {
  70576. /**
  70577. * Class containing static functions to help procedurally build meshes
  70578. */
  70579. export class MeshBuilder {
  70580. /**
  70581. * Creates a box mesh
  70582. * * The parameter `size` sets the size (float) of each box side (default 1)
  70583. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70584. * * 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)
  70585. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70587. * * 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
  70588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70589. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70590. * @param name defines the name of the mesh
  70591. * @param options defines the options used to create the mesh
  70592. * @param scene defines the hosting scene
  70593. * @returns the box mesh
  70594. */
  70595. static CreateBox(name: string, options: {
  70596. size?: number;
  70597. width?: number;
  70598. height?: number;
  70599. depth?: number;
  70600. faceUV?: Vector4[];
  70601. faceColors?: Color4[];
  70602. sideOrientation?: number;
  70603. frontUVs?: Vector4;
  70604. backUVs?: Vector4;
  70605. wrap?: boolean;
  70606. topBaseAt?: number;
  70607. bottomBaseAt?: number;
  70608. updatable?: boolean;
  70609. }, scene?: Nullable<Scene>): Mesh;
  70610. /**
  70611. * Creates a tiled box mesh
  70612. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70614. * @param name defines the name of the mesh
  70615. * @param options defines the options used to create the mesh
  70616. * @param scene defines the hosting scene
  70617. * @returns the tiled box mesh
  70618. */
  70619. static CreateTiledBox(name: string, options: {
  70620. pattern?: number;
  70621. size?: number;
  70622. width?: number;
  70623. height?: number;
  70624. depth: number;
  70625. tileSize?: number;
  70626. tileWidth?: number;
  70627. tileHeight?: number;
  70628. faceUV?: Vector4[];
  70629. faceColors?: Color4[];
  70630. alignHorizontal?: number;
  70631. alignVertical?: number;
  70632. sideOrientation?: number;
  70633. updatable?: boolean;
  70634. }, scene?: Nullable<Scene>): Mesh;
  70635. /**
  70636. * Creates a sphere mesh
  70637. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70638. * * 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`)
  70639. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70640. * * 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
  70641. * * 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)
  70642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70645. * @param name defines the name of the mesh
  70646. * @param options defines the options used to create the mesh
  70647. * @param scene defines the hosting scene
  70648. * @returns the sphere mesh
  70649. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70650. */
  70651. static CreateSphere(name: string, options: {
  70652. segments?: number;
  70653. diameter?: number;
  70654. diameterX?: number;
  70655. diameterY?: number;
  70656. diameterZ?: number;
  70657. arc?: number;
  70658. slice?: number;
  70659. sideOrientation?: number;
  70660. frontUVs?: Vector4;
  70661. backUVs?: Vector4;
  70662. updatable?: boolean;
  70663. }, scene?: Nullable<Scene>): Mesh;
  70664. /**
  70665. * Creates a plane polygonal mesh. By default, this is a disc
  70666. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70667. * * 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
  70668. * * 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
  70669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70670. * * 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
  70671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70672. * @param name defines the name of the mesh
  70673. * @param options defines the options used to create the mesh
  70674. * @param scene defines the hosting scene
  70675. * @returns the plane polygonal mesh
  70676. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70677. */
  70678. static CreateDisc(name: string, options: {
  70679. radius?: number;
  70680. tessellation?: number;
  70681. arc?: number;
  70682. updatable?: boolean;
  70683. sideOrientation?: number;
  70684. frontUVs?: Vector4;
  70685. backUVs?: Vector4;
  70686. }, scene?: Nullable<Scene>): Mesh;
  70687. /**
  70688. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70689. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70690. * * 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`)
  70691. * * The parameter `subdivisions` sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70692. * * 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
  70693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70694. * * 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
  70695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70696. * @param name defines the name of the mesh
  70697. * @param options defines the options used to create the mesh
  70698. * @param scene defines the hosting scene
  70699. * @returns the icosahedron mesh
  70700. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70701. */
  70702. static CreateIcoSphere(name: string, options: {
  70703. radius?: number;
  70704. radiusX?: number;
  70705. radiusY?: number;
  70706. radiusZ?: number;
  70707. flat?: boolean;
  70708. subdivisions?: number;
  70709. sideOrientation?: number;
  70710. frontUVs?: Vector4;
  70711. backUVs?: Vector4;
  70712. updatable?: boolean;
  70713. }, scene?: Nullable<Scene>): Mesh;
  70714. /**
  70715. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70716. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70717. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70718. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70719. * * 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
  70720. * * 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
  70721. * * 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
  70722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70723. * * 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
  70724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70725. * * 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
  70726. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70727. * * 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
  70728. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70730. * @param name defines the name of the mesh
  70731. * @param options defines the options used to create the mesh
  70732. * @param scene defines the hosting scene
  70733. * @returns the ribbon mesh
  70734. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70735. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70736. */
  70737. static CreateRibbon(name: string, options: {
  70738. pathArray: Vector3[][];
  70739. closeArray?: boolean;
  70740. closePath?: boolean;
  70741. offset?: number;
  70742. updatable?: boolean;
  70743. sideOrientation?: number;
  70744. frontUVs?: Vector4;
  70745. backUVs?: Vector4;
  70746. instance?: Mesh;
  70747. invertUV?: boolean;
  70748. uvs?: Vector2[];
  70749. colors?: Color4[];
  70750. }, scene?: Nullable<Scene>): Mesh;
  70751. /**
  70752. * Creates a cylinder or a cone mesh
  70753. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70754. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70755. * * 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.
  70756. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70757. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70758. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70759. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70760. * * 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).
  70761. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70762. * * 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).
  70763. * * 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
  70764. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70765. * * 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
  70766. * * 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.
  70767. * * If `enclose` is false, a ring surface is one element.
  70768. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70769. * * 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
  70770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70771. * * 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
  70772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70773. * @param name defines the name of the mesh
  70774. * @param options defines the options used to create the mesh
  70775. * @param scene defines the hosting scene
  70776. * @returns the cylinder mesh
  70777. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70778. */
  70779. static CreateCylinder(name: string, options: {
  70780. height?: number;
  70781. diameterTop?: number;
  70782. diameterBottom?: number;
  70783. diameter?: number;
  70784. tessellation?: number;
  70785. subdivisions?: number;
  70786. arc?: number;
  70787. faceColors?: Color4[];
  70788. faceUV?: Vector4[];
  70789. updatable?: boolean;
  70790. hasRings?: boolean;
  70791. enclose?: boolean;
  70792. cap?: number;
  70793. sideOrientation?: number;
  70794. frontUVs?: Vector4;
  70795. backUVs?: Vector4;
  70796. }, scene?: Nullable<Scene>): Mesh;
  70797. /**
  70798. * Creates a torus mesh
  70799. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70800. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70801. * * The parameter `tessellation` sets the number of torus sides (positive integer, default 16)
  70802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70805. * @param name defines the name of the mesh
  70806. * @param options defines the options used to create the mesh
  70807. * @param scene defines the hosting scene
  70808. * @returns the torus mesh
  70809. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70810. */
  70811. static CreateTorus(name: string, options: {
  70812. diameter?: number;
  70813. thickness?: number;
  70814. tessellation?: number;
  70815. updatable?: boolean;
  70816. sideOrientation?: number;
  70817. frontUVs?: Vector4;
  70818. backUVs?: Vector4;
  70819. }, scene?: Nullable<Scene>): Mesh;
  70820. /**
  70821. * Creates a torus knot mesh
  70822. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70823. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70824. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70825. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70827. * * 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
  70828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70829. * @param name defines the name of the mesh
  70830. * @param options defines the options used to create the mesh
  70831. * @param scene defines the hosting scene
  70832. * @returns the torus knot mesh
  70833. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70834. */
  70835. static CreateTorusKnot(name: string, options: {
  70836. radius?: number;
  70837. tube?: number;
  70838. radialSegments?: number;
  70839. tubularSegments?: number;
  70840. p?: number;
  70841. q?: number;
  70842. updatable?: boolean;
  70843. sideOrientation?: number;
  70844. frontUVs?: Vector4;
  70845. backUVs?: Vector4;
  70846. }, scene?: Nullable<Scene>): Mesh;
  70847. /**
  70848. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70849. * * 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
  70850. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70851. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70852. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70853. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70854. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70855. * * 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
  70856. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70859. * @param name defines the name of the new line system
  70860. * @param options defines the options used to create the line system
  70861. * @param scene defines the hosting scene
  70862. * @returns a new line system mesh
  70863. */
  70864. static CreateLineSystem(name: string, options: {
  70865. lines: Vector3[][];
  70866. updatable?: boolean;
  70867. instance?: Nullable<LinesMesh>;
  70868. colors?: Nullable<Color4[][]>;
  70869. useVertexAlpha?: boolean;
  70870. }, scene: Nullable<Scene>): LinesMesh;
  70871. /**
  70872. * Creates a line mesh
  70873. * 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
  70874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70875. * * The parameter `points` is an array successive Vector3
  70876. * * 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
  70877. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70878. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70879. * * When updating an instance, remember that only point positions can change, not the number of points
  70880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70881. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70882. * @param name defines the name of the new line system
  70883. * @param options defines the options used to create the line system
  70884. * @param scene defines the hosting scene
  70885. * @returns a new line mesh
  70886. */
  70887. static CreateLines(name: string, options: {
  70888. points: Vector3[];
  70889. updatable?: boolean;
  70890. instance?: Nullable<LinesMesh>;
  70891. colors?: Color4[];
  70892. useVertexAlpha?: boolean;
  70893. }, scene?: Nullable<Scene>): LinesMesh;
  70894. /**
  70895. * Creates a dashed line mesh
  70896. * * 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
  70897. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70898. * * The parameter `points` is an array successive Vector3
  70899. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70900. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70901. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70902. * * 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
  70903. * * When updating an instance, remember that only point positions can change, not the number of points
  70904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70905. * @param name defines the name of the mesh
  70906. * @param options defines the options used to create the mesh
  70907. * @param scene defines the hosting scene
  70908. * @returns the dashed line mesh
  70909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70910. */
  70911. static CreateDashedLines(name: string, options: {
  70912. points: Vector3[];
  70913. dashSize?: number;
  70914. gapSize?: number;
  70915. dashNb?: number;
  70916. updatable?: boolean;
  70917. instance?: LinesMesh;
  70918. }, scene?: Nullable<Scene>): LinesMesh;
  70919. /**
  70920. * 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.
  70921. * * 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.
  70922. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70923. * * 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.
  70924. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70925. * * 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
  70926. * * 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
  70927. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70929. * * 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
  70930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70932. * @param name defines the name of the mesh
  70933. * @param options defines the options used to create the mesh
  70934. * @param scene defines the hosting scene
  70935. * @returns the extruded shape mesh
  70936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70938. */
  70939. static ExtrudeShape(name: string, options: {
  70940. shape: Vector3[];
  70941. path: Vector3[];
  70942. scale?: number;
  70943. rotation?: number;
  70944. cap?: number;
  70945. updatable?: boolean;
  70946. sideOrientation?: number;
  70947. frontUVs?: Vector4;
  70948. backUVs?: Vector4;
  70949. instance?: Mesh;
  70950. invertUV?: boolean;
  70951. }, scene?: Nullable<Scene>): Mesh;
  70952. /**
  70953. * Creates an custom extruded shape mesh.
  70954. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70955. * * 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.
  70956. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70957. * * 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
  70958. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70959. * * 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
  70960. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70961. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70962. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70963. * * 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
  70964. * * 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
  70965. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70967. * * 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
  70968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70970. * @param name defines the name of the mesh
  70971. * @param options defines the options used to create the mesh
  70972. * @param scene defines the hosting scene
  70973. * @returns the custom extruded shape mesh
  70974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70975. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70977. */
  70978. static ExtrudeShapeCustom(name: string, options: {
  70979. shape: Vector3[];
  70980. path: Vector3[];
  70981. scaleFunction?: any;
  70982. rotationFunction?: any;
  70983. ribbonCloseArray?: boolean;
  70984. ribbonClosePath?: boolean;
  70985. cap?: number;
  70986. updatable?: boolean;
  70987. sideOrientation?: number;
  70988. frontUVs?: Vector4;
  70989. backUVs?: Vector4;
  70990. instance?: Mesh;
  70991. invertUV?: boolean;
  70992. }, scene?: Nullable<Scene>): Mesh;
  70993. /**
  70994. * Creates lathe mesh.
  70995. * The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe
  70996. * * 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
  70997. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70998. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70999. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71000. * * 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
  71001. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71002. * * 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
  71003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71004. * * 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
  71005. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71007. * @param name defines the name of the mesh
  71008. * @param options defines the options used to create the mesh
  71009. * @param scene defines the hosting scene
  71010. * @returns the lathe mesh
  71011. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71012. */
  71013. static CreateLathe(name: string, options: {
  71014. shape: Vector3[];
  71015. radius?: number;
  71016. tessellation?: number;
  71017. clip?: number;
  71018. arc?: number;
  71019. closed?: boolean;
  71020. updatable?: boolean;
  71021. sideOrientation?: number;
  71022. frontUVs?: Vector4;
  71023. backUVs?: Vector4;
  71024. cap?: number;
  71025. invertUV?: boolean;
  71026. }, scene?: Nullable<Scene>): Mesh;
  71027. /**
  71028. * Creates a tiled plane mesh
  71029. * * You can set a limited pattern arrangement with the tiles
  71030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71031. * * 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
  71032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71033. * @param name defines the name of the mesh
  71034. * @param options defines the options used to create the mesh
  71035. * @param scene defines the hosting scene
  71036. * @returns the plane mesh
  71037. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71038. */
  71039. static CreateTiledPlane(name: string, options: {
  71040. pattern?: number;
  71041. tileSize?: number;
  71042. tileWidth?: number;
  71043. tileHeight?: number;
  71044. size?: number;
  71045. width?: number;
  71046. height?: number;
  71047. alignHorizontal?: number;
  71048. alignVertical?: number;
  71049. sideOrientation?: number;
  71050. frontUVs?: Vector4;
  71051. backUVs?: Vector4;
  71052. updatable?: boolean;
  71053. }, scene?: Nullable<Scene>): Mesh;
  71054. /**
  71055. * Creates a plane mesh
  71056. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71057. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71058. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71060. * * 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
  71061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71062. * @param name defines the name of the mesh
  71063. * @param options defines the options used to create the mesh
  71064. * @param scene defines the hosting scene
  71065. * @returns the plane mesh
  71066. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71067. */
  71068. static CreatePlane(name: string, options: {
  71069. size?: number;
  71070. width?: number;
  71071. height?: number;
  71072. sideOrientation?: number;
  71073. frontUVs?: Vector4;
  71074. backUVs?: Vector4;
  71075. updatable?: boolean;
  71076. sourcePlane?: Plane;
  71077. }, scene?: Nullable<Scene>): Mesh;
  71078. /**
  71079. * Creates a ground mesh
  71080. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71081. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 ground mesh
  71087. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71088. */
  71089. static CreateGround(name: string, options: {
  71090. width?: number;
  71091. height?: number;
  71092. subdivisions?: number;
  71093. subdivisionsX?: number;
  71094. subdivisionsY?: number;
  71095. updatable?: boolean;
  71096. }, scene?: Nullable<Scene>): Mesh;
  71097. /**
  71098. * Creates a tiled ground mesh
  71099. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71100. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71101. * * 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
  71102. * * 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
  71103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71104. * @param name defines the name of the mesh
  71105. * @param options defines the options used to create the mesh
  71106. * @param scene defines the hosting scene
  71107. * @returns the tiled ground mesh
  71108. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71109. */
  71110. static CreateTiledGround(name: string, options: {
  71111. xmin: number;
  71112. zmin: number;
  71113. xmax: number;
  71114. zmax: number;
  71115. subdivisions?: {
  71116. w: number;
  71117. h: number;
  71118. };
  71119. precision?: {
  71120. w: number;
  71121. h: number;
  71122. };
  71123. updatable?: boolean;
  71124. }, scene?: Nullable<Scene>): Mesh;
  71125. /**
  71126. * Creates a ground mesh from a height map
  71127. * * The parameter `url` sets the URL of the height map image resource.
  71128. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71129. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71130. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71131. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71132. * * 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.
  71133. * * 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).
  71134. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71136. * @param name defines the name of the mesh
  71137. * @param url defines the url to the height map
  71138. * @param options defines the options used to create the mesh
  71139. * @param scene defines the hosting scene
  71140. * @returns the ground mesh
  71141. * @see https://doc.babylonjs.com/babylon101/height_map
  71142. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71143. */
  71144. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71145. width?: number;
  71146. height?: number;
  71147. subdivisions?: number;
  71148. minHeight?: number;
  71149. maxHeight?: number;
  71150. colorFilter?: Color3;
  71151. alphaFilter?: number;
  71152. updatable?: boolean;
  71153. onReady?: (mesh: GroundMesh) => void;
  71154. }, scene?: Nullable<Scene>): GroundMesh;
  71155. /**
  71156. * Creates a polygon mesh
  71157. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71158. * * 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
  71159. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71161. * * 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)
  71162. * * Remember you can only change the shape positions, not their number when updating a polygon
  71163. * @param name defines the name of the mesh
  71164. * @param options defines the options used to create the mesh
  71165. * @param scene defines the hosting scene
  71166. * @param earcutInjection can be used to inject your own earcut reference
  71167. * @returns the polygon mesh
  71168. */
  71169. static CreatePolygon(name: string, options: {
  71170. shape: Vector3[];
  71171. holes?: Vector3[][];
  71172. depth?: number;
  71173. faceUV?: Vector4[];
  71174. faceColors?: Color4[];
  71175. updatable?: boolean;
  71176. sideOrientation?: number;
  71177. frontUVs?: Vector4;
  71178. backUVs?: Vector4;
  71179. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71180. /**
  71181. * Creates an extruded polygon mesh, with depth in the Y direction.
  71182. * * 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)
  71183. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  71188. * @returns the polygon mesh
  71189. */
  71190. static ExtrudePolygon(name: string, options: {
  71191. shape: Vector3[];
  71192. holes?: Vector3[][];
  71193. depth?: number;
  71194. faceUV?: Vector4[];
  71195. faceColors?: Color4[];
  71196. updatable?: boolean;
  71197. sideOrientation?: number;
  71198. frontUVs?: Vector4;
  71199. backUVs?: Vector4;
  71200. wrap?: boolean;
  71201. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71202. /**
  71203. * Creates a tube mesh.
  71204. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71205. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71206. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71207. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71208. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overrides the parameter `radius`
  71209. * * 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)
  71210. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71211. * * 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
  71212. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71217. * @param name defines the name of the mesh
  71218. * @param options defines the options used to create the mesh
  71219. * @param scene defines the hosting scene
  71220. * @returns the tube mesh
  71221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71222. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71223. */
  71224. static CreateTube(name: string, options: {
  71225. path: Vector3[];
  71226. radius?: number;
  71227. tessellation?: number;
  71228. radiusFunction?: {
  71229. (i: number, distance: number): number;
  71230. };
  71231. cap?: number;
  71232. arc?: number;
  71233. updatable?: boolean;
  71234. sideOrientation?: number;
  71235. frontUVs?: Vector4;
  71236. backUVs?: Vector4;
  71237. instance?: Mesh;
  71238. invertUV?: boolean;
  71239. }, scene?: Nullable<Scene>): Mesh;
  71240. /**
  71241. * Creates a polyhedron mesh
  71242. * * 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
  71243. * * The parameter `size` (positive float, default 1) sets the polygon size
  71244. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71245. * * 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`
  71246. * * 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
  71247. * * 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)`)
  71248. * * 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
  71249. * * 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
  71250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71251. * * 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
  71252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71253. * @param name defines the name of the mesh
  71254. * @param options defines the options used to create the mesh
  71255. * @param scene defines the hosting scene
  71256. * @returns the polyhedron mesh
  71257. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71258. */
  71259. static CreatePolyhedron(name: string, options: {
  71260. type?: number;
  71261. size?: number;
  71262. sizeX?: number;
  71263. sizeY?: number;
  71264. sizeZ?: number;
  71265. custom?: any;
  71266. faceUV?: Vector4[];
  71267. faceColors?: Color4[];
  71268. flat?: boolean;
  71269. updatable?: boolean;
  71270. sideOrientation?: number;
  71271. frontUVs?: Vector4;
  71272. backUVs?: Vector4;
  71273. }, scene?: Nullable<Scene>): Mesh;
  71274. /**
  71275. * Creates a decal mesh.
  71276. * 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
  71277. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71278. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71279. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71280. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71281. * @param name defines the name of the mesh
  71282. * @param sourceMesh defines the mesh where the decal must be applied
  71283. * @param options defines the options used to create the mesh
  71284. * @param scene defines the hosting scene
  71285. * @returns the decal mesh
  71286. * @see https://doc.babylonjs.com/how_to/decals
  71287. */
  71288. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71289. position?: Vector3;
  71290. normal?: Vector3;
  71291. size?: Vector3;
  71292. angle?: number;
  71293. }): Mesh;
  71294. /**
  71295. * Creates a Capsule Mesh
  71296. * @param name defines the name of the mesh.
  71297. * @param options the constructors options used to shape the mesh.
  71298. * @param scene defines the scene the mesh is scoped to.
  71299. * @returns the capsule mesh
  71300. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71301. */
  71302. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. /**
  71307. * A simplifier interface for future simplification implementations
  71308. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71309. */
  71310. export interface ISimplifier {
  71311. /**
  71312. * Simplification of a given mesh according to the given settings.
  71313. * Since this requires computation, it is assumed that the function runs async.
  71314. * @param settings The settings of the simplification, including quality and distance
  71315. * @param successCallback A callback that will be called after the mesh was simplified.
  71316. * @param errorCallback in case of an error, this callback will be called. optional.
  71317. */
  71318. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71319. }
  71320. /**
  71321. * Expected simplification settings.
  71322. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71323. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71324. */
  71325. export interface ISimplificationSettings {
  71326. /**
  71327. * Gets or sets the expected quality
  71328. */
  71329. quality: number;
  71330. /**
  71331. * Gets or sets the distance when this optimized version should be used
  71332. */
  71333. distance: number;
  71334. /**
  71335. * Gets an already optimized mesh
  71336. */
  71337. optimizeMesh?: boolean;
  71338. }
  71339. /**
  71340. * Class used to specify simplification options
  71341. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71342. */
  71343. export class SimplificationSettings implements ISimplificationSettings {
  71344. /** expected quality */
  71345. quality: number;
  71346. /** distance when this optimized version should be used */
  71347. distance: number;
  71348. /** already optimized mesh */
  71349. optimizeMesh?: boolean | undefined;
  71350. /**
  71351. * Creates a SimplificationSettings
  71352. * @param quality expected quality
  71353. * @param distance distance when this optimized version should be used
  71354. * @param optimizeMesh already optimized mesh
  71355. */
  71356. constructor(
  71357. /** expected quality */
  71358. quality: number,
  71359. /** distance when this optimized version should be used */
  71360. distance: number,
  71361. /** already optimized mesh */
  71362. optimizeMesh?: boolean | undefined);
  71363. }
  71364. /**
  71365. * Interface used to define a simplification task
  71366. */
  71367. export interface ISimplificationTask {
  71368. /**
  71369. * Array of settings
  71370. */
  71371. settings: Array<ISimplificationSettings>;
  71372. /**
  71373. * Simplification type
  71374. */
  71375. simplificationType: SimplificationType;
  71376. /**
  71377. * Mesh to simplify
  71378. */
  71379. mesh: Mesh;
  71380. /**
  71381. * Callback called on success
  71382. */
  71383. successCallback?: () => void;
  71384. /**
  71385. * Defines if parallel processing can be used
  71386. */
  71387. parallelProcessing: boolean;
  71388. }
  71389. /**
  71390. * Queue used to order the simplification tasks
  71391. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71392. */
  71393. export class SimplificationQueue {
  71394. private _simplificationArray;
  71395. /**
  71396. * Gets a boolean indicating that the process is still running
  71397. */
  71398. running: boolean;
  71399. /**
  71400. * Creates a new queue
  71401. */
  71402. constructor();
  71403. /**
  71404. * Adds a new simplification task
  71405. * @param task defines a task to add
  71406. */
  71407. addTask(task: ISimplificationTask): void;
  71408. /**
  71409. * Execute next task
  71410. */
  71411. executeNext(): void;
  71412. /**
  71413. * Execute a simplification task
  71414. * @param task defines the task to run
  71415. */
  71416. runSimplification(task: ISimplificationTask): void;
  71417. private getSimplifier;
  71418. }
  71419. /**
  71420. * The implemented types of simplification
  71421. * At the moment only Quadratic Error Decimation is implemented
  71422. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71423. */
  71424. export enum SimplificationType {
  71425. /** Quadratic error decimation */
  71426. QUADRATIC = 0
  71427. }
  71428. /**
  71429. * An implementation of the Quadratic Error simplification algorithm.
  71430. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71431. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71432. * @author RaananW
  71433. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71434. */
  71435. export class QuadraticErrorSimplification implements ISimplifier {
  71436. private _mesh;
  71437. private triangles;
  71438. private vertices;
  71439. private references;
  71440. private _reconstructedMesh;
  71441. /** Gets or sets the number pf sync iterations */
  71442. syncIterations: number;
  71443. /** Gets or sets the aggressiveness of the simplifier */
  71444. aggressiveness: number;
  71445. /** Gets or sets the number of allowed iterations for decimation */
  71446. decimationIterations: number;
  71447. /** Gets or sets the espilon to use for bounding box computation */
  71448. boundingBoxEpsilon: number;
  71449. /**
  71450. * Creates a new QuadraticErrorSimplification
  71451. * @param _mesh defines the target mesh
  71452. */
  71453. constructor(_mesh: Mesh);
  71454. /**
  71455. * Simplification of a given mesh according to the given settings.
  71456. * Since this requires computation, it is assumed that the function runs async.
  71457. * @param settings The settings of the simplification, including quality and distance
  71458. * @param successCallback A callback that will be called after the mesh was simplified.
  71459. */
  71460. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71461. private runDecimation;
  71462. private initWithMesh;
  71463. private init;
  71464. private reconstructMesh;
  71465. private initDecimatedMesh;
  71466. private isFlipped;
  71467. private updateTriangles;
  71468. private identifyBorder;
  71469. private updateMesh;
  71470. private vertexError;
  71471. private calculateError;
  71472. }
  71473. }
  71474. declare module BABYLON {
  71475. interface Scene {
  71476. /** @hidden (Backing field) */
  71477. _simplificationQueue: SimplificationQueue;
  71478. /**
  71479. * Gets or sets the simplification queue attached to the scene
  71480. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71481. */
  71482. simplificationQueue: SimplificationQueue;
  71483. }
  71484. interface Mesh {
  71485. /**
  71486. * Simplify the mesh according to the given array of settings.
  71487. * Function will return immediately and will simplify async
  71488. * @param settings a collection of simplification settings
  71489. * @param parallelProcessing should all levels calculate parallel or one after the other
  71490. * @param simplificationType the type of simplification to run
  71491. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71492. * @returns the current mesh
  71493. */
  71494. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71495. }
  71496. /**
  71497. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71498. * created in a scene
  71499. */
  71500. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71501. /**
  71502. * The component name helpfull to identify the component in the list of scene components.
  71503. */
  71504. readonly name: string;
  71505. /**
  71506. * The scene the component belongs to.
  71507. */
  71508. scene: Scene;
  71509. /**
  71510. * Creates a new instance of the component for the given scene
  71511. * @param scene Defines the scene to register the component in
  71512. */
  71513. constructor(scene: Scene);
  71514. /**
  71515. * Registers the component in a given scene
  71516. */
  71517. register(): void;
  71518. /**
  71519. * Rebuilds the elements related to this component in case of
  71520. * context lost for instance.
  71521. */
  71522. rebuild(): void;
  71523. /**
  71524. * Disposes the component and the associated resources
  71525. */
  71526. dispose(): void;
  71527. private _beforeCameraUpdate;
  71528. }
  71529. }
  71530. declare module BABYLON {
  71531. interface Mesh {
  71532. /**
  71533. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71534. */
  71535. thinInstanceEnablePicking: boolean;
  71536. /**
  71537. * Creates a new thin instance
  71538. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71539. * @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
  71540. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71541. */
  71542. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71543. /**
  71544. * Adds the transformation (matrix) of the current mesh as a thin instance
  71545. * @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
  71546. * @returns the thin instance index number
  71547. */
  71548. thinInstanceAddSelf(refresh: boolean): number;
  71549. /**
  71550. * Registers a custom attribute to be used with thin instances
  71551. * @param kind name of the attribute
  71552. * @param stride size in floats of the attribute
  71553. */
  71554. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71555. /**
  71556. * Sets the matrix of a thin instance
  71557. * @param index index of the thin instance
  71558. * @param matrix matrix to set
  71559. * @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
  71560. */
  71561. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71562. /**
  71563. * Sets the value of a custom attribute for a thin instance
  71564. * @param kind name of the attribute
  71565. * @param index index of the thin instance
  71566. * @param value value to set
  71567. * @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
  71568. */
  71569. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71570. /**
  71571. * 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.
  71572. */
  71573. thinInstanceCount: number;
  71574. /**
  71575. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71576. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71577. * @param buffer buffer to set
  71578. * @param stride size in floats of each value of the buffer
  71579. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71580. */
  71581. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71582. /**
  71583. * Gets the list of world matrices
  71584. * @return an array containing all the world matrices from the thin instances
  71585. */
  71586. thinInstanceGetWorldMatrices(): Matrix[];
  71587. /**
  71588. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71589. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71590. */
  71591. thinInstanceBufferUpdated(kind: string): void;
  71592. /**
  71593. * Applies a partial update to a buffer directly on the GPU
  71594. * 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
  71595. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71596. * @param data the data to set in the GPU buffer
  71597. * @param offset the offset in the GPU buffer where to update the data
  71598. */
  71599. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71600. /**
  71601. * Refreshes the bounding info, taking into account all the thin instances defined
  71602. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71603. */
  71604. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71605. /** @hidden */
  71606. _thinInstanceInitializeUserStorage(): void;
  71607. /** @hidden */
  71608. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71609. /** @hidden */
  71610. _userThinInstanceBuffersStorage: {
  71611. data: {
  71612. [key: string]: Float32Array;
  71613. };
  71614. sizes: {
  71615. [key: string]: number;
  71616. };
  71617. vertexBuffers: {
  71618. [key: string]: Nullable<VertexBuffer>;
  71619. };
  71620. strides: {
  71621. [key: string]: number;
  71622. };
  71623. };
  71624. }
  71625. }
  71626. declare module BABYLON {
  71627. /**
  71628. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71629. */
  71630. export interface INavigationEnginePlugin {
  71631. /**
  71632. * plugin name
  71633. */
  71634. name: string;
  71635. /**
  71636. * Creates a navigation mesh
  71637. * @param meshes array of all the geometry used to compute the navigation mesh
  71638. * @param parameters bunch of parameters used to filter geometry
  71639. */
  71640. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71641. /**
  71642. * Create a navigation mesh debug mesh
  71643. * @param scene is where the mesh will be added
  71644. * @returns debug display mesh
  71645. */
  71646. createDebugNavMesh(scene: Scene): Mesh;
  71647. /**
  71648. * Get a navigation mesh constrained position, closest to the parameter position
  71649. * @param position world position
  71650. * @returns the closest point to position constrained by the navigation mesh
  71651. */
  71652. getClosestPoint(position: Vector3): Vector3;
  71653. /**
  71654. * Get a navigation mesh constrained position, closest to the parameter position
  71655. * @param position world position
  71656. * @param result output the closest point to position constrained by the navigation mesh
  71657. */
  71658. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71659. /**
  71660. * Get a navigation mesh constrained position, within a particular radius
  71661. * @param position world position
  71662. * @param maxRadius the maximum distance to the constrained world position
  71663. * @returns the closest point to position constrained by the navigation mesh
  71664. */
  71665. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71666. /**
  71667. * Get a navigation mesh constrained position, within a particular radius
  71668. * @param position world position
  71669. * @param maxRadius the maximum distance to the constrained world position
  71670. * @param result output the closest point to position constrained by the navigation mesh
  71671. */
  71672. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71673. /**
  71674. * Compute the final position from a segment made of destination-position
  71675. * @param position world position
  71676. * @param destination world position
  71677. * @returns the resulting point along the navmesh
  71678. */
  71679. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71680. /**
  71681. * Compute the final position from a segment made of destination-position
  71682. * @param position world position
  71683. * @param destination world position
  71684. * @param result output the resulting point along the navmesh
  71685. */
  71686. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71687. /**
  71688. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71689. * @param start world position
  71690. * @param end world position
  71691. * @returns array containing world position composing the path
  71692. */
  71693. computePath(start: Vector3, end: Vector3): Vector3[];
  71694. /**
  71695. * If this plugin is supported
  71696. * @returns true if plugin is supported
  71697. */
  71698. isSupported(): boolean;
  71699. /**
  71700. * Create a new Crowd so you can add agents
  71701. * @param maxAgents the maximum agent count in the crowd
  71702. * @param maxAgentRadius the maximum radius an agent can have
  71703. * @param scene to attach the crowd to
  71704. * @returns the crowd you can add agents to
  71705. */
  71706. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71707. /**
  71708. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71709. * The queries will try to find a solution within those bounds
  71710. * default is (1,1,1)
  71711. * @param extent x,y,z value that define the extent around the queries point of reference
  71712. */
  71713. setDefaultQueryExtent(extent: Vector3): void;
  71714. /**
  71715. * Get the Bounding box extent specified by setDefaultQueryExtent
  71716. * @returns the box extent values
  71717. */
  71718. getDefaultQueryExtent(): Vector3;
  71719. /**
  71720. * build the navmesh from a previously saved state using getNavmeshData
  71721. * @param data the Uint8Array returned by getNavmeshData
  71722. */
  71723. buildFromNavmeshData(data: Uint8Array): void;
  71724. /**
  71725. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71726. * @returns data the Uint8Array that can be saved and reused
  71727. */
  71728. getNavmeshData(): Uint8Array;
  71729. /**
  71730. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71731. * @param result output the box extent values
  71732. */
  71733. getDefaultQueryExtentToRef(result: Vector3): void;
  71734. /**
  71735. * Set the time step of the navigation tick update.
  71736. * Default is 1/60.
  71737. * A value of 0 will disable fixed time update
  71738. * @param newTimeStep the new timestep to apply to this world.
  71739. */
  71740. setTimeStep(newTimeStep: number): void;
  71741. /**
  71742. * Get the time step of the navigation tick update.
  71743. * @returns the current time step
  71744. */
  71745. getTimeStep(): number;
  71746. /**
  71747. * If delta time in navigation tick update is greater than the time step
  71748. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71749. * they will be discarded.
  71750. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71751. * @param newStepCount the maximum number of iterations
  71752. */
  71753. setMaximumSubStepCount(newStepCount: number): void;
  71754. /**
  71755. * Get the maximum number of iterations per navigation tick update
  71756. * @returns the maximum number of iterations
  71757. */
  71758. getMaximumSubStepCount(): number;
  71759. /**
  71760. * Release all resources
  71761. */
  71762. dispose(): void;
  71763. }
  71764. /**
  71765. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71766. */
  71767. export interface ICrowd {
  71768. /**
  71769. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71770. * You can attach anything to that node. The node position is updated in the scene update tick.
  71771. * @param pos world position that will be constrained by the navigation mesh
  71772. * @param parameters agent parameters
  71773. * @param transform hooked to the agent that will be update by the scene
  71774. * @returns agent index
  71775. */
  71776. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71777. /**
  71778. * Returns the agent position in world space
  71779. * @param index agent index returned by addAgent
  71780. * @returns world space position
  71781. */
  71782. getAgentPosition(index: number): Vector3;
  71783. /**
  71784. * Gets the agent position result in world space
  71785. * @param index agent index returned by addAgent
  71786. * @param result output world space position
  71787. */
  71788. getAgentPositionToRef(index: number, result: Vector3): void;
  71789. /**
  71790. * Gets the agent velocity in world space
  71791. * @param index agent index returned by addAgent
  71792. * @returns world space velocity
  71793. */
  71794. getAgentVelocity(index: number): Vector3;
  71795. /**
  71796. * Gets the agent velocity result in world space
  71797. * @param index agent index returned by addAgent
  71798. * @param result output world space velocity
  71799. */
  71800. getAgentVelocityToRef(index: number, result: Vector3): void;
  71801. /**
  71802. * Gets the agent next target point on the path
  71803. * @param index agent index returned by addAgent
  71804. * @returns world space position
  71805. */
  71806. getAgentNextTargetPath(index: number): Vector3;
  71807. /**
  71808. * Gets the agent state
  71809. * @param index agent index returned by addAgent
  71810. * @returns agent state
  71811. */
  71812. getAgentState(index: number): number;
  71813. /**
  71814. * returns true if the agent in over an off mesh link connection
  71815. * @param index agent index returned by addAgent
  71816. * @returns true if over an off mesh link connection
  71817. */
  71818. overOffmeshConnection(index: number): boolean;
  71819. /**
  71820. * Gets the agent next target point on the path
  71821. * @param index agent index returned by addAgent
  71822. * @param result output world space position
  71823. */
  71824. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71825. /**
  71826. * remove a particular agent previously created
  71827. * @param index agent index returned by addAgent
  71828. */
  71829. removeAgent(index: number): void;
  71830. /**
  71831. * get the list of all agents attached to this crowd
  71832. * @returns list of agent indices
  71833. */
  71834. getAgents(): number[];
  71835. /**
  71836. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71837. * @param deltaTime in seconds
  71838. */
  71839. update(deltaTime: number): void;
  71840. /**
  71841. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71842. * @param index agent index returned by addAgent
  71843. * @param destination targeted world position
  71844. */
  71845. agentGoto(index: number, destination: Vector3): void;
  71846. /**
  71847. * Teleport the agent to a new position
  71848. * @param index agent index returned by addAgent
  71849. * @param destination targeted world position
  71850. */
  71851. agentTeleport(index: number, destination: Vector3): void;
  71852. /**
  71853. * Update agent parameters
  71854. * @param index agent index returned by addAgent
  71855. * @param parameters agent parameters
  71856. */
  71857. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71858. /**
  71859. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71860. * The queries will try to find a solution within those bounds
  71861. * default is (1,1,1)
  71862. * @param extent x,y,z value that define the extent around the queries point of reference
  71863. */
  71864. setDefaultQueryExtent(extent: Vector3): void;
  71865. /**
  71866. * Get the Bounding box extent specified by setDefaultQueryExtent
  71867. * @returns the box extent values
  71868. */
  71869. getDefaultQueryExtent(): Vector3;
  71870. /**
  71871. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71872. * @param result output the box extent values
  71873. */
  71874. getDefaultQueryExtentToRef(result: Vector3): void;
  71875. /**
  71876. * Release all resources
  71877. */
  71878. dispose(): void;
  71879. }
  71880. /**
  71881. * Configures an agent
  71882. */
  71883. export interface IAgentParameters {
  71884. /**
  71885. * Agent radius. [Limit: >= 0]
  71886. */
  71887. radius: number;
  71888. /**
  71889. * Agent height. [Limit: > 0]
  71890. */
  71891. height: number;
  71892. /**
  71893. * Maximum allowed acceleration. [Limit: >= 0]
  71894. */
  71895. maxAcceleration: number;
  71896. /**
  71897. * Maximum allowed speed. [Limit: >= 0]
  71898. */
  71899. maxSpeed: number;
  71900. /**
  71901. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71902. */
  71903. collisionQueryRange: number;
  71904. /**
  71905. * The path visibility optimization range. [Limit: > 0]
  71906. */
  71907. pathOptimizationRange: number;
  71908. /**
  71909. * How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71910. */
  71911. separationWeight: number;
  71912. }
  71913. /**
  71914. * Configures the navigation mesh creation
  71915. */
  71916. export interface INavMeshParameters {
  71917. /**
  71918. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71919. */
  71920. cs: number;
  71921. /**
  71922. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71923. */
  71924. ch: number;
  71925. /**
  71926. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71927. */
  71928. walkableSlopeAngle: number;
  71929. /**
  71930. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71931. * be considered walkable. [Limit: >= 3] [Units: vx]
  71932. */
  71933. walkableHeight: number;
  71934. /**
  71935. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71936. */
  71937. walkableClimb: number;
  71938. /**
  71939. * The distance to erode/shrink the walkable area of the heightfield away from
  71940. * obstructions. [Limit: >=0] [Units: vx]
  71941. */
  71942. walkableRadius: number;
  71943. /**
  71944. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71945. */
  71946. maxEdgeLen: number;
  71947. /**
  71948. * The maximum distance a simplified contour's border edges should deviate
  71949. * the original raw contour. [Limit: >=0] [Units: vx]
  71950. */
  71951. maxSimplificationError: number;
  71952. /**
  71953. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71954. */
  71955. minRegionArea: number;
  71956. /**
  71957. * Any regions with a span count smaller than this value will, if possible,
  71958. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71959. */
  71960. mergeRegionArea: number;
  71961. /**
  71962. * The maximum number of vertices allowed for polygons generated during the
  71963. * contour to polygon conversion process. [Limit: >= 3]
  71964. */
  71965. maxVertsPerPoly: number;
  71966. /**
  71967. * Sets the sampling distance to use when generating the detail mesh.
  71968. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71969. */
  71970. detailSampleDist: number;
  71971. /**
  71972. * The maximum distance the detail mesh surface should deviate from heightfield
  71973. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71974. */
  71975. detailSampleMaxError: number;
  71976. }
  71977. }
  71978. declare module BABYLON {
  71979. /**
  71980. * RecastJS navigation plugin
  71981. */
  71982. export class RecastJSPlugin implements INavigationEnginePlugin {
  71983. /**
  71984. * Reference to the Recast library
  71985. */
  71986. bjsRECAST: any;
  71987. /**
  71988. * plugin name
  71989. */
  71990. name: string;
  71991. /**
  71992. * the first navmesh created. We might extend this to support multiple navmeshes
  71993. */
  71994. navMesh: any;
  71995. private _maximumSubStepCount;
  71996. private _timeStep;
  71997. /**
  71998. * Initializes the recastJS plugin
  71999. * @param recastInjection can be used to inject your own recast reference
  72000. */
  72001. constructor(recastInjection?: any);
  72002. /**
  72003. * Set the time step of the navigation tick update.
  72004. * Default is 1/60.
  72005. * A value of 0 will disable fixed time update
  72006. * @param newTimeStep the new timestep to apply to this world.
  72007. */
  72008. setTimeStep(newTimeStep?: number): void;
  72009. /**
  72010. * Get the time step of the navigation tick update.
  72011. * @returns the current time step
  72012. */
  72013. getTimeStep(): number;
  72014. /**
  72015. * If delta time in navigation tick update is greater than the time step
  72016. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72017. * they will be discarded.
  72018. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72019. * @param newStepCount the maximum number of iterations
  72020. */
  72021. setMaximumSubStepCount(newStepCount?: number): void;
  72022. /**
  72023. * Get the maximum number of iterations per navigation tick update
  72024. * @returns the maximum number of iterations
  72025. */
  72026. getMaximumSubStepCount(): number;
  72027. /**
  72028. * Creates a navigation mesh
  72029. * @param meshes array of all the geometry used to compute the navigation mesh
  72030. * @param parameters bunch of parameters used to filter geometry
  72031. */
  72032. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72033. /**
  72034. * Create a navigation mesh debug mesh
  72035. * @param scene is where the mesh will be added
  72036. * @returns debug display mesh
  72037. */
  72038. createDebugNavMesh(scene: Scene): Mesh;
  72039. /**
  72040. * Get a navigation mesh constrained position, closest to the parameter position
  72041. * @param position world position
  72042. * @returns the closest point to position constrained by the navigation mesh
  72043. */
  72044. getClosestPoint(position: Vector3): Vector3;
  72045. /**
  72046. * Get a navigation mesh constrained position, closest to the parameter position
  72047. * @param position world position
  72048. * @param result output the closest point to position constrained by the navigation mesh
  72049. */
  72050. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72051. /**
  72052. * Get a navigation mesh constrained position, within a particular radius
  72053. * @param position world position
  72054. * @param maxRadius the maximum distance to the constrained world position
  72055. * @returns the closest point to position constrained by the navigation mesh
  72056. */
  72057. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72058. /**
  72059. * Get a navigation mesh constrained position, within a particular radius
  72060. * @param position world position
  72061. * @param maxRadius the maximum distance to the constrained world position
  72062. * @param result output the closest point to position constrained by the navigation mesh
  72063. */
  72064. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72065. /**
  72066. * Compute the final position from a segment made of destination-position
  72067. * @param position world position
  72068. * @param destination world position
  72069. * @returns the resulting point along the navmesh
  72070. */
  72071. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72072. /**
  72073. * Compute the final position from a segment made of destination-position
  72074. * @param position world position
  72075. * @param destination world position
  72076. * @param result output the resulting point along the navmesh
  72077. */
  72078. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72079. /**
  72080. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72081. * @param start world position
  72082. * @param end world position
  72083. * @returns array containing world position composing the path
  72084. */
  72085. computePath(start: Vector3, end: Vector3): Vector3[];
  72086. /**
  72087. * Create a new Crowd so you can add agents
  72088. * @param maxAgents the maximum agent count in the crowd
  72089. * @param maxAgentRadius the maximum radius an agent can have
  72090. * @param scene to attach the crowd to
  72091. * @returns the crowd you can add agents to
  72092. */
  72093. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72094. /**
  72095. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72096. * The queries will try to find a solution within those bounds
  72097. * default is (1,1,1)
  72098. * @param extent x,y,z value that define the extent around the queries point of reference
  72099. */
  72100. setDefaultQueryExtent(extent: Vector3): void;
  72101. /**
  72102. * Get the Bounding box extent specified by setDefaultQueryExtent
  72103. * @returns the box extent values
  72104. */
  72105. getDefaultQueryExtent(): Vector3;
  72106. /**
  72107. * build the navmesh from a previously saved state using getNavmeshData
  72108. * @param data the Uint8Array returned by getNavmeshData
  72109. */
  72110. buildFromNavmeshData(data: Uint8Array): void;
  72111. /**
  72112. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72113. * @returns data the Uint8Array that can be saved and reused
  72114. */
  72115. getNavmeshData(): Uint8Array;
  72116. /**
  72117. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72118. * @param result output the box extent values
  72119. */
  72120. getDefaultQueryExtentToRef(result: Vector3): void;
  72121. /**
  72122. * Disposes
  72123. */
  72124. dispose(): void;
  72125. /**
  72126. * If this plugin is supported
  72127. * @returns true if plugin is supported
  72128. */
  72129. isSupported(): boolean;
  72130. }
  72131. /**
  72132. * Recast detour crowd implementation
  72133. */
  72134. export class RecastJSCrowd implements ICrowd {
  72135. /**
  72136. * Recast/detour plugin
  72137. */
  72138. bjsRECASTPlugin: RecastJSPlugin;
  72139. /**
  72140. * Link to the detour crowd
  72141. */
  72142. recastCrowd: any;
  72143. /**
  72144. * One transform per agent
  72145. */
  72146. transforms: TransformNode[];
  72147. /**
  72148. * All agents created
  72149. */
  72150. agents: number[];
  72151. /**
  72152. * Link to the scene is kept to unregister the crowd from the scene
  72153. */
  72154. private _scene;
  72155. /**
  72156. * Observer for crowd updates
  72157. */
  72158. private _onBeforeAnimationsObserver;
  72159. /**
  72160. * Constructor
  72161. * @param plugin recastJS plugin
  72162. * @param maxAgents the maximum agent count in the crowd
  72163. * @param maxAgentRadius the maximum radius an agent can have
  72164. * @param scene to attach the crowd to
  72165. * @returns the crowd you can add agents to
  72166. */
  72167. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72168. /**
  72169. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72170. * You can attach anything to that node. The node position is updated in the scene update tick.
  72171. * @param pos world position that will be constrained by the navigation mesh
  72172. * @param parameters agent parameters
  72173. * @param transform hooked to the agent that will be update by the scene
  72174. * @returns agent index
  72175. */
  72176. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72177. /**
  72178. * Returns the agent position in world space
  72179. * @param index agent index returned by addAgent
  72180. * @returns world space position
  72181. */
  72182. getAgentPosition(index: number): Vector3;
  72183. /**
  72184. * Returns the agent position result in world space
  72185. * @param index agent index returned by addAgent
  72186. * @param result output world space position
  72187. */
  72188. getAgentPositionToRef(index: number, result: Vector3): void;
  72189. /**
  72190. * Returns the agent velocity in world space
  72191. * @param index agent index returned by addAgent
  72192. * @returns world space velocity
  72193. */
  72194. getAgentVelocity(index: number): Vector3;
  72195. /**
  72196. * Returns the agent velocity result in world space
  72197. * @param index agent index returned by addAgent
  72198. * @param result output world space velocity
  72199. */
  72200. getAgentVelocityToRef(index: number, result: Vector3): void;
  72201. /**
  72202. * Returns the agent next target point on the path
  72203. * @param index agent index returned by addAgent
  72204. * @returns world space position
  72205. */
  72206. getAgentNextTargetPath(index: number): Vector3;
  72207. /**
  72208. * Returns the agent next target point on the path
  72209. * @param index agent index returned by addAgent
  72210. * @param result output world space position
  72211. */
  72212. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72213. /**
  72214. * Gets the agent state
  72215. * @param index agent index returned by addAgent
  72216. * @returns agent state
  72217. */
  72218. getAgentState(index: number): number;
  72219. /**
  72220. * returns true if the agent in over an off mesh link connection
  72221. * @param index agent index returned by addAgent
  72222. * @returns true if over an off mesh link connection
  72223. */
  72224. overOffmeshConnection(index: number): boolean;
  72225. /**
  72226. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72227. * @param index agent index returned by addAgent
  72228. * @param destination targeted world position
  72229. */
  72230. agentGoto(index: number, destination: Vector3): void;
  72231. /**
  72232. * Teleport the agent to a new position
  72233. * @param index agent index returned by addAgent
  72234. * @param destination targeted world position
  72235. */
  72236. agentTeleport(index: number, destination: Vector3): void;
  72237. /**
  72238. * Update agent parameters
  72239. * @param index agent index returned by addAgent
  72240. * @param parameters agent parameters
  72241. */
  72242. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72243. /**
  72244. * remove a particular agent previously created
  72245. * @param index agent index returned by addAgent
  72246. */
  72247. removeAgent(index: number): void;
  72248. /**
  72249. * get the list of all agents attached to this crowd
  72250. * @returns list of agent indices
  72251. */
  72252. getAgents(): number[];
  72253. /**
  72254. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72255. * @param deltaTime in seconds
  72256. */
  72257. update(deltaTime: number): void;
  72258. /**
  72259. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72260. * The queries will try to find a solution within those bounds
  72261. * default is (1,1,1)
  72262. * @param extent x,y,z value that define the extent around the queries point of reference
  72263. */
  72264. setDefaultQueryExtent(extent: Vector3): void;
  72265. /**
  72266. * Get the Bounding box extent specified by setDefaultQueryExtent
  72267. * @returns the box extent values
  72268. */
  72269. getDefaultQueryExtent(): Vector3;
  72270. /**
  72271. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72272. * @param result output the box extent values
  72273. */
  72274. getDefaultQueryExtentToRef(result: Vector3): void;
  72275. /**
  72276. * Release all resources
  72277. */
  72278. dispose(): void;
  72279. }
  72280. }
  72281. declare module BABYLON {
  72282. /**
  72283. * Class used to enable access to IndexedDB
  72284. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72285. */
  72286. export class Database implements IOfflineProvider {
  72287. private _callbackManifestChecked;
  72288. private _currentSceneUrl;
  72289. private _db;
  72290. private _enableSceneOffline;
  72291. private _enableTexturesOffline;
  72292. private _manifestVersionFound;
  72293. private _mustUpdateRessources;
  72294. private _hasReachedQuota;
  72295. private _isSupported;
  72296. private _idbFactory;
  72297. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72298. private static IsUASupportingBlobStorage;
  72299. /**
  72300. * Gets a boolean indicating if Database storage is enabled (off by default)
  72301. */
  72302. static IDBStorageEnabled: boolean;
  72303. /**
  72304. * Gets a boolean indicating if scene must be saved in the database
  72305. */
  72306. get enableSceneOffline(): boolean;
  72307. /**
  72308. * Gets a boolean indicating if textures must be saved in the database
  72309. */
  72310. get enableTexturesOffline(): boolean;
  72311. /**
  72312. * Creates a new Database
  72313. * @param urlToScene defines the url to load the scene
  72314. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72315. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72316. */
  72317. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72318. private static _ParseURL;
  72319. private static _ReturnFullUrlLocation;
  72320. private _checkManifestFile;
  72321. /**
  72322. * Open the database and make it available
  72323. * @param successCallback defines the callback to call on success
  72324. * @param errorCallback defines the callback to call on error
  72325. */
  72326. open(successCallback: () => void, errorCallback: () => void): void;
  72327. /**
  72328. * Loads an image from the database
  72329. * @param url defines the url to load from
  72330. * @param image defines the target DOM image
  72331. */
  72332. loadImage(url: string, image: HTMLImageElement): void;
  72333. private _loadImageFromDBAsync;
  72334. private _saveImageIntoDBAsync;
  72335. private _checkVersionFromDB;
  72336. private _loadVersionFromDBAsync;
  72337. private _saveVersionIntoDBAsync;
  72338. /**
  72339. * Loads a file from database
  72340. * @param url defines the URL to load from
  72341. * @param sceneLoaded defines a callback to call on success
  72342. * @param progressCallBack defines a callback to call when progress changed
  72343. * @param errorCallback defines a callback to call on error
  72344. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72345. */
  72346. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72347. private _loadFileAsync;
  72348. private _saveFileAsync;
  72349. /**
  72350. * Validates if xhr data is correct
  72351. * @param xhr defines the request to validate
  72352. * @param dataType defines the expected data type
  72353. * @returns true if data is correct
  72354. */
  72355. private static _ValidateXHRData;
  72356. }
  72357. }
  72358. declare module BABYLON {
  72359. /** @hidden */
  72360. export var gpuUpdateParticlesPixelShader: {
  72361. name: string;
  72362. shader: string;
  72363. };
  72364. }
  72365. declare module BABYLON {
  72366. /** @hidden */
  72367. export var gpuUpdateParticlesVertexShader: {
  72368. name: string;
  72369. shader: string;
  72370. };
  72371. }
  72372. declare module BABYLON {
  72373. /** @hidden */
  72374. export var clipPlaneFragmentDeclaration2: {
  72375. name: string;
  72376. shader: string;
  72377. };
  72378. }
  72379. declare module BABYLON {
  72380. /** @hidden */
  72381. export var gpuRenderParticlesPixelShader: {
  72382. name: string;
  72383. shader: string;
  72384. };
  72385. }
  72386. declare module BABYLON {
  72387. /** @hidden */
  72388. export var clipPlaneVertexDeclaration2: {
  72389. name: string;
  72390. shader: string;
  72391. };
  72392. }
  72393. declare module BABYLON {
  72394. /** @hidden */
  72395. export var gpuRenderParticlesVertexShader: {
  72396. name: string;
  72397. shader: string;
  72398. };
  72399. }
  72400. declare module BABYLON {
  72401. /**
  72402. * This represents a GPU particle system in Babylon
  72403. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72404. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72405. */
  72406. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72407. /**
  72408. * The layer mask we are rendering the particles through.
  72409. */
  72410. layerMask: number;
  72411. private _capacity;
  72412. private _activeCount;
  72413. private _currentActiveCount;
  72414. private _accumulatedCount;
  72415. private _renderEffect;
  72416. private _updateEffect;
  72417. private _buffer0;
  72418. private _buffer1;
  72419. private _spriteBuffer;
  72420. private _updateVAO;
  72421. private _renderVAO;
  72422. private _targetIndex;
  72423. private _sourceBuffer;
  72424. private _targetBuffer;
  72425. private _currentRenderId;
  72426. private _started;
  72427. private _stopped;
  72428. private _timeDelta;
  72429. private _randomTexture;
  72430. private _randomTexture2;
  72431. private _attributesStrideSize;
  72432. private _updateEffectOptions;
  72433. private _randomTextureSize;
  72434. private _actualFrame;
  72435. private _customEffect;
  72436. private readonly _rawTextureWidth;
  72437. /**
  72438. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72439. */
  72440. static get IsSupported(): boolean;
  72441. /**
  72442. * An event triggered when the system is disposed.
  72443. */
  72444. onDisposeObservable: Observable<IParticleSystem>;
  72445. /**
  72446. * An event triggered when the system is stopped
  72447. */
  72448. onStoppedObservable: Observable<IParticleSystem>;
  72449. /**
  72450. * Gets the maximum number of particles active at the same time.
  72451. * @returns The max number of active particles.
  72452. */
  72453. getCapacity(): number;
  72454. /**
  72455. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72456. * to override the particles.
  72457. */
  72458. forceDepthWrite: boolean;
  72459. /**
  72460. * Gets or set the number of active particles
  72461. */
  72462. get activeParticleCount(): number;
  72463. set activeParticleCount(value: number);
  72464. private _preWarmDone;
  72465. /**
  72466. * Specifies if the particles are updated in emitter local space or world space.
  72467. */
  72468. isLocal: boolean;
  72469. /** Gets or sets a matrix to use to compute projection */
  72470. defaultProjectionMatrix: Matrix;
  72471. /**
  72472. * Is this system ready to be used/rendered
  72473. * @return true if the system is ready
  72474. */
  72475. isReady(): boolean;
  72476. /**
  72477. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72478. * @returns True if it has been started, otherwise false.
  72479. */
  72480. isStarted(): boolean;
  72481. /**
  72482. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72483. * @returns True if it has been stopped, otherwise false.
  72484. */
  72485. isStopped(): boolean;
  72486. /**
  72487. * Gets a boolean indicating that the system is stopping
  72488. * @returns true if the system is currently stopping
  72489. */
  72490. isStopping(): boolean;
  72491. /**
  72492. * Gets the number of particles active at the same time.
  72493. * @returns The number of active particles.
  72494. */
  72495. getActiveCount(): number;
  72496. /**
  72497. * Starts the particle system and begins to emit
  72498. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72499. */
  72500. start(delay?: number): void;
  72501. /**
  72502. * Stops the particle system.
  72503. */
  72504. stop(): void;
  72505. /**
  72506. * Remove all active particles
  72507. */
  72508. reset(): void;
  72509. /**
  72510. * Returns the string "GPUParticleSystem"
  72511. * @returns a string containing the class name
  72512. */
  72513. getClassName(): string;
  72514. /**
  72515. * Gets the custom effect used to render the particles
  72516. * @param blendMode Blend mode for which the effect should be retrieved
  72517. * @returns The effect
  72518. */
  72519. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72520. /**
  72521. * Sets the custom effect used to render the particles
  72522. * @param effect The effect to set
  72523. * @param blendMode Blend mode for which the effect should be set
  72524. */
  72525. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72526. /** @hidden */
  72527. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72528. /**
  72529. * Observable that will be called just before the particles are drawn
  72530. */
  72531. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72532. /**
  72533. * Gets the name of the particle vertex shader
  72534. */
  72535. get vertexShaderName(): string;
  72536. private _colorGradientsTexture;
  72537. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72538. /**
  72539. * Adds a new color gradient
  72540. * @param gradient defines the gradient to use (between 0 and 1)
  72541. * @param color1 defines the color to affect to the specified gradient
  72542. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72543. * @returns the current particle system
  72544. */
  72545. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72546. private _refreshColorGradient;
  72547. /** Force the system to rebuild all gradients that need to be resync */
  72548. forceRefreshGradients(): void;
  72549. /**
  72550. * Remove a specific color gradient
  72551. * @param gradient defines the gradient to remove
  72552. * @returns the current particle system
  72553. */
  72554. removeColorGradient(gradient: number): GPUParticleSystem;
  72555. private _angularSpeedGradientsTexture;
  72556. private _sizeGradientsTexture;
  72557. private _velocityGradientsTexture;
  72558. private _limitVelocityGradientsTexture;
  72559. private _dragGradientsTexture;
  72560. private _addFactorGradient;
  72561. /**
  72562. * Adds a new size gradient
  72563. * @param gradient defines the gradient to use (between 0 and 1)
  72564. * @param factor defines the size factor to affect to the specified gradient
  72565. * @returns the current particle system
  72566. */
  72567. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72568. /**
  72569. * Remove a specific size gradient
  72570. * @param gradient defines the gradient to remove
  72571. * @returns the current particle system
  72572. */
  72573. removeSizeGradient(gradient: number): GPUParticleSystem;
  72574. private _refreshFactorGradient;
  72575. /**
  72576. * Adds a new angular speed gradient
  72577. * @param gradient defines the gradient to use (between 0 and 1)
  72578. * @param factor defines the angular speed to affect to the specified gradient
  72579. * @returns the current particle system
  72580. */
  72581. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72582. /**
  72583. * Remove a specific angular speed gradient
  72584. * @param gradient defines the gradient to remove
  72585. * @returns the current particle system
  72586. */
  72587. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72588. /**
  72589. * Adds a new velocity gradient
  72590. * @param gradient defines the gradient to use (between 0 and 1)
  72591. * @param factor defines the velocity to affect to the specified gradient
  72592. * @returns the current particle system
  72593. */
  72594. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72595. /**
  72596. * Remove a specific velocity gradient
  72597. * @param gradient defines the gradient to remove
  72598. * @returns the current particle system
  72599. */
  72600. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72601. /**
  72602. * Adds a new limit velocity gradient
  72603. * @param gradient defines the gradient to use (between 0 and 1)
  72604. * @param factor defines the limit velocity value to affect to the specified gradient
  72605. * @returns the current particle system
  72606. */
  72607. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72608. /**
  72609. * Remove a specific limit velocity gradient
  72610. * @param gradient defines the gradient to remove
  72611. * @returns the current particle system
  72612. */
  72613. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72614. /**
  72615. * Adds a new drag gradient
  72616. * @param gradient defines the gradient to use (between 0 and 1)
  72617. * @param factor defines the drag value to affect to the specified gradient
  72618. * @returns the current particle system
  72619. */
  72620. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72621. /**
  72622. * Remove a specific drag gradient
  72623. * @param gradient defines the gradient to remove
  72624. * @returns the current particle system
  72625. */
  72626. removeDragGradient(gradient: number): GPUParticleSystem;
  72627. /**
  72628. * Not supported by GPUParticleSystem
  72629. * @param gradient defines the gradient to use (between 0 and 1)
  72630. * @param factor defines the emit rate value to affect to the specified gradient
  72631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72632. * @returns the current particle system
  72633. */
  72634. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72635. /**
  72636. * Not supported by GPUParticleSystem
  72637. * @param gradient defines the gradient to remove
  72638. * @returns the current particle system
  72639. */
  72640. removeEmitRateGradient(gradient: number): IParticleSystem;
  72641. /**
  72642. * Not supported by GPUParticleSystem
  72643. * @param gradient defines the gradient to use (between 0 and 1)
  72644. * @param factor defines the start size value to affect to the specified gradient
  72645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72646. * @returns the current particle system
  72647. */
  72648. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72649. /**
  72650. * Not supported by GPUParticleSystem
  72651. * @param gradient defines the gradient to remove
  72652. * @returns the current particle system
  72653. */
  72654. removeStartSizeGradient(gradient: number): IParticleSystem;
  72655. /**
  72656. * Not supported by GPUParticleSystem
  72657. * @param gradient defines the gradient to use (between 0 and 1)
  72658. * @param min defines the color remap minimal range
  72659. * @param max defines the color remap maximal range
  72660. * @returns the current particle system
  72661. */
  72662. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72663. /**
  72664. * Not supported by GPUParticleSystem
  72665. * @param gradient defines the gradient to remove
  72666. * @returns the current particle system
  72667. */
  72668. removeColorRemapGradient(): IParticleSystem;
  72669. /**
  72670. * Not supported by GPUParticleSystem
  72671. * @param gradient defines the gradient to use (between 0 and 1)
  72672. * @param min defines the alpha remap minimal range
  72673. * @param max defines the alpha remap maximal range
  72674. * @returns the current particle system
  72675. */
  72676. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72677. /**
  72678. * Not supported by GPUParticleSystem
  72679. * @param gradient defines the gradient to remove
  72680. * @returns the current particle system
  72681. */
  72682. removeAlphaRemapGradient(): IParticleSystem;
  72683. /**
  72684. * Not supported by GPUParticleSystem
  72685. * @param gradient defines the gradient to use (between 0 and 1)
  72686. * @param color defines the color to affect to the specified gradient
  72687. * @returns the current particle system
  72688. */
  72689. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72690. /**
  72691. * Not supported by GPUParticleSystem
  72692. * @param gradient defines the gradient to remove
  72693. * @returns the current particle system
  72694. */
  72695. removeRampGradient(): IParticleSystem;
  72696. /**
  72697. * Not supported by GPUParticleSystem
  72698. * @returns the list of ramp gradients
  72699. */
  72700. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72701. /**
  72702. * Not supported by GPUParticleSystem
  72703. * Gets or sets a boolean indicating that ramp gradients must be used
  72704. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72705. */
  72706. get useRampGradients(): boolean;
  72707. set useRampGradients(value: boolean);
  72708. /**
  72709. * Not supported by GPUParticleSystem
  72710. * @param gradient defines the gradient to use (between 0 and 1)
  72711. * @param factor defines the life time factor to affect to the specified gradient
  72712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72713. * @returns the current particle system
  72714. */
  72715. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72716. /**
  72717. * Not supported by GPUParticleSystem
  72718. * @param gradient defines the gradient to remove
  72719. * @returns the current particle system
  72720. */
  72721. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72722. /**
  72723. * Instantiates a GPU particle system.
  72724. * 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.
  72725. * @param name The name of the particle system
  72726. * @param options The options used to create the system
  72727. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72728. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72729. * @param customEffect a custom effect used to change the way particles are rendered by default
  72730. */
  72731. constructor(name: string, options: Partial<{
  72732. capacity: number;
  72733. randomTextureSize: number;
  72734. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72735. protected _reset(): void;
  72736. private _createUpdateVAO;
  72737. private _createRenderVAO;
  72738. private _initialize;
  72739. /** @hidden */
  72740. _recreateUpdateEffect(): void;
  72741. private _getEffect;
  72742. /**
  72743. * Fill the defines array according to the current settings of the particle system
  72744. * @param defines Array to be updated
  72745. * @param blendMode blend mode to take into account when updating the array
  72746. */
  72747. fillDefines(defines: Array<string>, blendMode?: number): void;
  72748. /**
  72749. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72750. * @param uniforms Uniforms array to fill
  72751. * @param attributes Attributes array to fill
  72752. * @param samplers Samplers array to fill
  72753. */
  72754. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72755. /** @hidden */
  72756. _recreateRenderEffect(): Effect;
  72757. /**
  72758. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72759. * @param preWarm defines if we are in the pre-warmimg phase
  72760. */
  72761. animate(preWarm?: boolean): void;
  72762. private _createFactorGradientTexture;
  72763. private _createSizeGradientTexture;
  72764. private _createAngularSpeedGradientTexture;
  72765. private _createVelocityGradientTexture;
  72766. private _createLimitVelocityGradientTexture;
  72767. private _createDragGradientTexture;
  72768. private _createColorGradientTexture;
  72769. /**
  72770. * Renders the particle system in its current state
  72771. * @param preWarm defines if the system should only update the particles but not render them
  72772. * @returns the current number of particles
  72773. */
  72774. render(preWarm?: boolean): number;
  72775. /**
  72776. * Rebuilds the particle system
  72777. */
  72778. rebuild(): void;
  72779. private _releaseBuffers;
  72780. private _releaseVAOs;
  72781. /**
  72782. * Disposes the particle system and free the associated resources
  72783. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72784. */
  72785. dispose(disposeTexture?: boolean): void;
  72786. /**
  72787. * Clones the particle system.
  72788. * @param name The name of the cloned object
  72789. * @param newEmitter The new emitter to use
  72790. * @returns the cloned particle system
  72791. */
  72792. clone(name: string, newEmitter: any): GPUParticleSystem;
  72793. /**
  72794. * Serializes the particle system to a JSON object
  72795. * @param serializeTexture defines if the texture must be serialized as well
  72796. * @returns the JSON object
  72797. */
  72798. serialize(serializeTexture?: boolean): any;
  72799. /**
  72800. * Parses a JSON object to create a GPU particle system.
  72801. * @param parsedParticleSystem The JSON object to parse
  72802. * @param sceneOrEngine The scene or the engine to create the particle system in
  72803. * @param rootUrl The root url to use to load external dependencies like texture
  72804. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72805. * @returns the parsed GPU particle system
  72806. */
  72807. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72808. }
  72809. }
  72810. declare module BABYLON {
  72811. /**
  72812. * Represents a set of particle systems working together to create a specific effect
  72813. */
  72814. export class ParticleSystemSet implements IDisposable {
  72815. /**
  72816. * Gets or sets base Assets URL
  72817. */
  72818. static BaseAssetsUrl: string;
  72819. private _emitterCreationOptions;
  72820. private _emitterNode;
  72821. /**
  72822. * Gets the particle system list
  72823. */
  72824. systems: IParticleSystem[];
  72825. /**
  72826. * Gets the emitter node used with this set
  72827. */
  72828. get emitterNode(): Nullable<TransformNode>;
  72829. /**
  72830. * Creates a new emitter mesh as a sphere
  72831. * @param options defines the options used to create the sphere
  72832. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72833. * @param scene defines the hosting scene
  72834. */
  72835. setEmitterAsSphere(options: {
  72836. diameter: number;
  72837. segments: number;
  72838. color: Color3;
  72839. }, renderingGroupId: number, scene: Scene): void;
  72840. /**
  72841. * Starts all particle systems of the set
  72842. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72843. */
  72844. start(emitter?: AbstractMesh): void;
  72845. /**
  72846. * Release all associated resources
  72847. */
  72848. dispose(): void;
  72849. /**
  72850. * Serialize the set into a JSON compatible object
  72851. * @param serializeTexture defines if the texture must be serialized as well
  72852. * @returns a JSON compatible representation of the set
  72853. */
  72854. serialize(serializeTexture?: boolean): any;
  72855. /**
  72856. * Parse a new ParticleSystemSet from a serialized source
  72857. * @param data defines a JSON compatible representation of the set
  72858. * @param scene defines the hosting scene
  72859. * @param gpu defines if we want GPU particles or CPU particles
  72860. * @returns a new ParticleSystemSet
  72861. */
  72862. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72863. }
  72864. }
  72865. declare module BABYLON {
  72866. /**
  72867. * This class is made for on one-liner static method to help creating particle system set.
  72868. */
  72869. export class ParticleHelper {
  72870. /**
  72871. * Gets or sets base Assets URL
  72872. */
  72873. static BaseAssetsUrl: string;
  72874. /** Define the Url to load snippets */
  72875. static SnippetUrl: string;
  72876. /**
  72877. * Create a default particle system that you can tweak
  72878. * @param emitter defines the emitter to use
  72879. * @param capacity defines the system capacity (default is 500 particles)
  72880. * @param scene defines the hosting scene
  72881. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72882. * @returns the new Particle system
  72883. */
  72884. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72885. /**
  72886. * This is the main static method (one-liner) of this helper to create different particle systems
  72887. * @param type This string represents the type to the particle system to create
  72888. * @param scene The scene where the particle system should live
  72889. * @param gpu If the system will use gpu
  72890. * @returns the ParticleSystemSet created
  72891. */
  72892. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72893. /**
  72894. * Static function used to export a particle system to a ParticleSystemSet variable.
  72895. * Please note that the emitter shape is not exported
  72896. * @param systems defines the particle systems to export
  72897. * @returns the created particle system set
  72898. */
  72899. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72900. /**
  72901. * Creates a particle system from a snippet saved in a remote file
  72902. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72903. * @param url defines the url to load from
  72904. * @param scene defines the hosting scene
  72905. * @param gpu If the system will use gpu
  72906. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72907. * @returns a promise that will resolve to the new particle system
  72908. */
  72909. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72910. /**
  72911. * Creates a particle system from a snippet saved by the particle system editor
  72912. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72913. * @param scene defines the hosting scene
  72914. * @param gpu If the system will use gpu
  72915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72916. * @returns a promise that will resolve to the new particle system
  72917. */
  72918. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72919. }
  72920. }
  72921. declare module BABYLON {
  72922. interface Engine {
  72923. /**
  72924. * Create an effect to use with particle systems.
  72925. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72926. * the particle system for which you want to create a custom effect in the last parameter
  72927. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72928. * @param uniformsNames defines a list of attribute names
  72929. * @param samplers defines an array of string used to represent textures
  72930. * @param defines defines the string containing the defines to use to compile the shaders
  72931. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  72932. * @param onCompiled defines a function to call when the effect creation is successful
  72933. * @param onError defines a function to call when the effect creation has failed
  72934. * @param particleSystem the particle system you want to create the effect for
  72935. * @returns the new Effect
  72936. */
  72937. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72938. }
  72939. interface Mesh {
  72940. /**
  72941. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72942. * @returns an array of IParticleSystem
  72943. */
  72944. getEmittedParticleSystems(): IParticleSystem[];
  72945. /**
  72946. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72947. * @returns an array of IParticleSystem
  72948. */
  72949. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72950. }
  72951. }
  72952. declare module BABYLON {
  72953. /** Defines the 4 color options */
  72954. export enum PointColor {
  72955. /** color value */
  72956. Color = 2,
  72957. /** uv value */
  72958. UV = 1,
  72959. /** random value */
  72960. Random = 0,
  72961. /** stated value */
  72962. Stated = 3
  72963. }
  72964. /**
  72965. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72966. * 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.
  72967. * The PointCloudSystem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72968. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72969. *
  72970. * Full documentation here : TO BE ENTERED
  72971. */
  72972. export class PointsCloudSystem implements IDisposable {
  72973. /**
  72974. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72975. * Example : var p = SPS.particles[i];
  72976. */
  72977. particles: CloudPoint[];
  72978. /**
  72979. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72980. */
  72981. nbParticles: number;
  72982. /**
  72983. * This a counter for your own usage. It's not set by any SPS functions.
  72984. */
  72985. counter: number;
  72986. /**
  72987. * The PCS name. This name is also given to the underlying mesh.
  72988. */
  72989. name: string;
  72990. /**
  72991. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are available.
  72992. */
  72993. mesh: Mesh;
  72994. /**
  72995. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72996. * Please read :
  72997. */
  72998. vars: any;
  72999. /**
  73000. * @hidden
  73001. */
  73002. _size: number;
  73003. private _scene;
  73004. private _promises;
  73005. private _positions;
  73006. private _indices;
  73007. private _normals;
  73008. private _colors;
  73009. private _uvs;
  73010. private _indices32;
  73011. private _positions32;
  73012. private _colors32;
  73013. private _uvs32;
  73014. private _updatable;
  73015. private _isVisibilityBoxLocked;
  73016. private _alwaysVisible;
  73017. private _groups;
  73018. private _groupCounter;
  73019. private _computeParticleColor;
  73020. private _computeParticleTexture;
  73021. private _computeParticleRotation;
  73022. private _computeBoundingBox;
  73023. private _isReady;
  73024. /**
  73025. * Creates a PCS (Points Cloud System) object
  73026. * @param name (String) is the PCS name, this will be the underlying mesh name
  73027. * @param pointSize (number) is the size for each point
  73028. * @param scene (Scene) is the scene in which the PCS is added
  73029. * @param options defines the options of the PCS e.g.
  73030. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73031. */
  73032. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73033. updatable?: boolean;
  73034. });
  73035. /**
  73036. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73037. * If no points were added to the PCS, the returned mesh is just a single point.
  73038. * @returns a promise for the created mesh
  73039. */
  73040. buildMeshAsync(): Promise<Mesh>;
  73041. /**
  73042. * @hidden
  73043. */
  73044. private _buildMesh;
  73045. private _addParticle;
  73046. private _randomUnitVector;
  73047. private _getColorIndicesForCoord;
  73048. private _setPointsColorOrUV;
  73049. private _colorFromTexture;
  73050. private _calculateDensity;
  73051. /**
  73052. * Adds points to the PCS in random positions within a unit sphere
  73053. * @param nb (positive integer) the number of particles to be created from this model
  73054. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73055. * @returns the number of groups in the system
  73056. */
  73057. addPoints(nb: number, pointFunction?: any): number;
  73058. /**
  73059. * Adds points to the PCS from the surface of the model shape
  73060. * @param mesh is any Mesh object that will be used as a surface model for the points
  73061. * @param nb (positive integer) the number of particles to be created from this model
  73062. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73063. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73064. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73065. * @returns the number of groups in the system
  73066. */
  73067. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73068. /**
  73069. * Adds points to the PCS inside the model shape
  73070. * @param mesh is any Mesh object that will be used as a surface model for the points
  73071. * @param nb (positive integer) the number of particles to be created from this model
  73072. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73073. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73074. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73075. * @returns the number of groups in the system
  73076. */
  73077. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73078. /**
  73079. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73080. * This method calls `updateParticle()` for each particle of the SPS.
  73081. * For an animated SPS, it is usually called within the render loop.
  73082. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73083. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73084. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73085. * @returns the PCS.
  73086. */
  73087. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73088. /**
  73089. * Disposes the PCS.
  73090. */
  73091. dispose(): void;
  73092. /**
  73093. * Visibility helper : Recomputes the visible size according to the mesh bounding box
  73094. * doc :
  73095. * @returns the PCS.
  73096. */
  73097. refreshVisibleSize(): PointsCloudSystem;
  73098. /**
  73099. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73100. * @param size the size (float) of the visibility box
  73101. * note : this doesn't lock the PCS mesh bounding box.
  73102. * doc :
  73103. */
  73104. setVisibilityBox(size: number): void;
  73105. /**
  73106. * Gets whether the PCS is always visible or not
  73107. * doc :
  73108. */
  73109. get isAlwaysVisible(): boolean;
  73110. /**
  73111. * Sets the PCS as always visible or not
  73112. * doc :
  73113. */
  73114. set isAlwaysVisible(val: boolean);
  73115. /**
  73116. * Tells to `setParticles()` to compute the particle rotations or not
  73117. * Default value : false. The PCS is faster when it's set to false
  73118. * Note : particle rotations are only applied to parent particles
  73119. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73120. */
  73121. set computeParticleRotation(val: boolean);
  73122. /**
  73123. * Tells to `setParticles()` to compute the particle colors or not.
  73124. * Default value : true. The PCS is faster when it's set to false.
  73125. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73126. */
  73127. set computeParticleColor(val: boolean);
  73128. set computeParticleTexture(val: boolean);
  73129. /**
  73130. * Gets if `setParticles()` computes the particle colors or not.
  73131. * Default value : false. The PCS is faster when it's set to false.
  73132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73133. */
  73134. get computeParticleColor(): boolean;
  73135. /**
  73136. * Gets if `setParticles()` computes the particle textures or not.
  73137. * Default value : false. The PCS is faster when it's set to false.
  73138. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73139. */
  73140. get computeParticleTexture(): boolean;
  73141. /**
  73142. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73143. */
  73144. set computeBoundingBox(val: boolean);
  73145. /**
  73146. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73147. */
  73148. get computeBoundingBox(): boolean;
  73149. /**
  73150. * This function does nothing. It may be overwritten to set all the particle first values.
  73151. * The PCS doesn't call this function, you may have to call it by your own.
  73152. * doc :
  73153. */
  73154. initParticles(): void;
  73155. /**
  73156. * This function does nothing. It may be overwritten to recycle a particle
  73157. * The PCS doesn't call this function, you can to call it
  73158. * doc :
  73159. * @param particle The particle to recycle
  73160. * @returns the recycled particle
  73161. */
  73162. recycleParticle(particle: CloudPoint): CloudPoint;
  73163. /**
  73164. * Updates a particle : this function should be overwritten by the user.
  73165. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73166. * doc :
  73167. * @example : just set a particle position or velocity and recycle conditions
  73168. * @param particle The particle to update
  73169. * @returns the updated particle
  73170. */
  73171. updateParticle(particle: CloudPoint): CloudPoint;
  73172. /**
  73173. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73174. * This does nothing and may be overwritten by the user.
  73175. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73176. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73177. * @param update the boolean update value actually passed to setParticles()
  73178. */
  73179. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73180. /**
  73181. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73182. * This will be passed three parameters.
  73183. * This does nothing and may be overwritten by the user.
  73184. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73185. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73186. * @param update the boolean update value actually passed to setParticles()
  73187. */
  73188. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73189. }
  73190. }
  73191. declare module BABYLON {
  73192. /**
  73193. * Represents one particle of a points cloud system.
  73194. */
  73195. export class CloudPoint {
  73196. /**
  73197. * particle global index
  73198. */
  73199. idx: number;
  73200. /**
  73201. * The color of the particle
  73202. */
  73203. color: Nullable<Color4>;
  73204. /**
  73205. * The world space position of the particle.
  73206. */
  73207. position: Vector3;
  73208. /**
  73209. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73210. */
  73211. rotation: Vector3;
  73212. /**
  73213. * The world space rotation quaternion of the particle.
  73214. */
  73215. rotationQuaternion: Nullable<Quaternion>;
  73216. /**
  73217. * The uv of the particle.
  73218. */
  73219. uv: Nullable<Vector2>;
  73220. /**
  73221. * The current speed of the particle.
  73222. */
  73223. velocity: Vector3;
  73224. /**
  73225. * The pivot point in the particle local space.
  73226. */
  73227. pivot: Vector3;
  73228. /**
  73229. * Must the particle be translated from its pivot point in its local space ?
  73230. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73231. * Default : false
  73232. */
  73233. translateFromPivot: boolean;
  73234. /**
  73235. * Index of this particle in the global "positions" array (Internal use)
  73236. * @hidden
  73237. */
  73238. _pos: number;
  73239. /**
  73240. * @hidden Index of this particle in the global "indices" array (Internal use)
  73241. */
  73242. _ind: number;
  73243. /**
  73244. * Group this particle belongs to
  73245. */
  73246. _group: PointsGroup;
  73247. /**
  73248. * Group id of this particle
  73249. */
  73250. groupId: number;
  73251. /**
  73252. * Index of the particle in its group id (Internal use)
  73253. */
  73254. idxInGroup: number;
  73255. /**
  73256. * @hidden Particle BoundingInfo object (Internal use)
  73257. */
  73258. _boundingInfo: BoundingInfo;
  73259. /**
  73260. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73261. */
  73262. _pcs: PointsCloudSystem;
  73263. /**
  73264. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73265. */
  73266. _stillInvisible: boolean;
  73267. /**
  73268. * @hidden Last computed particle rotation matrix
  73269. */
  73270. _rotationMatrix: number[];
  73271. /**
  73272. * Parent particle Id, if any.
  73273. * Default null.
  73274. */
  73275. parentId: Nullable<number>;
  73276. /**
  73277. * @hidden Internal global position in the PCS.
  73278. */
  73279. _globalPosition: Vector3;
  73280. /**
  73281. * Creates a Point Cloud object.
  73282. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73283. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73284. * @param group (PointsGroup) is the group the particle belongs to
  73285. * @param groupId (integer) is the group identifier in the PCS.
  73286. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73287. * @param pcs defines the PCS it is associated to
  73288. */
  73289. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73290. /**
  73291. * get point size
  73292. */
  73293. get size(): Vector3;
  73294. /**
  73295. * Set point size
  73296. */
  73297. set size(scale: Vector3);
  73298. /**
  73299. * Legacy support, changed quaternion to rotationQuaternion
  73300. */
  73301. get quaternion(): Nullable<Quaternion>;
  73302. /**
  73303. * Legacy support, changed quaternion to rotationQuaternion
  73304. */
  73305. set quaternion(q: Nullable<Quaternion>);
  73306. /**
  73307. * Returns a boolean. True if the particle intersects a mesh, else false
  73308. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73309. * @param target is the object (point or mesh) what the intersection is computed against
  73310. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used
  73311. * @returns true if it intersects
  73312. */
  73313. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73314. /**
  73315. * get the rotation matrix of the particle
  73316. * @hidden
  73317. */
  73318. getRotationMatrix(m: Matrix): void;
  73319. }
  73320. /**
  73321. * Represents a group of points in a points cloud system
  73322. * * PCS internal tool, don't use it manually.
  73323. */
  73324. export class PointsGroup {
  73325. /**
  73326. * The group id
  73327. * @hidden
  73328. */
  73329. groupID: number;
  73330. /**
  73331. * image data for group (internal use)
  73332. * @hidden
  73333. */
  73334. _groupImageData: Nullable<ArrayBufferView>;
  73335. /**
  73336. * Image Width (internal use)
  73337. * @hidden
  73338. */
  73339. _groupImgWidth: number;
  73340. /**
  73341. * Image Height (internal use)
  73342. * @hidden
  73343. */
  73344. _groupImgHeight: number;
  73345. /**
  73346. * Custom position function (internal use)
  73347. * @hidden
  73348. */
  73349. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73350. /**
  73351. * density per facet for surface points
  73352. * @hidden
  73353. */
  73354. _groupDensity: number[];
  73355. /**
  73356. * Only when points are colored by texture carries pointer to texture list array
  73357. * @hidden
  73358. */
  73359. _textureNb: number;
  73360. /**
  73361. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73362. * PCS internal tool, don't use it manually.
  73363. * @hidden
  73364. */
  73365. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73366. }
  73367. }
  73368. declare module BABYLON {
  73369. interface Scene {
  73370. /** @hidden (Backing field) */
  73371. _physicsEngine: Nullable<IPhysicsEngine>;
  73372. /** @hidden */
  73373. _physicsTimeAccumulator: number;
  73374. /**
  73375. * Gets the current physics engine
  73376. * @returns a IPhysicsEngine or null if none attached
  73377. */
  73378. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73379. /**
  73380. * Enables physics to the current scene
  73381. * @param gravity defines the scene's gravity for the physics engine
  73382. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73383. * @return a boolean indicating if the physics engine was initialized
  73384. */
  73385. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73386. /**
  73387. * Disables and disposes the physics engine associated with the scene
  73388. */
  73389. disablePhysicsEngine(): void;
  73390. /**
  73391. * Gets a boolean indicating if there is an active physics engine
  73392. * @returns a boolean indicating if there is an active physics engine
  73393. */
  73394. isPhysicsEnabled(): boolean;
  73395. /**
  73396. * Deletes a physics compound impostor
  73397. * @param compound defines the compound to delete
  73398. */
  73399. deleteCompoundImpostor(compound: any): void;
  73400. /**
  73401. * An event triggered when physic simulation is about to be run
  73402. */
  73403. onBeforePhysicsObservable: Observable<Scene>;
  73404. /**
  73405. * An event triggered when physic simulation has been done
  73406. */
  73407. onAfterPhysicsObservable: Observable<Scene>;
  73408. }
  73409. interface AbstractMesh {
  73410. /** @hidden */
  73411. _physicsImpostor: Nullable<PhysicsImpostor>;
  73412. /**
  73413. * Gets or sets impostor used for physic simulation
  73414. * @see https://doc.babylonjs.com/features/physics_engine
  73415. */
  73416. physicsImpostor: Nullable<PhysicsImpostor>;
  73417. /**
  73418. * Gets the current physics impostor
  73419. * @see https://doc.babylonjs.com/features/physics_engine
  73420. * @returns a physics impostor or null
  73421. */
  73422. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73423. /** Apply a physic impulse to the mesh
  73424. * @param force defines the force to apply
  73425. * @param contactPoint defines where to apply the force
  73426. * @returns the current mesh
  73427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73428. */
  73429. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73430. /**
  73431. * Creates a physic joint between two meshes
  73432. * @param otherMesh defines the other mesh to use
  73433. * @param pivot1 defines the pivot to use on this mesh
  73434. * @param pivot2 defines the pivot to use on the other mesh
  73435. * @param options defines additional options (can be plugin dependent)
  73436. * @returns the current mesh
  73437. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73438. */
  73439. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73440. /** @hidden */
  73441. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73442. }
  73443. /**
  73444. * Defines the physics engine scene component responsible to manage a physics engine
  73445. */
  73446. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73447. /**
  73448. * The component name helpful to identify the component in the list of scene components.
  73449. */
  73450. readonly name: string;
  73451. /**
  73452. * The scene the component belongs to.
  73453. */
  73454. scene: Scene;
  73455. /**
  73456. * Creates a new instance of the component for the given scene
  73457. * @param scene Defines the scene to register the component in
  73458. */
  73459. constructor(scene: Scene);
  73460. /**
  73461. * Registers the component in a given scene
  73462. */
  73463. register(): void;
  73464. /**
  73465. * Rebuilds the elements related to this component in case of
  73466. * context lost for instance.
  73467. */
  73468. rebuild(): void;
  73469. /**
  73470. * Disposes the component and the associated resources
  73471. */
  73472. dispose(): void;
  73473. }
  73474. }
  73475. declare module BABYLON {
  73476. /**
  73477. * A helper for physics simulations
  73478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73479. */
  73480. export class PhysicsHelper {
  73481. private _scene;
  73482. private _physicsEngine;
  73483. /**
  73484. * Initializes the Physics helper
  73485. * @param scene Babylon.js scene
  73486. */
  73487. constructor(scene: Scene);
  73488. /**
  73489. * Applies a radial explosion impulse
  73490. * @param origin the origin of the explosion
  73491. * @param radiusOrEventOptions the radius or the options of radial explosion
  73492. * @param strength the explosion strength
  73493. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73494. * @returns A physics radial explosion event, or null
  73495. */
  73496. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73497. /**
  73498. * Applies a radial explosion force
  73499. * @param origin the origin of the explosion
  73500. * @param radiusOrEventOptions the radius or the options of radial explosion
  73501. * @param strength the explosion strength
  73502. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73503. * @returns A physics radial explosion event, or null
  73504. */
  73505. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73506. /**
  73507. * Creates a gravitational field
  73508. * @param origin the origin of the explosion
  73509. * @param radiusOrEventOptions the radius or the options of radial explosion
  73510. * @param strength the explosion strength
  73511. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73512. * @returns A physics gravitational field event, or null
  73513. */
  73514. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73515. /**
  73516. * Creates a physics updraft event
  73517. * @param origin the origin of the updraft
  73518. * @param radiusOrEventOptions the radius or the options of the updraft
  73519. * @param strength the strength of the updraft
  73520. * @param height the height of the updraft
  73521. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73522. * @returns A physics updraft event, or null
  73523. */
  73524. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73525. /**
  73526. * Creates a physics vortex event
  73527. * @param origin the of the vortex
  73528. * @param radiusOrEventOptions the radius or the options of the vortex
  73529. * @param strength the strength of the vortex
  73530. * @param height the height of the vortex
  73531. * @returns a Physics vortex event, or null
  73532. * A physics vortex event or null
  73533. */
  73534. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73535. }
  73536. /**
  73537. * Represents a physics radial explosion event
  73538. */
  73539. class PhysicsRadialExplosionEvent {
  73540. private _scene;
  73541. private _options;
  73542. private _sphere;
  73543. private _dataFetched;
  73544. /**
  73545. * Initializes a radial explosion event
  73546. * @param _scene BabylonJS scene
  73547. * @param _options The options for the vortex event
  73548. */
  73549. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73550. /**
  73551. * Returns the data related to the radial explosion event (sphere).
  73552. * @returns The radial explosion event data
  73553. */
  73554. getData(): PhysicsRadialExplosionEventData;
  73555. /**
  73556. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73557. * @param impostor A physics imposter
  73558. * @param origin the origin of the explosion
  73559. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73560. */
  73561. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73562. /**
  73563. * Triggers affected impostors callbacks
  73564. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73565. */
  73566. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73567. /**
  73568. * Disposes the sphere.
  73569. * @param force Specifies if the sphere should be disposed by force
  73570. */
  73571. dispose(force?: boolean): void;
  73572. /*** Helpers ***/
  73573. private _prepareSphere;
  73574. private _intersectsWithSphere;
  73575. }
  73576. /**
  73577. * Represents a gravitational field event
  73578. */
  73579. class PhysicsGravitationalFieldEvent {
  73580. private _physicsHelper;
  73581. private _scene;
  73582. private _origin;
  73583. private _options;
  73584. private _tickCallback;
  73585. private _sphere;
  73586. private _dataFetched;
  73587. /**
  73588. * Initializes the physics gravitational field event
  73589. * @param _physicsHelper A physics helper
  73590. * @param _scene BabylonJS scene
  73591. * @param _origin The origin position of the gravitational field event
  73592. * @param _options The options for the vortex event
  73593. */
  73594. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73595. /**
  73596. * Returns the data related to the gravitational field event (sphere).
  73597. * @returns A gravitational field event
  73598. */
  73599. getData(): PhysicsGravitationalFieldEventData;
  73600. /**
  73601. * Enables the gravitational field.
  73602. */
  73603. enable(): void;
  73604. /**
  73605. * Disables the gravitational field.
  73606. */
  73607. disable(): void;
  73608. /**
  73609. * Disposes the sphere.
  73610. * @param force The force to dispose from the gravitational field event
  73611. */
  73612. dispose(force?: boolean): void;
  73613. private _tick;
  73614. }
  73615. /**
  73616. * Represents a physics updraft event
  73617. */
  73618. class PhysicsUpdraftEvent {
  73619. private _scene;
  73620. private _origin;
  73621. private _options;
  73622. private _physicsEngine;
  73623. private _originTop;
  73624. private _originDirection;
  73625. private _tickCallback;
  73626. private _cylinder;
  73627. private _cylinderPosition;
  73628. private _dataFetched;
  73629. /**
  73630. * Initializes the physics updraft event
  73631. * @param _scene BabylonJS scene
  73632. * @param _origin The origin position of the updraft
  73633. * @param _options The options for the updraft event
  73634. */
  73635. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73636. /**
  73637. * Returns the data related to the updraft event (cylinder).
  73638. * @returns A physics updraft event
  73639. */
  73640. getData(): PhysicsUpdraftEventData;
  73641. /**
  73642. * Enables the updraft.
  73643. */
  73644. enable(): void;
  73645. /**
  73646. * Disables the updraft.
  73647. */
  73648. disable(): void;
  73649. /**
  73650. * Disposes the cylinder.
  73651. * @param force Specifies if the updraft should be disposed by force
  73652. */
  73653. dispose(force?: boolean): void;
  73654. private getImpostorHitData;
  73655. private _tick;
  73656. /*** Helpers ***/
  73657. private _prepareCylinder;
  73658. private _intersectsWithCylinder;
  73659. }
  73660. /**
  73661. * Represents a physics vortex event
  73662. */
  73663. class PhysicsVortexEvent {
  73664. private _scene;
  73665. private _origin;
  73666. private _options;
  73667. private _physicsEngine;
  73668. private _originTop;
  73669. private _tickCallback;
  73670. private _cylinder;
  73671. private _cylinderPosition;
  73672. private _dataFetched;
  73673. /**
  73674. * Initializes the physics vortex event
  73675. * @param _scene The BabylonJS scene
  73676. * @param _origin The origin position of the vortex
  73677. * @param _options The options for the vortex event
  73678. */
  73679. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73680. /**
  73681. * Returns the data related to the vortex event (cylinder).
  73682. * @returns The physics vortex event data
  73683. */
  73684. getData(): PhysicsVortexEventData;
  73685. /**
  73686. * Enables the vortex.
  73687. */
  73688. enable(): void;
  73689. /**
  73690. * Disables the cortex.
  73691. */
  73692. disable(): void;
  73693. /**
  73694. * Disposes the sphere.
  73695. * @param force
  73696. */
  73697. dispose(force?: boolean): void;
  73698. private getImpostorHitData;
  73699. private _tick;
  73700. /*** Helpers ***/
  73701. private _prepareCylinder;
  73702. private _intersectsWithCylinder;
  73703. }
  73704. /**
  73705. * Options fot the radial explosion event
  73706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73707. */
  73708. export class PhysicsRadialExplosionEventOptions {
  73709. /**
  73710. * The radius of the sphere for the radial explosion.
  73711. */
  73712. radius: number;
  73713. /**
  73714. * The strength of the explosion.
  73715. */
  73716. strength: number;
  73717. /**
  73718. * The strength of the force in correspondence to the distance of the affected object
  73719. */
  73720. falloff: PhysicsRadialImpulseFalloff;
  73721. /**
  73722. * Sphere options for the radial explosion.
  73723. */
  73724. sphere: {
  73725. segments: number;
  73726. diameter: number;
  73727. };
  73728. /**
  73729. * Sphere options for the radial explosion.
  73730. */
  73731. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73732. }
  73733. /**
  73734. * Options fot the updraft event
  73735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73736. */
  73737. export class PhysicsUpdraftEventOptions {
  73738. /**
  73739. * The radius of the cylinder for the vortex
  73740. */
  73741. radius: number;
  73742. /**
  73743. * The strength of the updraft.
  73744. */
  73745. strength: number;
  73746. /**
  73747. * The height of the cylinder for the updraft.
  73748. */
  73749. height: number;
  73750. /**
  73751. * The mode for the the updraft.
  73752. */
  73753. updraftMode: PhysicsUpdraftMode;
  73754. }
  73755. /**
  73756. * Options fot the vortex event
  73757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73758. */
  73759. export class PhysicsVortexEventOptions {
  73760. /**
  73761. * The radius of the cylinder for the vortex
  73762. */
  73763. radius: number;
  73764. /**
  73765. * The strength of the vortex.
  73766. */
  73767. strength: number;
  73768. /**
  73769. * The height of the cylinder for the vortex.
  73770. */
  73771. height: number;
  73772. /**
  73773. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73774. */
  73775. centripetalForceThreshold: number;
  73776. /**
  73777. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the threshold.
  73778. */
  73779. centripetalForceMultiplier: number;
  73780. /**
  73781. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the threshold.
  73782. */
  73783. centrifugalForceMultiplier: number;
  73784. /**
  73785. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73786. */
  73787. updraftForceMultiplier: number;
  73788. }
  73789. /**
  73790. * The strength of the force in correspondence to the distance of the affected object
  73791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73792. */
  73793. export enum PhysicsRadialImpulseFalloff {
  73794. /** Defines that impulse is constant in strength across it's whole radius */
  73795. Constant = 0,
  73796. /** Defines that impulse gets weaker if it's further from the origin */
  73797. Linear = 1
  73798. }
  73799. /**
  73800. * The strength of the force in correspondence to the distance of the affected object
  73801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73802. */
  73803. export enum PhysicsUpdraftMode {
  73804. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73805. Center = 0,
  73806. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73807. Perpendicular = 1
  73808. }
  73809. /**
  73810. * Interface for a physics hit data
  73811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73812. */
  73813. export interface PhysicsHitData {
  73814. /**
  73815. * The force applied at the contact point
  73816. */
  73817. force: Vector3;
  73818. /**
  73819. * The contact point
  73820. */
  73821. contactPoint: Vector3;
  73822. /**
  73823. * The distance from the origin to the contact point
  73824. */
  73825. distanceFromOrigin: number;
  73826. }
  73827. /**
  73828. * Interface for radial explosion event data
  73829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73830. */
  73831. export interface PhysicsRadialExplosionEventData {
  73832. /**
  73833. * A sphere used for the radial explosion event
  73834. */
  73835. sphere: Mesh;
  73836. }
  73837. /**
  73838. * Interface for gravitational field event data
  73839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73840. */
  73841. export interface PhysicsGravitationalFieldEventData {
  73842. /**
  73843. * A sphere mesh used for the gravitational field event
  73844. */
  73845. sphere: Mesh;
  73846. }
  73847. /**
  73848. * Interface for updraft event data
  73849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73850. */
  73851. export interface PhysicsUpdraftEventData {
  73852. /**
  73853. * A cylinder used for the updraft event
  73854. */
  73855. cylinder: Mesh;
  73856. }
  73857. /**
  73858. * Interface for vortex event data
  73859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73860. */
  73861. export interface PhysicsVortexEventData {
  73862. /**
  73863. * A cylinder used for the vortex event
  73864. */
  73865. cylinder: Mesh;
  73866. }
  73867. /**
  73868. * Interface for an affected physics impostor
  73869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73870. */
  73871. export interface PhysicsAffectedImpostorWithData {
  73872. /**
  73873. * The impostor affected by the effect
  73874. */
  73875. impostor: PhysicsImpostor;
  73876. /**
  73877. * The data about the hit/force from the explosion
  73878. */
  73879. hitData: PhysicsHitData;
  73880. }
  73881. }
  73882. declare module BABYLON {
  73883. /** @hidden */
  73884. export var blackAndWhitePixelShader: {
  73885. name: string;
  73886. shader: string;
  73887. };
  73888. }
  73889. declare module BABYLON {
  73890. /**
  73891. * Post process used to render in black and white
  73892. */
  73893. export class BlackAndWhitePostProcess extends PostProcess {
  73894. /**
  73895. * Linear about to convert he result to black and white (default: 1)
  73896. */
  73897. degree: number;
  73898. /**
  73899. * Gets a string identifying the name of the class
  73900. * @returns "BlackAndWhitePostProcess" string
  73901. */
  73902. getClassName(): string;
  73903. /**
  73904. * Creates a black and white post process
  73905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73906. * @param name The name of the effect.
  73907. * @param options The required width/height ratio to downsize to before computing the render pass.
  73908. * @param camera The camera to apply the render pass to.
  73909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73910. * @param engine The engine which the post process will be applied. (default: current engine)
  73911. * @param reusable If the post process can be reused on the same frame. (default: false)
  73912. */
  73913. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73914. /** @hidden */
  73915. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73916. }
  73917. }
  73918. declare module BABYLON {
  73919. /**
  73920. * This represents a set of one or more post processes in Babylon.
  73921. * A post process can be used to apply a shader to a texture after it is rendered.
  73922. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73923. */
  73924. export class PostProcessRenderEffect {
  73925. private _postProcesses;
  73926. private _getPostProcesses;
  73927. private _singleInstance;
  73928. private _cameras;
  73929. private _indicesForCamera;
  73930. /**
  73931. * Name of the effect
  73932. * @hidden
  73933. */
  73934. _name: string;
  73935. /**
  73936. * Instantiates a post process render effect.
  73937. * A post process can be used to apply a shader to a texture after it is rendered.
  73938. * @param engine The engine the effect is tied to
  73939. * @param name The name of the effect
  73940. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73941. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73942. */
  73943. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73944. /**
  73945. * Checks if all the post processes in the effect are supported.
  73946. */
  73947. get isSupported(): boolean;
  73948. /**
  73949. * Updates the current state of the effect
  73950. * @hidden
  73951. */
  73952. _update(): void;
  73953. /**
  73954. * Attaches the effect on cameras
  73955. * @param cameras The camera to attach to.
  73956. * @hidden
  73957. */
  73958. _attachCameras(cameras: Camera): void;
  73959. /**
  73960. * Attaches the effect on cameras
  73961. * @param cameras The camera to attach to.
  73962. * @hidden
  73963. */
  73964. _attachCameras(cameras: Camera[]): void;
  73965. /**
  73966. * Detaches the effect on cameras
  73967. * @param cameras The camera to detach from.
  73968. * @hidden
  73969. */
  73970. _detachCameras(cameras: Camera): void;
  73971. /**
  73972. * Detaches the effect on cameras
  73973. * @param cameras The camera to detach from.
  73974. * @hidden
  73975. */
  73976. _detachCameras(cameras: Camera[]): void;
  73977. /**
  73978. * Enables the effect on given cameras
  73979. * @param cameras The camera to enable.
  73980. * @hidden
  73981. */
  73982. _enable(cameras: Camera): void;
  73983. /**
  73984. * Enables the effect on given cameras
  73985. * @param cameras The camera to enable.
  73986. * @hidden
  73987. */
  73988. _enable(cameras: Nullable<Camera[]>): void;
  73989. /**
  73990. * Disables the effect on the given cameras
  73991. * @param cameras The camera to disable.
  73992. * @hidden
  73993. */
  73994. _disable(cameras: Camera): void;
  73995. /**
  73996. * Disables the effect on the given cameras
  73997. * @param cameras The camera to disable.
  73998. * @hidden
  73999. */
  74000. _disable(cameras: Nullable<Camera[]>): void;
  74001. /**
  74002. * Gets a list of the post processes contained in the effect.
  74003. * @param camera The camera to get the post processes on.
  74004. * @returns The list of the post processes in the effect.
  74005. */
  74006. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74007. }
  74008. }
  74009. declare module BABYLON {
  74010. /** @hidden */
  74011. export var extractHighlightsPixelShader: {
  74012. name: string;
  74013. shader: string;
  74014. };
  74015. }
  74016. declare module BABYLON {
  74017. /**
  74018. * 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.
  74019. */
  74020. export class ExtractHighlightsPostProcess extends PostProcess {
  74021. /**
  74022. * The luminance threshold, pixels below this value will be set to black.
  74023. */
  74024. threshold: number;
  74025. /** @hidden */
  74026. _exposure: number;
  74027. /**
  74028. * Post process which has the input texture to be used when performing highlight extraction
  74029. * @hidden
  74030. */
  74031. _inputPostProcess: Nullable<PostProcess>;
  74032. /**
  74033. * Gets a string identifying the name of the class
  74034. * @returns "ExtractHighlightsPostProcess" string
  74035. */
  74036. getClassName(): string;
  74037. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74038. }
  74039. }
  74040. declare module BABYLON {
  74041. /** @hidden */
  74042. export var bloomMergePixelShader: {
  74043. name: string;
  74044. shader: string;
  74045. };
  74046. }
  74047. declare module BABYLON {
  74048. /**
  74049. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74050. */
  74051. export class BloomMergePostProcess extends PostProcess {
  74052. /** Weight of the bloom to be added to the original input. */
  74053. weight: number;
  74054. /**
  74055. * Gets a string identifying the name of the class
  74056. * @returns "BloomMergePostProcess" string
  74057. */
  74058. getClassName(): string;
  74059. /**
  74060. * Creates a new instance of @see BloomMergePostProcess
  74061. * @param name The name of the effect.
  74062. * @param originalFromInput Post process which's input will be used for the merge.
  74063. * @param blurred Blurred highlights post process which's output will be used.
  74064. * @param weight Weight of the bloom to be added to the original input.
  74065. * @param options The required width/height ratio to downsize to before computing the render pass.
  74066. * @param camera The camera to apply the render pass to.
  74067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74068. * @param engine The engine which the post process will be applied. (default: current engine)
  74069. * @param reusable If the post process can be reused on the same frame. (default: false)
  74070. * @param textureType Type of textures used when performing the post process. (default: 0)
  74071. * @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)
  74072. */
  74073. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74074. /** Weight of the bloom to be added to the original input. */
  74075. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74076. }
  74077. }
  74078. declare module BABYLON {
  74079. /**
  74080. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74081. */
  74082. export class BloomEffect extends PostProcessRenderEffect {
  74083. private bloomScale;
  74084. /**
  74085. * @hidden Internal
  74086. */
  74087. _effects: Array<PostProcess>;
  74088. /**
  74089. * @hidden Internal
  74090. */
  74091. _downscale: ExtractHighlightsPostProcess;
  74092. private _blurX;
  74093. private _blurY;
  74094. private _merge;
  74095. /**
  74096. * The luminance threshold to find bright areas of the image to bloom.
  74097. */
  74098. get threshold(): number;
  74099. set threshold(value: number);
  74100. /**
  74101. * The strength of the bloom.
  74102. */
  74103. get weight(): number;
  74104. set weight(value: number);
  74105. /**
  74106. * Specifies the size of the bloom blur kernel, relative to the final output size
  74107. */
  74108. get kernel(): number;
  74109. set kernel(value: number);
  74110. /**
  74111. * Creates a new instance of @see BloomEffect
  74112. * @param scene The scene the effect belongs to.
  74113. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74114. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74115. * @param bloomWeight The the strength of bloom.
  74116. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74117. * @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)
  74118. */
  74119. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74120. /**
  74121. * Disposes each of the internal effects for a given camera.
  74122. * @param camera The camera to dispose the effect on.
  74123. */
  74124. disposeEffects(camera: Camera): void;
  74125. /**
  74126. * @hidden Internal
  74127. */
  74128. _updateEffects(): void;
  74129. /**
  74130. * Internal
  74131. * @returns if all the contained post processes are ready.
  74132. * @hidden
  74133. */
  74134. _isReady(): boolean;
  74135. }
  74136. }
  74137. declare module BABYLON {
  74138. /** @hidden */
  74139. export var chromaticAberrationPixelShader: {
  74140. name: string;
  74141. shader: string;
  74142. };
  74143. }
  74144. declare module BABYLON {
  74145. /**
  74146. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74147. */
  74148. export class ChromaticAberrationPostProcess extends PostProcess {
  74149. /**
  74150. * The amount of separation of rgb channels (default: 30)
  74151. */
  74152. aberrationAmount: number;
  74153. /**
  74154. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74155. */
  74156. radialIntensity: number;
  74157. /**
  74158. * 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))
  74159. */
  74160. direction: Vector2;
  74161. /**
  74162. * 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))
  74163. */
  74164. centerPosition: Vector2;
  74165. /** The width of the screen to apply the effect on */
  74166. screenWidth: number;
  74167. /** The height of the screen to apply the effect on */
  74168. screenHeight: number;
  74169. /**
  74170. * Gets a string identifying the name of the class
  74171. * @returns "ChromaticAberrationPostProcess" string
  74172. */
  74173. getClassName(): string;
  74174. /**
  74175. * Creates a new instance ChromaticAberrationPostProcess
  74176. * @param name The name of the effect.
  74177. * @param screenWidth The width of the screen to apply the effect on.
  74178. * @param screenHeight The height of the screen to apply the effect on.
  74179. * @param options The required width/height ratio to downsize to before computing the render pass.
  74180. * @param camera The camera to apply the render pass to.
  74181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74182. * @param engine The engine which the post process will be applied. (default: current engine)
  74183. * @param reusable If the post process can be reused on the same frame. (default: false)
  74184. * @param textureType Type of textures used when performing the post process. (default: 0)
  74185. * @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)
  74186. */
  74187. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74188. /** @hidden */
  74189. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74190. }
  74191. }
  74192. declare module BABYLON {
  74193. /** @hidden */
  74194. export var circleOfConfusionPixelShader: {
  74195. name: string;
  74196. shader: string;
  74197. };
  74198. }
  74199. declare module BABYLON {
  74200. /**
  74201. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74202. */
  74203. export class CircleOfConfusionPostProcess extends PostProcess {
  74204. /**
  74205. * 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.
  74206. */
  74207. lensSize: number;
  74208. /**
  74209. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74210. */
  74211. fStop: number;
  74212. /**
  74213. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74214. */
  74215. focusDistance: number;
  74216. /**
  74217. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74218. */
  74219. focalLength: number;
  74220. /**
  74221. * Gets a string identifying the name of the class
  74222. * @returns "CircleOfConfusionPostProcess" string
  74223. */
  74224. getClassName(): string;
  74225. private _depthTexture;
  74226. /**
  74227. * Creates a new instance CircleOfConfusionPostProcess
  74228. * @param name The name of the effect.
  74229. * @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.
  74230. * @param options The required width/height ratio to downsize to before computing the render pass.
  74231. * @param camera The camera to apply the render pass to.
  74232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74233. * @param engine The engine which the post process will be applied. (default: current engine)
  74234. * @param reusable If the post process can be reused on the same frame. (default: false)
  74235. * @param textureType Type of textures used when performing the post process. (default: 0)
  74236. * @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)
  74237. */
  74238. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74239. /**
  74240. * 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.
  74241. */
  74242. set depthTexture(value: RenderTargetTexture);
  74243. }
  74244. }
  74245. declare module BABYLON {
  74246. /** @hidden */
  74247. export var colorCorrectionPixelShader: {
  74248. name: string;
  74249. shader: string;
  74250. };
  74251. }
  74252. declare module BABYLON {
  74253. /**
  74254. *
  74255. * This post-process allows the modification of rendered colors by using
  74256. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74257. *
  74258. * The object needs to be provided an url to a texture containing the color
  74259. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74260. * Use an image editing software to tweak the LUT to match your needs.
  74261. *
  74262. * For an example of a color LUT, see here:
  74263. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74264. * For explanations on color grading, see here:
  74265. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74266. *
  74267. */
  74268. export class ColorCorrectionPostProcess extends PostProcess {
  74269. private _colorTableTexture;
  74270. /**
  74271. * Gets the color table url used to create the LUT texture
  74272. */
  74273. colorTableUrl: string;
  74274. /**
  74275. * Gets a string identifying the name of the class
  74276. * @returns "ColorCorrectionPostProcess" string
  74277. */
  74278. getClassName(): string;
  74279. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74280. /** @hidden */
  74281. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74282. }
  74283. }
  74284. declare module BABYLON {
  74285. /** @hidden */
  74286. export var convolutionPixelShader: {
  74287. name: string;
  74288. shader: string;
  74289. };
  74290. }
  74291. declare module BABYLON {
  74292. /**
  74293. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74294. * input texture to perform effects such as edge detection or sharpening
  74295. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74296. */
  74297. export class ConvolutionPostProcess extends PostProcess {
  74298. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74299. kernel: number[];
  74300. /**
  74301. * Gets a string identifying the name of the class
  74302. * @returns "ConvolutionPostProcess" string
  74303. */
  74304. getClassName(): string;
  74305. /**
  74306. * Creates a new instance ConvolutionPostProcess
  74307. * @param name The name of the effect.
  74308. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74309. * @param options The required width/height ratio to downsize to before computing the render pass.
  74310. * @param camera The camera to apply the render pass to.
  74311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74312. * @param engine The engine which the post process will be applied. (default: current engine)
  74313. * @param reusable If the post process can be reused on the same frame. (default: false)
  74314. * @param textureType Type of textures used when performing the post process. (default: 0)
  74315. */
  74316. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74317. /** @hidden */
  74318. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74319. /**
  74320. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74321. */
  74322. static EdgeDetect0Kernel: number[];
  74323. /**
  74324. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74325. */
  74326. static EdgeDetect1Kernel: number[];
  74327. /**
  74328. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74329. */
  74330. static EdgeDetect2Kernel: number[];
  74331. /**
  74332. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74333. */
  74334. static SharpenKernel: number[];
  74335. /**
  74336. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74337. */
  74338. static EmbossKernel: number[];
  74339. /**
  74340. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74341. */
  74342. static GaussianKernel: number[];
  74343. }
  74344. }
  74345. declare module BABYLON {
  74346. /**
  74347. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74348. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74349. * based on samples that have a large difference in distance than the center pixel.
  74350. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74351. */
  74352. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74353. /**
  74354. * The direction the blur should be applied
  74355. */
  74356. direction: Vector2;
  74357. /**
  74358. * Gets a string identifying the name of the class
  74359. * @returns "DepthOfFieldBlurPostProcess" string
  74360. */
  74361. getClassName(): string;
  74362. /**
  74363. * Creates a new instance CircleOfConfusionPostProcess
  74364. * @param name The name of the effect.
  74365. * @param scene The scene the effect belongs to.
  74366. * @param direction The direction the blur should be applied.
  74367. * @param kernel The size of the kernel used to blur.
  74368. * @param options The required width/height ratio to downsize to before computing the render pass.
  74369. * @param camera The camera to apply the render pass to.
  74370. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring across edges
  74371. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74372. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74373. * @param engine The engine which the post process will be applied. (default: current engine)
  74374. * @param reusable If the post process can be reused on the same frame. (default: false)
  74375. * @param textureType Type of textures used when performing the post process. (default: 0)
  74376. * @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)
  74377. */
  74378. 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);
  74379. }
  74380. }
  74381. declare module BABYLON {
  74382. /** @hidden */
  74383. export var depthOfFieldMergePixelShader: {
  74384. name: string;
  74385. shader: string;
  74386. };
  74387. }
  74388. declare module BABYLON {
  74389. /**
  74390. * Options to be set when merging outputs from the default pipeline.
  74391. */
  74392. export class DepthOfFieldMergePostProcessOptions {
  74393. /**
  74394. * The original image to merge on top of
  74395. */
  74396. originalFromInput: PostProcess;
  74397. /**
  74398. * Parameters to perform the merge of the depth of field effect
  74399. */
  74400. depthOfField?: {
  74401. circleOfConfusion: PostProcess;
  74402. blurSteps: Array<PostProcess>;
  74403. };
  74404. /**
  74405. * Parameters to perform the merge of bloom effect
  74406. */
  74407. bloom?: {
  74408. blurred: PostProcess;
  74409. weight: number;
  74410. };
  74411. }
  74412. /**
  74413. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74414. */
  74415. export class DepthOfFieldMergePostProcess extends PostProcess {
  74416. private blurSteps;
  74417. /**
  74418. * Gets a string identifying the name of the class
  74419. * @returns "DepthOfFieldMergePostProcess" string
  74420. */
  74421. getClassName(): string;
  74422. /**
  74423. * Creates a new instance of DepthOfFieldMergePostProcess
  74424. * @param name The name of the effect.
  74425. * @param originalFromInput Post process which's input will be used for the merge.
  74426. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74427. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74428. * @param options The required width/height ratio to downsize to before computing the render pass.
  74429. * @param camera The camera to apply the render pass to.
  74430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74431. * @param engine The engine which the post process will be applied. (default: current engine)
  74432. * @param reusable If the post process can be reused on the same frame. (default: false)
  74433. * @param textureType Type of textures used when performing the post process. (default: 0)
  74434. * @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)
  74435. */
  74436. 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);
  74437. /**
  74438. * Updates the effect with the current post process compile time values and recompiles the shader.
  74439. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74440. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74441. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74442. * @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
  74443. * @param onCompiled Called when the shader has been compiled.
  74444. * @param onError Called if there is an error when compiling a shader.
  74445. */
  74446. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74447. }
  74448. }
  74449. declare module BABYLON {
  74450. /**
  74451. * Specifies the level of max blur that should be applied when using the depth of field effect
  74452. */
  74453. export enum DepthOfFieldEffectBlurLevel {
  74454. /**
  74455. * Subtle blur
  74456. */
  74457. Low = 0,
  74458. /**
  74459. * Medium blur
  74460. */
  74461. Medium = 1,
  74462. /**
  74463. * Large blur
  74464. */
  74465. High = 2
  74466. }
  74467. /**
  74468. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74469. */
  74470. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74471. private _circleOfConfusion;
  74472. /**
  74473. * @hidden Internal, blurs from high to low
  74474. */
  74475. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74476. private _depthOfFieldBlurY;
  74477. private _dofMerge;
  74478. /**
  74479. * @hidden Internal post processes in depth of field effect
  74480. */
  74481. _effects: Array<PostProcess>;
  74482. /**
  74483. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74484. */
  74485. set focalLength(value: number);
  74486. get focalLength(): number;
  74487. /**
  74488. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74489. */
  74490. set fStop(value: number);
  74491. get fStop(): number;
  74492. /**
  74493. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74494. */
  74495. set focusDistance(value: number);
  74496. get focusDistance(): number;
  74497. /**
  74498. * 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.
  74499. */
  74500. set lensSize(value: number);
  74501. get lensSize(): number;
  74502. /**
  74503. * Creates a new instance DepthOfFieldEffect
  74504. * @param scene The scene the effect belongs to.
  74505. * @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.
  74506. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74507. * @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)
  74508. */
  74509. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74510. /**
  74511. * Get the current class name of the current effect
  74512. * @returns "DepthOfFieldEffect"
  74513. */
  74514. getClassName(): string;
  74515. /**
  74516. * 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.
  74517. */
  74518. set depthTexture(value: RenderTargetTexture);
  74519. /**
  74520. * Disposes each of the internal effects for a given camera.
  74521. * @param camera The camera to dispose the effect on.
  74522. */
  74523. disposeEffects(camera: Camera): void;
  74524. /**
  74525. * @hidden Internal
  74526. */
  74527. _updateEffects(): void;
  74528. /**
  74529. * Internal
  74530. * @returns if all the contained post processes are ready.
  74531. * @hidden
  74532. */
  74533. _isReady(): boolean;
  74534. }
  74535. }
  74536. declare module BABYLON {
  74537. /** @hidden */
  74538. export var displayPassPixelShader: {
  74539. name: string;
  74540. shader: string;
  74541. };
  74542. }
  74543. declare module BABYLON {
  74544. /**
  74545. * DisplayPassPostProcess which produces an output the same as it's input
  74546. */
  74547. export class DisplayPassPostProcess extends PostProcess {
  74548. /**
  74549. * Gets a string identifying the name of the class
  74550. * @returns "DisplayPassPostProcess" string
  74551. */
  74552. getClassName(): string;
  74553. /**
  74554. * Creates the DisplayPassPostProcess
  74555. * @param name The name of the effect.
  74556. * @param options The required width/height ratio to downsize to before computing the render pass.
  74557. * @param camera The camera to apply the render pass to.
  74558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74559. * @param engine The engine which the post process will be applied. (default: current engine)
  74560. * @param reusable If the post process can be reused on the same frame. (default: false)
  74561. */
  74562. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74563. /** @hidden */
  74564. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74565. }
  74566. }
  74567. declare module BABYLON {
  74568. /** @hidden */
  74569. export var filterPixelShader: {
  74570. name: string;
  74571. shader: string;
  74572. };
  74573. }
  74574. declare module BABYLON {
  74575. /**
  74576. * Applies a kernel filter to the image
  74577. */
  74578. export class FilterPostProcess extends PostProcess {
  74579. /** The matrix to be applied to the image */
  74580. kernelMatrix: Matrix;
  74581. /**
  74582. * Gets a string identifying the name of the class
  74583. * @returns "FilterPostProcess" string
  74584. */
  74585. getClassName(): string;
  74586. /**
  74587. *
  74588. * @param name The name of the effect.
  74589. * @param kernelMatrix The matrix to be applied to the image
  74590. * @param options The required width/height ratio to downsize to before computing the render pass.
  74591. * @param camera The camera to apply the render pass to.
  74592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74593. * @param engine The engine which the post process will be applied. (default: current engine)
  74594. * @param reusable If the post process can be reused on the same frame. (default: false)
  74595. */
  74596. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74597. /** @hidden */
  74598. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74599. }
  74600. }
  74601. declare module BABYLON {
  74602. /** @hidden */
  74603. export var fxaaPixelShader: {
  74604. name: string;
  74605. shader: string;
  74606. };
  74607. }
  74608. declare module BABYLON {
  74609. /** @hidden */
  74610. export var fxaaVertexShader: {
  74611. name: string;
  74612. shader: string;
  74613. };
  74614. }
  74615. declare module BABYLON {
  74616. /**
  74617. * Fxaa post process
  74618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74619. */
  74620. export class FxaaPostProcess extends PostProcess {
  74621. /**
  74622. * Gets a string identifying the name of the class
  74623. * @returns "FxaaPostProcess" string
  74624. */
  74625. getClassName(): string;
  74626. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74627. private _getDefines;
  74628. /** @hidden */
  74629. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74630. }
  74631. }
  74632. declare module BABYLON {
  74633. /** @hidden */
  74634. export var grainPixelShader: {
  74635. name: string;
  74636. shader: string;
  74637. };
  74638. }
  74639. declare module BABYLON {
  74640. /**
  74641. * The GrainPostProcess adds noise to the image at mid luminance levels
  74642. */
  74643. export class GrainPostProcess extends PostProcess {
  74644. /**
  74645. * The intensity of the grain added (default: 30)
  74646. */
  74647. intensity: number;
  74648. /**
  74649. * If the grain should be randomized on every frame
  74650. */
  74651. animated: boolean;
  74652. /**
  74653. * Gets a string identifying the name of the class
  74654. * @returns "GrainPostProcess" string
  74655. */
  74656. getClassName(): string;
  74657. /**
  74658. * Creates a new instance of @see GrainPostProcess
  74659. * @param name The name of the effect.
  74660. * @param options The required width/height ratio to downsize to before computing the render pass.
  74661. * @param camera The camera to apply the render pass to.
  74662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74663. * @param engine The engine which the post process will be applied. (default: current engine)
  74664. * @param reusable If the post process can be reused on the same frame. (default: false)
  74665. * @param textureType Type of textures used when performing the post process. (default: 0)
  74666. * @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)
  74667. */
  74668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74669. /** @hidden */
  74670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74671. }
  74672. }
  74673. declare module BABYLON {
  74674. /** @hidden */
  74675. export var highlightsPixelShader: {
  74676. name: string;
  74677. shader: string;
  74678. };
  74679. }
  74680. declare module BABYLON {
  74681. /**
  74682. * Extracts highlights from the image
  74683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74684. */
  74685. export class HighlightsPostProcess extends PostProcess {
  74686. /**
  74687. * Gets a string identifying the name of the class
  74688. * @returns "HighlightsPostProcess" string
  74689. */
  74690. getClassName(): string;
  74691. /**
  74692. * Extracts highlights from the image
  74693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74694. * @param name The name of the effect.
  74695. * @param options The required width/height ratio to downsize to before computing the render pass.
  74696. * @param camera The camera to apply the render pass to.
  74697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74698. * @param engine The engine which the post process will be applied. (default: current engine)
  74699. * @param reusable If the post process can be reused on the same frame. (default: false)
  74700. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74701. */
  74702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74703. }
  74704. }
  74705. declare module BABYLON {
  74706. /**
  74707. * Contains all parameters needed for the prepass to perform
  74708. * motion blur
  74709. */
  74710. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74711. /**
  74712. * Is motion blur enabled
  74713. */
  74714. enabled: boolean;
  74715. /**
  74716. * Name of the configuration
  74717. */
  74718. name: string;
  74719. /**
  74720. * Textures that should be present in the MRT for this effect to work
  74721. */
  74722. readonly texturesRequired: number[];
  74723. }
  74724. }
  74725. declare module BABYLON {
  74726. interface Scene {
  74727. /** @hidden (Backing field) */
  74728. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74729. /**
  74730. * Gets or Sets the current geometry buffer associated to the scene.
  74731. */
  74732. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74733. /**
  74734. * Enables a GeometryBufferRender and associates it with the scene
  74735. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74736. * @returns the GeometryBufferRenderer
  74737. */
  74738. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74739. /**
  74740. * Disables the GeometryBufferRender associated with the scene
  74741. */
  74742. disableGeometryBufferRenderer(): void;
  74743. }
  74744. /**
  74745. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74746. * in several rendering techniques.
  74747. */
  74748. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74749. /**
  74750. * The component name helpful to identify the component in the list of scene components.
  74751. */
  74752. readonly name: string;
  74753. /**
  74754. * The scene the component belongs to.
  74755. */
  74756. scene: Scene;
  74757. /**
  74758. * Creates a new instance of the component for the given scene
  74759. * @param scene Defines the scene to register the component in
  74760. */
  74761. constructor(scene: Scene);
  74762. /**
  74763. * Registers the component in a given scene
  74764. */
  74765. register(): void;
  74766. /**
  74767. * Rebuilds the elements related to this component in case of
  74768. * context lost for instance.
  74769. */
  74770. rebuild(): void;
  74771. /**
  74772. * Disposes the component and the associated resources
  74773. */
  74774. dispose(): void;
  74775. private _gatherRenderTargets;
  74776. }
  74777. }
  74778. declare module BABYLON {
  74779. /** @hidden */
  74780. export var motionBlurPixelShader: {
  74781. name: string;
  74782. shader: string;
  74783. };
  74784. }
  74785. declare module BABYLON {
  74786. /**
  74787. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74788. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74789. * As an example, all you have to do is to create the post-process:
  74790. * var mb = new BABYLON.MotionBlurPostProcess(
  74791. * 'mb', // The name of the effect.
  74792. * scene, // The scene containing the objects to blur according to their velocity.
  74793. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74794. * camera // The camera to apply the render pass to.
  74795. * );
  74796. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74797. */
  74798. export class MotionBlurPostProcess extends PostProcess {
  74799. /**
  74800. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74801. */
  74802. motionStrength: number;
  74803. /**
  74804. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74805. */
  74806. get motionBlurSamples(): number;
  74807. /**
  74808. * Sets the number of iterations to be used for motion blur quality
  74809. */
  74810. set motionBlurSamples(samples: number);
  74811. private _motionBlurSamples;
  74812. /**
  74813. * Gets whether or not the motion blur post-process is in object based mode.
  74814. */
  74815. get isObjectBased(): boolean;
  74816. /**
  74817. * Sets whether or not the motion blur post-process is in object based mode.
  74818. */
  74819. set isObjectBased(value: boolean);
  74820. private _isObjectBased;
  74821. private _forceGeometryBuffer;
  74822. private _geometryBufferRenderer;
  74823. private _prePassRenderer;
  74824. private _invViewProjection;
  74825. private _previousViewProjection;
  74826. /**
  74827. * Gets a string identifying the name of the class
  74828. * @returns "MotionBlurPostProcess" string
  74829. */
  74830. getClassName(): string;
  74831. /**
  74832. * Creates a new instance MotionBlurPostProcess
  74833. * @param name The name of the effect.
  74834. * @param scene The scene containing the objects to blur according to their velocity.
  74835. * @param options The required width/height ratio to downsize to before computing the render pass.
  74836. * @param camera The camera to apply the render pass to.
  74837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74838. * @param engine The engine which the post process will be applied. (default: current engine)
  74839. * @param reusable If the post process can be reused on the same frame. (default: false)
  74840. * @param textureType Type of textures used when performing the post process. (default: 0)
  74841. * @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)
  74842. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74843. */
  74844. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74845. /**
  74846. * Excludes the given skinned mesh from computing bones velocities.
  74847. * 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.
  74848. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74849. */
  74850. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74851. /**
  74852. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74853. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74854. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74855. */
  74856. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74857. /**
  74858. * Disposes the post process.
  74859. * @param camera The camera to dispose the post process on.
  74860. */
  74861. dispose(camera?: Camera): void;
  74862. /**
  74863. * Called on the mode changed (object based or screen based).
  74864. */
  74865. private _applyMode;
  74866. /**
  74867. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74868. */
  74869. private _onApplyObjectBased;
  74870. /**
  74871. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74872. */
  74873. private _onApplyScreenBased;
  74874. /**
  74875. * Called on the effect must be updated (changed mode, samples count, etc.).
  74876. */
  74877. private _updateEffect;
  74878. /** @hidden */
  74879. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74880. }
  74881. }
  74882. declare module BABYLON {
  74883. /** @hidden */
  74884. export var refractionPixelShader: {
  74885. name: string;
  74886. shader: string;
  74887. };
  74888. }
  74889. declare module BABYLON {
  74890. /**
  74891. * Post process which applies a refraction texture
  74892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74893. */
  74894. export class RefractionPostProcess extends PostProcess {
  74895. private _refTexture;
  74896. private _ownRefractionTexture;
  74897. /** the base color of the refraction (used to taint the rendering) */
  74898. color: Color3;
  74899. /** simulated refraction depth */
  74900. depth: number;
  74901. /** the coefficient of the base color (0 to remove base color tainting) */
  74902. colorLevel: number;
  74903. /** Gets the url used to load the refraction texture */
  74904. refractionTextureUrl: string;
  74905. /**
  74906. * Gets or sets the refraction texture
  74907. * Please note that you are responsible for disposing the texture if you set it manually
  74908. */
  74909. get refractionTexture(): Texture;
  74910. set refractionTexture(value: Texture);
  74911. /**
  74912. * Gets a string identifying the name of the class
  74913. * @returns "RefractionPostProcess" string
  74914. */
  74915. getClassName(): string;
  74916. /**
  74917. * Initializes the RefractionPostProcess
  74918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74919. * @param name The name of the effect.
  74920. * @param refractionTextureUrl Url of the refraction texture to use
  74921. * @param color the base color of the refraction (used to taint the rendering)
  74922. * @param depth simulated refraction depth
  74923. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74924. * @param camera The camera to apply the render pass to.
  74925. * @param options The required width/height ratio to downsize to before computing the render pass.
  74926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74927. * @param engine The engine which the post process will be applied. (default: current engine)
  74928. * @param reusable If the post process can be reused on the same frame. (default: false)
  74929. */
  74930. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74931. /**
  74932. * Disposes of the post process
  74933. * @param camera Camera to dispose post process on
  74934. */
  74935. dispose(camera: Camera): void;
  74936. /** @hidden */
  74937. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74938. }
  74939. }
  74940. declare module BABYLON {
  74941. /** @hidden */
  74942. export var sharpenPixelShader: {
  74943. name: string;
  74944. shader: string;
  74945. };
  74946. }
  74947. declare module BABYLON {
  74948. /**
  74949. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74950. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74951. */
  74952. export class SharpenPostProcess extends PostProcess {
  74953. /**
  74954. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74955. */
  74956. colorAmount: number;
  74957. /**
  74958. * How much sharpness should be applied (default: 0.3)
  74959. */
  74960. edgeAmount: number;
  74961. /**
  74962. * Gets a string identifying the name of the class
  74963. * @returns "SharpenPostProcess" string
  74964. */
  74965. getClassName(): string;
  74966. /**
  74967. * Creates a new instance ConvolutionPostProcess
  74968. * @param name The name of the effect.
  74969. * @param options The required width/height ratio to downsize to before computing the render pass.
  74970. * @param camera The camera to apply the render pass to.
  74971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74972. * @param engine The engine which the post process will be applied. (default: current engine)
  74973. * @param reusable If the post process can be reused on the same frame. (default: false)
  74974. * @param textureType Type of textures used when performing the post process. (default: 0)
  74975. * @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)
  74976. */
  74977. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74978. /** @hidden */
  74979. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74980. }
  74981. }
  74982. declare module BABYLON {
  74983. /**
  74984. * PostProcessRenderPipeline
  74985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74986. */
  74987. export class PostProcessRenderPipeline {
  74988. private engine;
  74989. private _renderEffects;
  74990. private _renderEffectsForIsolatedPass;
  74991. /**
  74992. * List of inspectable custom properties (used by the Inspector)
  74993. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74994. */
  74995. inspectableCustomProperties: IInspectable[];
  74996. /**
  74997. * @hidden
  74998. */
  74999. protected _cameras: Camera[];
  75000. /** @hidden */
  75001. _name: string;
  75002. /**
  75003. * Gets pipeline name
  75004. */
  75005. get name(): string;
  75006. /** Gets the list of attached cameras */
  75007. get cameras(): Camera[];
  75008. /**
  75009. * Initializes a PostProcessRenderPipeline
  75010. * @param engine engine to add the pipeline to
  75011. * @param name name of the pipeline
  75012. */
  75013. constructor(engine: Engine, name: string);
  75014. /**
  75015. * Gets the class name
  75016. * @returns "PostProcessRenderPipeline"
  75017. */
  75018. getClassName(): string;
  75019. /**
  75020. * If all the render effects in the pipeline are supported
  75021. */
  75022. get isSupported(): boolean;
  75023. /**
  75024. * Adds an effect to the pipeline
  75025. * @param renderEffect the effect to add
  75026. */
  75027. addEffect(renderEffect: PostProcessRenderEffect): void;
  75028. /** @hidden */
  75029. _rebuild(): void;
  75030. /** @hidden */
  75031. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75032. /** @hidden */
  75033. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75034. /** @hidden */
  75035. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75036. /** @hidden */
  75037. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75038. /** @hidden */
  75039. _attachCameras(cameras: Camera, unique: boolean): void;
  75040. /** @hidden */
  75041. _attachCameras(cameras: Camera[], unique: boolean): void;
  75042. /** @hidden */
  75043. _detachCameras(cameras: Camera): void;
  75044. /** @hidden */
  75045. _detachCameras(cameras: Nullable<Camera[]>): void;
  75046. /** @hidden */
  75047. _update(): void;
  75048. /** @hidden */
  75049. _reset(): void;
  75050. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75051. /**
  75052. * Sets the required values to the prepass renderer.
  75053. * @param prePassRenderer defines the prepass renderer to setup.
  75054. * @returns true if the pre pass is needed.
  75055. */
  75056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75057. /**
  75058. * Disposes of the pipeline
  75059. */
  75060. dispose(): void;
  75061. }
  75062. }
  75063. declare module BABYLON {
  75064. /**
  75065. * PostProcessRenderPipelineManager class
  75066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75067. */
  75068. export class PostProcessRenderPipelineManager {
  75069. private _renderPipelines;
  75070. /**
  75071. * Initializes a PostProcessRenderPipelineManager
  75072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75073. */
  75074. constructor();
  75075. /**
  75076. * Gets the list of supported render pipelines
  75077. */
  75078. get supportedPipelines(): PostProcessRenderPipeline[];
  75079. /**
  75080. * Adds a pipeline to the manager
  75081. * @param renderPipeline The pipeline to add
  75082. */
  75083. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75084. /**
  75085. * Attaches a camera to the pipeline
  75086. * @param renderPipelineName The name of the pipeline to attach to
  75087. * @param cameras the camera to attach
  75088. * @param unique if the camera can be attached multiple times to the pipeline
  75089. */
  75090. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75091. /**
  75092. * Detaches a camera from the pipeline
  75093. * @param renderPipelineName The name of the pipeline to detach from
  75094. * @param cameras the camera to detach
  75095. */
  75096. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75097. /**
  75098. * Enables an effect by name on a pipeline
  75099. * @param renderPipelineName the name of the pipeline to enable the effect in
  75100. * @param renderEffectName the name of the effect to enable
  75101. * @param cameras the cameras that the effect should be enabled on
  75102. */
  75103. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75104. /**
  75105. * Disables an effect by name on a pipeline
  75106. * @param renderPipelineName the name of the pipeline to disable the effect in
  75107. * @param renderEffectName the name of the effect to disable
  75108. * @param cameras the cameras that the effect should be disabled on
  75109. */
  75110. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75111. /**
  75112. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75113. */
  75114. update(): void;
  75115. /** @hidden */
  75116. _rebuild(): void;
  75117. /**
  75118. * Disposes of the manager and pipelines
  75119. */
  75120. dispose(): void;
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. interface Scene {
  75125. /** @hidden (Backing field) */
  75126. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75127. /**
  75128. * Gets the postprocess render pipeline manager
  75129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75130. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75131. */
  75132. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75133. }
  75134. /**
  75135. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75136. */
  75137. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75138. /**
  75139. * The component name helpful to identify the component in the list of scene components.
  75140. */
  75141. readonly name: string;
  75142. /**
  75143. * The scene the component belongs to.
  75144. */
  75145. scene: Scene;
  75146. /**
  75147. * Creates a new instance of the component for the given scene
  75148. * @param scene Defines the scene to register the component in
  75149. */
  75150. constructor(scene: Scene);
  75151. /**
  75152. * Registers the component in a given scene
  75153. */
  75154. register(): void;
  75155. /**
  75156. * Rebuilds the elements related to this component in case of
  75157. * context lost for instance.
  75158. */
  75159. rebuild(): void;
  75160. /**
  75161. * Disposes the component and the associated resources
  75162. */
  75163. dispose(): void;
  75164. private _gatherRenderTargets;
  75165. }
  75166. }
  75167. declare module BABYLON {
  75168. /**
  75169. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75170. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75171. */
  75172. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75173. private _scene;
  75174. private _camerasToBeAttached;
  75175. /**
  75176. * ID of the sharpen post process,
  75177. */
  75178. private readonly SharpenPostProcessId;
  75179. /**
  75180. * @ignore
  75181. * ID of the image processing post process;
  75182. */
  75183. readonly ImageProcessingPostProcessId: string;
  75184. /**
  75185. * @ignore
  75186. * ID of the Fast Approximate Anti-Aliasing post process;
  75187. */
  75188. readonly FxaaPostProcessId: string;
  75189. /**
  75190. * ID of the chromatic aberration post process,
  75191. */
  75192. private readonly ChromaticAberrationPostProcessId;
  75193. /**
  75194. * ID of the grain post process
  75195. */
  75196. private readonly GrainPostProcessId;
  75197. /**
  75198. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75199. */
  75200. sharpen: SharpenPostProcess;
  75201. private _sharpenEffect;
  75202. private bloom;
  75203. /**
  75204. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75205. */
  75206. depthOfField: DepthOfFieldEffect;
  75207. /**
  75208. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  75209. */
  75210. fxaa: FxaaPostProcess;
  75211. /**
  75212. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75213. */
  75214. imageProcessing: ImageProcessingPostProcess;
  75215. /**
  75216. * Chromatic aberration post process which will shift rgb colors in the image
  75217. */
  75218. chromaticAberration: ChromaticAberrationPostProcess;
  75219. private _chromaticAberrationEffect;
  75220. /**
  75221. * Grain post process which add noise to the image
  75222. */
  75223. grain: GrainPostProcess;
  75224. private _grainEffect;
  75225. /**
  75226. * Glow post process which adds a glow to emissive areas of the image
  75227. */
  75228. private _glowLayer;
  75229. /**
  75230. * Animations which can be used to tweak settings over a period of time
  75231. */
  75232. animations: Animation[];
  75233. private _imageProcessingConfigurationObserver;
  75234. private _sharpenEnabled;
  75235. private _bloomEnabled;
  75236. private _depthOfFieldEnabled;
  75237. private _depthOfFieldBlurLevel;
  75238. private _fxaaEnabled;
  75239. private _imageProcessingEnabled;
  75240. private _defaultPipelineTextureType;
  75241. private _bloomScale;
  75242. private _chromaticAberrationEnabled;
  75243. private _grainEnabled;
  75244. private _buildAllowed;
  75245. /**
  75246. * This is triggered each time the pipeline has been built.
  75247. */
  75248. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75249. /**
  75250. * Gets active scene
  75251. */
  75252. get scene(): Scene;
  75253. /**
  75254. * Enable or disable the sharpen process from the pipeline
  75255. */
  75256. set sharpenEnabled(enabled: boolean);
  75257. get sharpenEnabled(): boolean;
  75258. private _resizeObserver;
  75259. private _hardwareScaleLevel;
  75260. private _bloomKernel;
  75261. /**
  75262. * Specifies the size of the bloom blur kernel, relative to the final output size
  75263. */
  75264. get bloomKernel(): number;
  75265. set bloomKernel(value: number);
  75266. /**
  75267. * Specifies the weight of the bloom in the final rendering
  75268. */
  75269. private _bloomWeight;
  75270. /**
  75271. * Specifies the luma threshold for the area that will be blurred by the bloom
  75272. */
  75273. private _bloomThreshold;
  75274. private _hdr;
  75275. /**
  75276. * The strength of the bloom.
  75277. */
  75278. set bloomWeight(value: number);
  75279. get bloomWeight(): number;
  75280. /**
  75281. * The strength of the bloom.
  75282. */
  75283. set bloomThreshold(value: number);
  75284. get bloomThreshold(): number;
  75285. /**
  75286. * The scale of the bloom, lower value will provide better performance.
  75287. */
  75288. set bloomScale(value: number);
  75289. get bloomScale(): number;
  75290. /**
  75291. * Enable or disable the bloom from the pipeline
  75292. */
  75293. set bloomEnabled(enabled: boolean);
  75294. get bloomEnabled(): boolean;
  75295. private _rebuildBloom;
  75296. /**
  75297. * If the depth of field is enabled.
  75298. */
  75299. get depthOfFieldEnabled(): boolean;
  75300. set depthOfFieldEnabled(enabled: boolean);
  75301. /**
  75302. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75303. */
  75304. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75305. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75306. /**
  75307. * If the anti aliasing is enabled.
  75308. */
  75309. set fxaaEnabled(enabled: boolean);
  75310. get fxaaEnabled(): boolean;
  75311. private _samples;
  75312. /**
  75313. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75314. */
  75315. set samples(sampleCount: number);
  75316. get samples(): number;
  75317. /**
  75318. * If image processing is enabled.
  75319. */
  75320. set imageProcessingEnabled(enabled: boolean);
  75321. get imageProcessingEnabled(): boolean;
  75322. /**
  75323. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75324. */
  75325. set glowLayerEnabled(enabled: boolean);
  75326. get glowLayerEnabled(): boolean;
  75327. /**
  75328. * Gets the glow layer (or null if not defined)
  75329. */
  75330. get glowLayer(): Nullable<GlowLayer>;
  75331. /**
  75332. * Enable or disable the chromaticAberration process from the pipeline
  75333. */
  75334. set chromaticAberrationEnabled(enabled: boolean);
  75335. get chromaticAberrationEnabled(): boolean;
  75336. /**
  75337. * Enable or disable the grain process from the pipeline
  75338. */
  75339. set grainEnabled(enabled: boolean);
  75340. get grainEnabled(): boolean;
  75341. /**
  75342. * @constructor
  75343. * @param name - The rendering pipeline name (default: "")
  75344. * @param hdr - If high dynamic range textures should be used (default: true)
  75345. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75346. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75347. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75348. */
  75349. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75350. /**
  75351. * Get the class name
  75352. * @returns "DefaultRenderingPipeline"
  75353. */
  75354. getClassName(): string;
  75355. /**
  75356. * Force the compilation of the entire pipeline.
  75357. */
  75358. prepare(): void;
  75359. private _hasCleared;
  75360. private _prevPostProcess;
  75361. private _prevPrevPostProcess;
  75362. private _setAutoClearAndTextureSharing;
  75363. private _depthOfFieldSceneObserver;
  75364. private _buildPipeline;
  75365. private _disposePostProcesses;
  75366. /**
  75367. * Adds a camera to the pipeline
  75368. * @param camera the camera to be added
  75369. */
  75370. addCamera(camera: Camera): void;
  75371. /**
  75372. * Removes a camera from the pipeline
  75373. * @param camera the camera to remove
  75374. */
  75375. removeCamera(camera: Camera): void;
  75376. /**
  75377. * Dispose of the pipeline and stop all post processes
  75378. */
  75379. dispose(): void;
  75380. /**
  75381. * Serialize the rendering pipeline (Used when exporting)
  75382. * @returns the serialized object
  75383. */
  75384. serialize(): any;
  75385. /**
  75386. * Parse the serialized pipeline
  75387. * @param source Source pipeline.
  75388. * @param scene The scene to load the pipeline to.
  75389. * @param rootUrl The URL of the serialized pipeline.
  75390. * @returns An instantiated pipeline from the serialized object.
  75391. */
  75392. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75393. }
  75394. }
  75395. declare module BABYLON {
  75396. /** @hidden */
  75397. export var lensHighlightsPixelShader: {
  75398. name: string;
  75399. shader: string;
  75400. };
  75401. }
  75402. declare module BABYLON {
  75403. /** @hidden */
  75404. export var depthOfFieldPixelShader: {
  75405. name: string;
  75406. shader: string;
  75407. };
  75408. }
  75409. declare module BABYLON {
  75410. /**
  75411. * BABYLON.JS Chromatic Aberration GLSL Shader
  75412. * Author: Olivier Guyot
  75413. * Separates very slightly R, G and B colors on the edges of the screen
  75414. * Inspired by Francois Tarlier & Martins Upitis
  75415. */
  75416. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75417. /**
  75418. * @ignore
  75419. * The chromatic aberration PostProcess id in the pipeline
  75420. */
  75421. LensChromaticAberrationEffect: string;
  75422. /**
  75423. * @ignore
  75424. * The highlights enhancing PostProcess id in the pipeline
  75425. */
  75426. HighlightsEnhancingEffect: string;
  75427. /**
  75428. * @ignore
  75429. * The depth-of-field PostProcess id in the pipeline
  75430. */
  75431. LensDepthOfFieldEffect: string;
  75432. private _scene;
  75433. private _depthTexture;
  75434. private _grainTexture;
  75435. private _chromaticAberrationPostProcess;
  75436. private _highlightsPostProcess;
  75437. private _depthOfFieldPostProcess;
  75438. private _edgeBlur;
  75439. private _grainAmount;
  75440. private _chromaticAberration;
  75441. private _distortion;
  75442. private _highlightsGain;
  75443. private _highlightsThreshold;
  75444. private _dofDistance;
  75445. private _dofAperture;
  75446. private _dofDarken;
  75447. private _dofPentagon;
  75448. private _blurNoise;
  75449. /**
  75450. * @constructor
  75451. *
  75452. * Effect parameters are as follow:
  75453. * {
  75454. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75455. * edge_blur: number; // from 0 to x (1 for realism)
  75456. * distortion: number; // from 0 to x (1 for realism)
  75457. * grain_amount: number; // from 0 to 1
  75458. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75459. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75460. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75461. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75462. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75463. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75464. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75465. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75466. * }
  75467. * Note: if an effect parameter is unset, effect is disabled
  75468. *
  75469. * @param name The rendering pipeline name
  75470. * @param parameters - An object containing all parameters (see above)
  75471. * @param scene The scene linked to this pipeline
  75472. * @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)
  75473. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75474. */
  75475. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75476. /**
  75477. * Get the class name
  75478. * @returns "LensRenderingPipeline"
  75479. */
  75480. getClassName(): string;
  75481. /**
  75482. * Gets associated scene
  75483. */
  75484. get scene(): Scene;
  75485. /**
  75486. * Gets or sets the edge blur
  75487. */
  75488. get edgeBlur(): number;
  75489. set edgeBlur(value: number);
  75490. /**
  75491. * Gets or sets the grain amount
  75492. */
  75493. get grainAmount(): number;
  75494. set grainAmount(value: number);
  75495. /**
  75496. * Gets or sets the chromatic aberration amount
  75497. */
  75498. get chromaticAberration(): number;
  75499. set chromaticAberration(value: number);
  75500. /**
  75501. * Gets or sets the depth of field aperture
  75502. */
  75503. get dofAperture(): number;
  75504. set dofAperture(value: number);
  75505. /**
  75506. * Gets or sets the edge distortion
  75507. */
  75508. get edgeDistortion(): number;
  75509. set edgeDistortion(value: number);
  75510. /**
  75511. * Gets or sets the depth of field distortion
  75512. */
  75513. get dofDistortion(): number;
  75514. set dofDistortion(value: number);
  75515. /**
  75516. * Gets or sets the darken out of focus amount
  75517. */
  75518. get darkenOutOfFocus(): number;
  75519. set darkenOutOfFocus(value: number);
  75520. /**
  75521. * Gets or sets a boolean indicating if blur noise is enabled
  75522. */
  75523. get blurNoise(): boolean;
  75524. set blurNoise(value: boolean);
  75525. /**
  75526. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75527. */
  75528. get pentagonBokeh(): boolean;
  75529. set pentagonBokeh(value: boolean);
  75530. /**
  75531. * Gets or sets the highlight grain amount
  75532. */
  75533. get highlightsGain(): number;
  75534. set highlightsGain(value: number);
  75535. /**
  75536. * Gets or sets the highlight threshold
  75537. */
  75538. get highlightsThreshold(): number;
  75539. set highlightsThreshold(value: number);
  75540. /**
  75541. * Sets the amount of blur at the edges
  75542. * @param amount blur amount
  75543. */
  75544. setEdgeBlur(amount: number): void;
  75545. /**
  75546. * Sets edge blur to 0
  75547. */
  75548. disableEdgeBlur(): void;
  75549. /**
  75550. * Sets the amount of grain
  75551. * @param amount Amount of grain
  75552. */
  75553. setGrainAmount(amount: number): void;
  75554. /**
  75555. * Set grain amount to 0
  75556. */
  75557. disableGrain(): void;
  75558. /**
  75559. * Sets the chromatic aberration amount
  75560. * @param amount amount of chromatic aberration
  75561. */
  75562. setChromaticAberration(amount: number): void;
  75563. /**
  75564. * Sets chromatic aberration amount to 0
  75565. */
  75566. disableChromaticAberration(): void;
  75567. /**
  75568. * Sets the EdgeDistortion amount
  75569. * @param amount amount of EdgeDistortion
  75570. */
  75571. setEdgeDistortion(amount: number): void;
  75572. /**
  75573. * Sets edge distortion to 0
  75574. */
  75575. disableEdgeDistortion(): void;
  75576. /**
  75577. * Sets the FocusDistance amount
  75578. * @param amount amount of FocusDistance
  75579. */
  75580. setFocusDistance(amount: number): void;
  75581. /**
  75582. * Disables depth of field
  75583. */
  75584. disableDepthOfField(): void;
  75585. /**
  75586. * Sets the Aperture amount
  75587. * @param amount amount of Aperture
  75588. */
  75589. setAperture(amount: number): void;
  75590. /**
  75591. * Sets the DarkenOutOfFocus amount
  75592. * @param amount amount of DarkenOutOfFocus
  75593. */
  75594. setDarkenOutOfFocus(amount: number): void;
  75595. private _pentagonBokehIsEnabled;
  75596. /**
  75597. * Creates a pentagon bokeh effect
  75598. */
  75599. enablePentagonBokeh(): void;
  75600. /**
  75601. * Disables the pentagon bokeh effect
  75602. */
  75603. disablePentagonBokeh(): void;
  75604. /**
  75605. * Enables noise blur
  75606. */
  75607. enableNoiseBlur(): void;
  75608. /**
  75609. * Disables noise blur
  75610. */
  75611. disableNoiseBlur(): void;
  75612. /**
  75613. * Sets the HighlightsGain amount
  75614. * @param amount amount of HighlightsGain
  75615. */
  75616. setHighlightsGain(amount: number): void;
  75617. /**
  75618. * Sets the HighlightsThreshold amount
  75619. * @param amount amount of HighlightsThreshold
  75620. */
  75621. setHighlightsThreshold(amount: number): void;
  75622. /**
  75623. * Disables highlights
  75624. */
  75625. disableHighlights(): void;
  75626. /**
  75627. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75628. * @param disableDepthRender If the scene's depth rendering should be disabled (default: false)
  75629. */
  75630. dispose(disableDepthRender?: boolean): void;
  75631. private _createChromaticAberrationPostProcess;
  75632. private _createHighlightsPostProcess;
  75633. private _createDepthOfFieldPostProcess;
  75634. private _createGrainTexture;
  75635. }
  75636. }
  75637. declare module BABYLON {
  75638. /**
  75639. * Contains all parameters needed for the prepass to perform
  75640. * screen space subsurface scattering
  75641. */
  75642. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75643. /**
  75644. * Is subsurface enabled
  75645. */
  75646. enabled: boolean;
  75647. /**
  75648. * Name of the configuration
  75649. */
  75650. name: string;
  75651. /**
  75652. * Textures that should be present in the MRT for this effect to work
  75653. */
  75654. readonly texturesRequired: number[];
  75655. }
  75656. }
  75657. declare module BABYLON {
  75658. /** @hidden */
  75659. export var ssao2PixelShader: {
  75660. name: string;
  75661. shader: string;
  75662. };
  75663. }
  75664. declare module BABYLON {
  75665. /** @hidden */
  75666. export var ssaoCombinePixelShader: {
  75667. name: string;
  75668. shader: string;
  75669. };
  75670. }
  75671. declare module BABYLON {
  75672. /**
  75673. * Render pipeline to produce ssao effect
  75674. */
  75675. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75676. /**
  75677. * @ignore
  75678. * The PassPostProcess id in the pipeline that contains the original scene color
  75679. */
  75680. SSAOOriginalSceneColorEffect: string;
  75681. /**
  75682. * @ignore
  75683. * The SSAO PostProcess id in the pipeline
  75684. */
  75685. SSAORenderEffect: string;
  75686. /**
  75687. * @ignore
  75688. * The horizontal blur PostProcess id in the pipeline
  75689. */
  75690. SSAOBlurHRenderEffect: string;
  75691. /**
  75692. * @ignore
  75693. * The vertical blur PostProcess id in the pipeline
  75694. */
  75695. SSAOBlurVRenderEffect: string;
  75696. /**
  75697. * @ignore
  75698. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75699. */
  75700. SSAOCombineRenderEffect: string;
  75701. /**
  75702. * The output strength of the SSAO post-process. Default value is 1.0.
  75703. */
  75704. totalStrength: number;
  75705. /**
  75706. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75707. */
  75708. maxZ: number;
  75709. /**
  75710. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75711. */
  75712. minZAspect: number;
  75713. private _samples;
  75714. /**
  75715. * Number of samples used for the SSAO calculations. Default value is 8
  75716. */
  75717. set samples(n: number);
  75718. get samples(): number;
  75719. private _textureSamples;
  75720. /**
  75721. * Number of samples to use for antialiasing
  75722. */
  75723. set textureSamples(n: number);
  75724. get textureSamples(): number;
  75725. /**
  75726. * Force rendering the geometry through geometry buffer
  75727. */
  75728. private _forceGeometryBuffer;
  75729. /**
  75730. * Ratio object used for SSAO ratio and blur ratio
  75731. */
  75732. private _ratio;
  75733. /**
  75734. * Dynamically generated sphere sampler.
  75735. */
  75736. private _sampleSphere;
  75737. /**
  75738. * Blur filter offsets
  75739. */
  75740. private _samplerOffsets;
  75741. private _expensiveBlur;
  75742. /**
  75743. * If bilateral blur should be used
  75744. */
  75745. set expensiveBlur(b: boolean);
  75746. get expensiveBlur(): boolean;
  75747. /**
  75748. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75749. */
  75750. radius: number;
  75751. /**
  75752. * The base color of the SSAO post-process
  75753. * The final result is "base + ssao" between [0, 1]
  75754. */
  75755. base: number;
  75756. /**
  75757. * Support test.
  75758. */
  75759. static get IsSupported(): boolean;
  75760. private _scene;
  75761. private _randomTexture;
  75762. private _originalColorPostProcess;
  75763. private _ssaoPostProcess;
  75764. private _blurHPostProcess;
  75765. private _blurVPostProcess;
  75766. private _ssaoCombinePostProcess;
  75767. private _prePassRenderer;
  75768. /**
  75769. * Gets active scene
  75770. */
  75771. get scene(): Scene;
  75772. /**
  75773. * @constructor
  75774. * @param name The rendering pipeline name
  75775. * @param scene The scene linked to this pipeline
  75776. * @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 }
  75777. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75778. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75779. */
  75780. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75781. /**
  75782. * Get the class name
  75783. * @returns "SSAO2RenderingPipeline"
  75784. */
  75785. getClassName(): string;
  75786. /**
  75787. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75788. */
  75789. dispose(disableGeometryBufferRenderer?: boolean): void;
  75790. private _createBlurPostProcess;
  75791. /** @hidden */
  75792. _rebuild(): void;
  75793. private _bits;
  75794. private _radicalInverse_VdC;
  75795. private _hammersley;
  75796. private _hemisphereSample_uniform;
  75797. private _generateHemisphere;
  75798. private _getDefinesForSSAO;
  75799. private static readonly ORTHO_DEPTH_PROJECTION;
  75800. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75801. private _createSSAOPostProcess;
  75802. private _createSSAOCombinePostProcess;
  75803. private _createRandomTexture;
  75804. /**
  75805. * Serialize the rendering pipeline (Used when exporting)
  75806. * @returns the serialized object
  75807. */
  75808. serialize(): any;
  75809. /**
  75810. * Parse the serialized pipeline
  75811. * @param source Source pipeline.
  75812. * @param scene The scene to load the pipeline to.
  75813. * @param rootUrl The URL of the serialized pipeline.
  75814. * @returns An instantiated pipeline from the serialized object.
  75815. */
  75816. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75817. }
  75818. }
  75819. declare module BABYLON {
  75820. /** @hidden */
  75821. export var ssaoPixelShader: {
  75822. name: string;
  75823. shader: string;
  75824. };
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * Render pipeline to produce ssao effect
  75829. */
  75830. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75831. /**
  75832. * @ignore
  75833. * The PassPostProcess id in the pipeline that contains the original scene color
  75834. */
  75835. SSAOOriginalSceneColorEffect: string;
  75836. /**
  75837. * @ignore
  75838. * The SSAO PostProcess id in the pipeline
  75839. */
  75840. SSAORenderEffect: string;
  75841. /**
  75842. * @ignore
  75843. * The horizontal blur PostProcess id in the pipeline
  75844. */
  75845. SSAOBlurHRenderEffect: string;
  75846. /**
  75847. * @ignore
  75848. * The vertical blur PostProcess id in the pipeline
  75849. */
  75850. SSAOBlurVRenderEffect: string;
  75851. /**
  75852. * @ignore
  75853. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75854. */
  75855. SSAOCombineRenderEffect: string;
  75856. /**
  75857. * The output strength of the SSAO post-process. Default value is 1.0.
  75858. */
  75859. totalStrength: number;
  75860. /**
  75861. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75862. */
  75863. radius: number;
  75864. /**
  75865. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75866. * Must not be equal to fallOff and superior to fallOff.
  75867. * Default value is 0.0075
  75868. */
  75869. area: number;
  75870. /**
  75871. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75872. * Must not be equal to area and inferior to area.
  75873. * Default value is 0.000001
  75874. */
  75875. fallOff: number;
  75876. /**
  75877. * The base color of the SSAO post-process
  75878. * The final result is "base + ssao" between [0, 1]
  75879. */
  75880. base: number;
  75881. private _scene;
  75882. private _depthTexture;
  75883. private _randomTexture;
  75884. private _originalColorPostProcess;
  75885. private _ssaoPostProcess;
  75886. private _blurHPostProcess;
  75887. private _blurVPostProcess;
  75888. private _ssaoCombinePostProcess;
  75889. private _firstUpdate;
  75890. /**
  75891. * Gets active scene
  75892. */
  75893. get scene(): Scene;
  75894. /**
  75895. * @constructor
  75896. * @param name - The rendering pipeline name
  75897. * @param scene - The scene linked to this pipeline
  75898. * @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 }
  75899. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75900. */
  75901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75902. /**
  75903. * Get the class name
  75904. * @returns "SSAORenderingPipeline"
  75905. */
  75906. getClassName(): string;
  75907. /**
  75908. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75909. */
  75910. dispose(disableDepthRender?: boolean): void;
  75911. private _createBlurPostProcess;
  75912. /** @hidden */
  75913. _rebuild(): void;
  75914. private _createSSAOPostProcess;
  75915. private _createSSAOCombinePostProcess;
  75916. private _createRandomTexture;
  75917. }
  75918. }
  75919. declare module BABYLON {
  75920. /**
  75921. * Contains all parameters needed for the prepass to perform
  75922. * screen space reflections
  75923. */
  75924. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75925. /**
  75926. * Is ssr enabled
  75927. */
  75928. enabled: boolean;
  75929. /**
  75930. * Name of the configuration
  75931. */
  75932. name: string;
  75933. /**
  75934. * Textures that should be present in the MRT for this effect to work
  75935. */
  75936. readonly texturesRequired: number[];
  75937. }
  75938. }
  75939. declare module BABYLON {
  75940. /** @hidden */
  75941. export var screenSpaceReflectionPixelShader: {
  75942. name: string;
  75943. shader: string;
  75944. };
  75945. }
  75946. declare module BABYLON {
  75947. /**
  75948. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75949. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75950. */
  75951. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75952. /**
  75953. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75954. */
  75955. threshold: number;
  75956. /**
  75957. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75958. */
  75959. strength: number;
  75960. /**
  75961. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75962. */
  75963. reflectionSpecularFalloffExponent: number;
  75964. /**
  75965. * 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]
  75966. */
  75967. step: number;
  75968. /**
  75969. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75970. */
  75971. roughnessFactor: number;
  75972. private _forceGeometryBuffer;
  75973. private _geometryBufferRenderer;
  75974. private _prePassRenderer;
  75975. private _enableSmoothReflections;
  75976. private _reflectionSamples;
  75977. private _smoothSteps;
  75978. /**
  75979. * Gets a string identifying the name of the class
  75980. * @returns "ScreenSpaceReflectionPostProcess" string
  75981. */
  75982. getClassName(): string;
  75983. /**
  75984. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75985. * @param name The name of the effect.
  75986. * @param scene The scene containing the objects to calculate reflections.
  75987. * @param options The required width/height ratio to downsize to before computing the render pass.
  75988. * @param camera The camera to apply the render pass to.
  75989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75990. * @param engine The engine which the post process will be applied. (default: current engine)
  75991. * @param reusable If the post process can be reused on the same frame. (default: false)
  75992. * @param textureType Type of textures used when performing the post process. (default: 0)
  75993. * @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)
  75994. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75995. */
  75996. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75997. /**
  75998. * Gets whether or not smoothing reflections is enabled.
  75999. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76000. */
  76001. get enableSmoothReflections(): boolean;
  76002. /**
  76003. * Sets whether or not smoothing reflections is enabled.
  76004. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76005. */
  76006. set enableSmoothReflections(enabled: boolean);
  76007. /**
  76008. * Gets the number of samples taken while computing reflections. More samples count is high,
  76009. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76010. */
  76011. get reflectionSamples(): number;
  76012. /**
  76013. * Sets the number of samples taken while computing reflections. More samples count is high,
  76014. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76015. */
  76016. set reflectionSamples(samples: number);
  76017. /**
  76018. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76019. * more the post-process will require GPU power and can generate a drop in FPS.
  76020. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76021. */
  76022. get smoothSteps(): number;
  76023. set smoothSteps(steps: number);
  76024. private _updateEffectDefines;
  76025. /** @hidden */
  76026. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76027. }
  76028. }
  76029. declare module BABYLON {
  76030. /** @hidden */
  76031. export var standardPixelShader: {
  76032. name: string;
  76033. shader: string;
  76034. };
  76035. }
  76036. declare module BABYLON {
  76037. /**
  76038. * Standard rendering pipeline
  76039. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76040. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76041. */
  76042. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76043. /**
  76044. * Public members
  76045. */
  76046. /**
  76047. * Post-process which contains the original scene color before the pipeline applies all the effects
  76048. */
  76049. originalPostProcess: Nullable<PostProcess>;
  76050. /**
  76051. * Post-process used to down scale an image x4
  76052. */
  76053. downSampleX4PostProcess: Nullable<PostProcess>;
  76054. /**
  76055. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76056. */
  76057. brightPassPostProcess: Nullable<PostProcess>;
  76058. /**
  76059. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76060. */
  76061. blurHPostProcesses: PostProcess[];
  76062. /**
  76063. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76064. */
  76065. blurVPostProcesses: PostProcess[];
  76066. /**
  76067. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76068. */
  76069. textureAdderPostProcess: Nullable<PostProcess>;
  76070. /**
  76071. * Post-process used to create volumetric lighting effect
  76072. */
  76073. volumetricLightPostProcess: Nullable<PostProcess>;
  76074. /**
  76075. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76076. */
  76077. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76078. /**
  76079. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76080. */
  76081. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76082. /**
  76083. * Post-process used to merge the volumetric light effect and the real scene color
  76084. */
  76085. volumetricLightMergePostProces: Nullable<PostProcess>;
  76086. /**
  76087. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76088. */
  76089. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76090. /**
  76091. * Base post-process used to calculate the average luminance of the final image for HDR
  76092. */
  76093. luminancePostProcess: Nullable<PostProcess>;
  76094. /**
  76095. * Post-processes used to create down sample post-processes in order to get
  76096. * the average luminance of the final image for HDR
  76097. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76098. */
  76099. luminanceDownSamplePostProcesses: PostProcess[];
  76100. /**
  76101. * Post-process used to create a HDR effect (light adaptation)
  76102. */
  76103. hdrPostProcess: Nullable<PostProcess>;
  76104. /**
  76105. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76106. */
  76107. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76108. /**
  76109. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76110. */
  76111. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76112. /**
  76113. * Post-process used to merge the final HDR post-process and the real scene color
  76114. */
  76115. hdrFinalPostProcess: Nullable<PostProcess>;
  76116. /**
  76117. * Post-process used to create a lens flare effect
  76118. */
  76119. lensFlarePostProcess: Nullable<PostProcess>;
  76120. /**
  76121. * Post-process that merges the result of the lens flare post-process and the real scene color
  76122. */
  76123. lensFlareComposePostProcess: Nullable<PostProcess>;
  76124. /**
  76125. * Post-process used to create a motion blur effect
  76126. */
  76127. motionBlurPostProcess: Nullable<PostProcess>;
  76128. /**
  76129. * Post-process used to create a depth of field effect
  76130. */
  76131. depthOfFieldPostProcess: Nullable<PostProcess>;
  76132. /**
  76133. * The Fast Approximate Anti-Aliasing post process which attempts to remove aliasing from an image.
  76134. */
  76135. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76136. /**
  76137. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76138. */
  76139. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76140. /**
  76141. * Represents the brightness threshold in order to configure the illuminated surfaces
  76142. */
  76143. brightThreshold: number;
  76144. /**
  76145. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76146. */
  76147. blurWidth: number;
  76148. /**
  76149. * Sets if the blur for highlighted surfaces must be only horizontal
  76150. */
  76151. horizontalBlur: boolean;
  76152. /**
  76153. * Gets the overall exposure used by the pipeline
  76154. */
  76155. get exposure(): number;
  76156. /**
  76157. * Sets the overall exposure used by the pipeline
  76158. */
  76159. set exposure(value: number);
  76160. /**
  76161. * Texture used typically to simulate "dirty" on camera lens
  76162. */
  76163. lensTexture: Nullable<Texture>;
  76164. /**
  76165. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76166. */
  76167. volumetricLightCoefficient: number;
  76168. /**
  76169. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76170. */
  76171. volumetricLightPower: number;
  76172. /**
  76173. * Used the set the blur intensity to smooth the volumetric lights
  76174. */
  76175. volumetricLightBlurScale: number;
  76176. /**
  76177. * Light (spot or directional) used to generate the volumetric lights rays
  76178. * The source light must have a shadow generate so the pipeline can get its
  76179. * depth map
  76180. */
  76181. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76182. /**
  76183. * For eye adaptation, represents the minimum luminance the eye can see
  76184. */
  76185. hdrMinimumLuminance: number;
  76186. /**
  76187. * For eye adaptation, represents the decrease luminance speed
  76188. */
  76189. hdrDecreaseRate: number;
  76190. /**
  76191. * For eye adaptation, represents the increase luminance speed
  76192. */
  76193. hdrIncreaseRate: number;
  76194. /**
  76195. * Gets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76196. */
  76197. get hdrAutoExposure(): boolean;
  76198. /**
  76199. * Sets whether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76200. */
  76201. set hdrAutoExposure(value: boolean);
  76202. /**
  76203. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76204. */
  76205. lensColorTexture: Nullable<Texture>;
  76206. /**
  76207. * The overall strengh for the lens flare effect
  76208. */
  76209. lensFlareStrength: number;
  76210. /**
  76211. * Dispersion coefficient for lens flare ghosts
  76212. */
  76213. lensFlareGhostDispersal: number;
  76214. /**
  76215. * Main lens flare halo width
  76216. */
  76217. lensFlareHaloWidth: number;
  76218. /**
  76219. * Based on the lens distortion effect, defines how much the lens flare result
  76220. * is distorted
  76221. */
  76222. lensFlareDistortionStrength: number;
  76223. /**
  76224. * Configures the blur intensity used for for lens flare (halo)
  76225. */
  76226. lensFlareBlurWidth: number;
  76227. /**
  76228. * Lens star texture must be used to simulate rays on the flares and is available
  76229. * in the documentation
  76230. */
  76231. lensStarTexture: Nullable<Texture>;
  76232. /**
  76233. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76234. * flare effect by taking account of the dirt texture
  76235. */
  76236. lensFlareDirtTexture: Nullable<Texture>;
  76237. /**
  76238. * Represents the focal length for the depth of field effect
  76239. */
  76240. depthOfFieldDistance: number;
  76241. /**
  76242. * Represents the blur intensity for the blurred part of the depth of field effect
  76243. */
  76244. depthOfFieldBlurWidth: number;
  76245. /**
  76246. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76247. */
  76248. get motionStrength(): number;
  76249. /**
  76250. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76251. */
  76252. set motionStrength(strength: number);
  76253. /**
  76254. * Gets whether or not the motion blur post-process is object based or screen based.
  76255. */
  76256. get objectBasedMotionBlur(): boolean;
  76257. /**
  76258. * Sets whether or not the motion blur post-process should be object based or screen based
  76259. */
  76260. set objectBasedMotionBlur(value: boolean);
  76261. /**
  76262. * List of animations for the pipeline (IAnimatable implementation)
  76263. */
  76264. animations: Animation[];
  76265. /**
  76266. * Private members
  76267. */
  76268. private _scene;
  76269. private _currentDepthOfFieldSource;
  76270. private _basePostProcess;
  76271. private _fixedExposure;
  76272. private _currentExposure;
  76273. private _hdrAutoExposure;
  76274. private _hdrCurrentLuminance;
  76275. private _motionStrength;
  76276. private _isObjectBasedMotionBlur;
  76277. private _floatTextureType;
  76278. private _camerasToBeAttached;
  76279. private _ratio;
  76280. private _bloomEnabled;
  76281. private _depthOfFieldEnabled;
  76282. private _vlsEnabled;
  76283. private _lensFlareEnabled;
  76284. private _hdrEnabled;
  76285. private _motionBlurEnabled;
  76286. private _fxaaEnabled;
  76287. private _screenSpaceReflectionsEnabled;
  76288. private _motionBlurSamples;
  76289. private _volumetricLightStepsCount;
  76290. private _samples;
  76291. /**
  76292. * @ignore
  76293. * Specifies if the bloom pipeline is enabled
  76294. */
  76295. get BloomEnabled(): boolean;
  76296. set BloomEnabled(enabled: boolean);
  76297. /**
  76298. * @ignore
  76299. * Specifies if the depth of field pipeline is enabled
  76300. */
  76301. get DepthOfFieldEnabled(): boolean;
  76302. set DepthOfFieldEnabled(enabled: boolean);
  76303. /**
  76304. * @ignore
  76305. * Specifies if the lens flare pipeline is enabled
  76306. */
  76307. get LensFlareEnabled(): boolean;
  76308. set LensFlareEnabled(enabled: boolean);
  76309. /**
  76310. * @ignore
  76311. * Specifies if the HDR pipeline is enabled
  76312. */
  76313. get HDREnabled(): boolean;
  76314. set HDREnabled(enabled: boolean);
  76315. /**
  76316. * @ignore
  76317. * Specifies if the volumetric lights scattering effect is enabled
  76318. */
  76319. get VLSEnabled(): boolean;
  76320. set VLSEnabled(enabled: boolean);
  76321. /**
  76322. * @ignore
  76323. * Specifies if the motion blur effect is enabled
  76324. */
  76325. get MotionBlurEnabled(): boolean;
  76326. set MotionBlurEnabled(enabled: boolean);
  76327. /**
  76328. * Specifies if anti-aliasing is enabled
  76329. */
  76330. get fxaaEnabled(): boolean;
  76331. set fxaaEnabled(enabled: boolean);
  76332. /**
  76333. * Specifies if screen space reflections are enabled.
  76334. */
  76335. get screenSpaceReflectionsEnabled(): boolean;
  76336. set screenSpaceReflectionsEnabled(enabled: boolean);
  76337. /**
  76338. * Specifies the number of steps used to calculate the volumetric lights
  76339. * Typically in interval [50, 200]
  76340. */
  76341. get volumetricLightStepsCount(): number;
  76342. set volumetricLightStepsCount(count: number);
  76343. /**
  76344. * Specifies the number of samples used for the motion blur effect
  76345. * Typically in interval [16, 64]
  76346. */
  76347. get motionBlurSamples(): number;
  76348. set motionBlurSamples(samples: number);
  76349. /**
  76350. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76351. */
  76352. get samples(): number;
  76353. set samples(sampleCount: number);
  76354. /**
  76355. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76356. * @constructor
  76357. * @param name The rendering pipeline name
  76358. * @param scene The scene linked to this pipeline
  76359. * @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)
  76360. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76361. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76362. */
  76363. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76364. private _buildPipeline;
  76365. private _createDownSampleX4PostProcess;
  76366. private _createBrightPassPostProcess;
  76367. private _createBlurPostProcesses;
  76368. private _createTextureAdderPostProcess;
  76369. private _createVolumetricLightPostProcess;
  76370. private _createLuminancePostProcesses;
  76371. private _createHdrPostProcess;
  76372. private _createLensFlarePostProcess;
  76373. private _createDepthOfFieldPostProcess;
  76374. private _createMotionBlurPostProcess;
  76375. private _getDepthTexture;
  76376. private _disposePostProcesses;
  76377. /**
  76378. * Dispose of the pipeline and stop all post processes
  76379. */
  76380. dispose(): void;
  76381. /**
  76382. * Serialize the rendering pipeline (Used when exporting)
  76383. * @returns the serialized object
  76384. */
  76385. serialize(): any;
  76386. /**
  76387. * Parse the serialized pipeline
  76388. * @param source Source pipeline.
  76389. * @param scene The scene to load the pipeline to.
  76390. * @param rootUrl The URL of the serialized pipeline.
  76391. * @returns An instantiated pipeline from the serialized object.
  76392. */
  76393. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76394. /**
  76395. * Luminance steps
  76396. */
  76397. static LuminanceSteps: number;
  76398. }
  76399. }
  76400. declare module BABYLON {
  76401. /** @hidden */
  76402. export var tonemapPixelShader: {
  76403. name: string;
  76404. shader: string;
  76405. };
  76406. }
  76407. declare module BABYLON {
  76408. /** Defines operator used for tonemapping */
  76409. export enum TonemappingOperator {
  76410. /** Hable */
  76411. Hable = 0,
  76412. /** Reinhard */
  76413. Reinhard = 1,
  76414. /** HejiDawson */
  76415. HejiDawson = 2,
  76416. /** Photographic */
  76417. Photographic = 3
  76418. }
  76419. /**
  76420. * Defines a post process to apply tone mapping
  76421. */
  76422. export class TonemapPostProcess extends PostProcess {
  76423. private _operator;
  76424. /** Defines the required exposure adjustment */
  76425. exposureAdjustment: number;
  76426. /**
  76427. * Gets a string identifying the name of the class
  76428. * @returns "TonemapPostProcess" string
  76429. */
  76430. getClassName(): string;
  76431. /**
  76432. * Creates a new TonemapPostProcess
  76433. * @param name defines the name of the postprocess
  76434. * @param _operator defines the operator to use
  76435. * @param exposureAdjustment defines the required exposure adjustement
  76436. * @param camera defines the camera to use (can be null)
  76437. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76438. * @param engine defines the hosting engine (can be ignore if camera is set)
  76439. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76440. */
  76441. constructor(name: string, _operator: TonemappingOperator,
  76442. /** Defines the required exposure adjustment */
  76443. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76444. }
  76445. }
  76446. declare module BABYLON {
  76447. /** @hidden */
  76448. export var volumetricLightScatteringPixelShader: {
  76449. name: string;
  76450. shader: string;
  76451. };
  76452. }
  76453. declare module BABYLON {
  76454. /** @hidden */
  76455. export var volumetricLightScatteringPassVertexShader: {
  76456. name: string;
  76457. shader: string;
  76458. };
  76459. }
  76460. declare module BABYLON {
  76461. /** @hidden */
  76462. export var volumetricLightScatteringPassPixelShader: {
  76463. name: string;
  76464. shader: string;
  76465. };
  76466. }
  76467. declare module BABYLON {
  76468. /**
  76469. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76470. */
  76471. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76472. private _volumetricLightScatteringPass;
  76473. private _volumetricLightScatteringRTT;
  76474. private _viewPort;
  76475. private _screenCoordinates;
  76476. private _cachedDefines;
  76477. /**
  76478. * If not undefined, the mesh position is computed from the attached node position
  76479. */
  76480. attachedNode: {
  76481. position: Vector3;
  76482. };
  76483. /**
  76484. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76485. */
  76486. customMeshPosition: Vector3;
  76487. /**
  76488. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76489. */
  76490. useCustomMeshPosition: boolean;
  76491. /**
  76492. * If the post-process should inverse the light scattering direction
  76493. */
  76494. invert: boolean;
  76495. /**
  76496. * The internal mesh used by the post-process
  76497. */
  76498. mesh: Mesh;
  76499. /**
  76500. * @hidden
  76501. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76502. */
  76503. get useDiffuseColor(): boolean;
  76504. set useDiffuseColor(useDiffuseColor: boolean);
  76505. /**
  76506. * Array containing the excluded meshes not rendered in the internal pass
  76507. */
  76508. excludedMeshes: AbstractMesh[];
  76509. /**
  76510. * Controls the overall intensity of the post-process
  76511. */
  76512. exposure: number;
  76513. /**
  76514. * Dissipates each sample's contribution in range [0, 1]
  76515. */
  76516. decay: number;
  76517. /**
  76518. * Controls the overall intensity of each sample
  76519. */
  76520. weight: number;
  76521. /**
  76522. * Controls the density of each sample
  76523. */
  76524. density: number;
  76525. /**
  76526. * @constructor
  76527. * @param name The post-process name
  76528. * @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)
  76529. * @param camera The camera that the post-process will be attached to
  76530. * @param mesh The mesh used to create the light scattering
  76531. * @param samples The post-process quality, default 100
  76532. * @param samplingModeThe post-process filtering mode
  76533. * @param engine The babylon engine
  76534. * @param reusable If the post-process is reusable
  76535. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76536. */
  76537. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76538. /**
  76539. * Returns the string "VolumetricLightScatteringPostProcess"
  76540. * @returns "VolumetricLightScatteringPostProcess"
  76541. */
  76542. getClassName(): string;
  76543. private _isReady;
  76544. /**
  76545. * Sets the new light position for light scattering effect
  76546. * @param position The new custom light position
  76547. */
  76548. setCustomMeshPosition(position: Vector3): void;
  76549. /**
  76550. * Returns the light position for light scattering effect
  76551. * @return Vector3 The custom light position
  76552. */
  76553. getCustomMeshPosition(): Vector3;
  76554. /**
  76555. * Disposes the internal assets and detaches the post-process from the camera
  76556. */
  76557. dispose(camera: Camera): void;
  76558. /**
  76559. * Returns the render target texture used by the post-process
  76560. * @return the render target texture used by the post-process
  76561. */
  76562. getPass(): RenderTargetTexture;
  76563. private _meshExcluded;
  76564. private _createPass;
  76565. private _updateMeshScreenCoordinates;
  76566. /**
  76567. * Creates a default mesh for the Volumeric Light Scattering post-process
  76568. * @param name The mesh name
  76569. * @param scene The scene where to create the mesh
  76570. * @return the default mesh
  76571. */
  76572. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76573. }
  76574. }
  76575. declare module BABYLON {
  76576. /** @hidden */
  76577. export var screenSpaceCurvaturePixelShader: {
  76578. name: string;
  76579. shader: string;
  76580. };
  76581. }
  76582. declare module BABYLON {
  76583. /**
  76584. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76585. */
  76586. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76587. /**
  76588. * Defines how much ridge the curvature effect displays.
  76589. */
  76590. ridge: number;
  76591. /**
  76592. * Defines how much valley the curvature effect displays.
  76593. */
  76594. valley: number;
  76595. private _geometryBufferRenderer;
  76596. /**
  76597. * Gets a string identifying the name of the class
  76598. * @returns "ScreenSpaceCurvaturePostProcess" string
  76599. */
  76600. getClassName(): string;
  76601. /**
  76602. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76603. * @param name The name of the effect.
  76604. * @param scene The scene containing the objects to blur according to their velocity.
  76605. * @param options The required width/height ratio to downsize to before computing the render pass.
  76606. * @param camera The camera to apply the render pass to.
  76607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76608. * @param engine The engine which the post process will be applied. (default: current engine)
  76609. * @param reusable If the post process can be reused on the same frame. (default: false)
  76610. * @param textureType Type of textures used when performing the post process. (default: 0)
  76611. * @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)
  76612. */
  76613. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76614. /**
  76615. * Support test.
  76616. */
  76617. static get IsSupported(): boolean;
  76618. /** @hidden */
  76619. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76620. }
  76621. }
  76622. declare module BABYLON {
  76623. interface Scene {
  76624. /** @hidden (Backing field) */
  76625. _boundingBoxRenderer: BoundingBoxRenderer;
  76626. /** @hidden (Backing field) */
  76627. _forceShowBoundingBoxes: boolean;
  76628. /**
  76629. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76630. */
  76631. forceShowBoundingBoxes: boolean;
  76632. /**
  76633. * Gets the bounding box renderer associated with the scene
  76634. * @returns a BoundingBoxRenderer
  76635. */
  76636. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76637. }
  76638. interface AbstractMesh {
  76639. /** @hidden (Backing field) */
  76640. _showBoundingBox: boolean;
  76641. /**
  76642. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76643. */
  76644. showBoundingBox: boolean;
  76645. }
  76646. /**
  76647. * Component responsible of rendering the bounding box of the meshes in a scene.
  76648. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76649. */
  76650. export class BoundingBoxRenderer implements ISceneComponent {
  76651. /**
  76652. * The component name helpful to identify the component in the list of scene components.
  76653. */
  76654. readonly name: string;
  76655. /**
  76656. * The scene the component belongs to.
  76657. */
  76658. scene: Scene;
  76659. /**
  76660. * Color of the bounding box lines placed in front of an object
  76661. */
  76662. frontColor: Color3;
  76663. /**
  76664. * Color of the bounding box lines placed behind an object
  76665. */
  76666. backColor: Color3;
  76667. /**
  76668. * Defines if the renderer should show the back lines or not
  76669. */
  76670. showBackLines: boolean;
  76671. /**
  76672. * Observable raised before rendering a bounding box
  76673. */
  76674. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76675. /**
  76676. * Observable raised after rendering a bounding box
  76677. */
  76678. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76679. /**
  76680. * Observable raised after resources are created
  76681. */
  76682. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76683. /**
  76684. * When false, no bounding boxes will be rendered
  76685. */
  76686. enabled: boolean;
  76687. /**
  76688. * @hidden
  76689. */
  76690. renderList: SmartArray<BoundingBox>;
  76691. private _colorShader;
  76692. private _vertexBuffers;
  76693. private _indexBuffer;
  76694. private _fillIndexBuffer;
  76695. private _fillIndexData;
  76696. /**
  76697. * Instantiates a new bounding box renderer in a scene.
  76698. * @param scene the scene the renderer renders in
  76699. */
  76700. constructor(scene: Scene);
  76701. /**
  76702. * Registers the component in a given scene
  76703. */
  76704. register(): void;
  76705. private _evaluateSubMesh;
  76706. private _preActiveMesh;
  76707. private _prepareResources;
  76708. private _createIndexBuffer;
  76709. /**
  76710. * Rebuilds the elements related to this component in case of
  76711. * context lost for instance.
  76712. */
  76713. rebuild(): void;
  76714. /**
  76715. * @hidden
  76716. */
  76717. reset(): void;
  76718. /**
  76719. * Render the bounding boxes of a specific rendering group
  76720. * @param renderingGroupId defines the rendering group to render
  76721. */
  76722. render(renderingGroupId: number): void;
  76723. /**
  76724. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76725. * @param mesh Define the mesh to render the occlusion bounding box for
  76726. */
  76727. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76728. /**
  76729. * Dispose and release the resources attached to this renderer.
  76730. */
  76731. dispose(): void;
  76732. }
  76733. }
  76734. declare module BABYLON {
  76735. interface Scene {
  76736. /** @hidden (Backing field) */
  76737. _depthRenderer: {
  76738. [id: string]: DepthRenderer;
  76739. };
  76740. /**
  76741. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76742. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76743. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76744. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76745. * @returns the created depth renderer
  76746. */
  76747. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76748. /**
  76749. * Disables a depth renderer for a given camera
  76750. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76751. */
  76752. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76753. }
  76754. /**
  76755. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76756. * in several rendering techniques.
  76757. */
  76758. export class DepthRendererSceneComponent implements ISceneComponent {
  76759. /**
  76760. * The component name helpful to identify the component in the list of scene components.
  76761. */
  76762. readonly name: string;
  76763. /**
  76764. * The scene the component belongs to.
  76765. */
  76766. scene: Scene;
  76767. /**
  76768. * Creates a new instance of the component for the given scene
  76769. * @param scene Defines the scene to register the component in
  76770. */
  76771. constructor(scene: Scene);
  76772. /**
  76773. * Registers the component in a given scene
  76774. */
  76775. register(): void;
  76776. /**
  76777. * Rebuilds the elements related to this component in case of
  76778. * context lost for instance.
  76779. */
  76780. rebuild(): void;
  76781. /**
  76782. * Disposes the component and the associated resources
  76783. */
  76784. dispose(): void;
  76785. private _gatherRenderTargets;
  76786. private _gatherActiveCameraRenderTargets;
  76787. }
  76788. }
  76789. declare module BABYLON {
  76790. interface AbstractScene {
  76791. /** @hidden (Backing field) */
  76792. _prePassRenderer: Nullable<PrePassRenderer>;
  76793. /**
  76794. * Gets or Sets the current prepass renderer associated to the scene.
  76795. */
  76796. prePassRenderer: Nullable<PrePassRenderer>;
  76797. /**
  76798. * Enables the prepass and associates it with the scene
  76799. * @returns the PrePassRenderer
  76800. */
  76801. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76802. /**
  76803. * Disables the prepass associated with the scene
  76804. */
  76805. disablePrePassRenderer(): void;
  76806. }
  76807. interface RenderTargetTexture {
  76808. /** @hidden */
  76809. _prePassRenderTarget: PrePassRenderTarget;
  76810. }
  76811. /**
  76812. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76813. * in several rendering techniques.
  76814. */
  76815. export class PrePassRendererSceneComponent implements ISceneComponent {
  76816. /**
  76817. * The component name helpful to identify the component in the list of scene components.
  76818. */
  76819. readonly name: string;
  76820. /**
  76821. * The scene the component belongs to.
  76822. */
  76823. scene: Scene;
  76824. /**
  76825. * Creates a new instance of the component for the given scene
  76826. * @param scene Defines the scene to register the component in
  76827. */
  76828. constructor(scene: Scene);
  76829. /**
  76830. * Registers the component in a given scene
  76831. */
  76832. register(): void;
  76833. private _beforeRenderTargetDraw;
  76834. private _afterRenderTargetDraw;
  76835. private _beforeRenderTargetClearStage;
  76836. private _beforeCameraDraw;
  76837. private _afterCameraDraw;
  76838. private _beforeClearStage;
  76839. private _beforeRenderingMeshStage;
  76840. private _afterRenderingMeshStage;
  76841. /**
  76842. * Rebuilds the elements related to this component in case of
  76843. * context lost for instance.
  76844. */
  76845. rebuild(): void;
  76846. /**
  76847. * Disposes the component and the associated resources
  76848. */
  76849. dispose(): void;
  76850. }
  76851. }
  76852. declare module BABYLON {
  76853. /** @hidden */
  76854. export var fibonacci: {
  76855. name: string;
  76856. shader: string;
  76857. };
  76858. }
  76859. declare module BABYLON {
  76860. /** @hidden */
  76861. export var diffusionProfile: {
  76862. name: string;
  76863. shader: string;
  76864. };
  76865. }
  76866. declare module BABYLON {
  76867. /** @hidden */
  76868. export var subSurfaceScatteringPixelShader: {
  76869. name: string;
  76870. shader: string;
  76871. };
  76872. }
  76873. declare module BABYLON {
  76874. /**
  76875. * Sub surface scattering post process
  76876. */
  76877. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76878. /**
  76879. * Gets a string identifying the name of the class
  76880. * @returns "SubSurfaceScatteringPostProcess" string
  76881. */
  76882. getClassName(): string;
  76883. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76884. }
  76885. }
  76886. declare module BABYLON {
  76887. /**
  76888. * Contains all parameters needed for the prepass to perform
  76889. * screen space subsurface scattering
  76890. */
  76891. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76892. /** @hidden */
  76893. static _SceneComponentInitialization: (scene: Scene) => void;
  76894. private _ssDiffusionS;
  76895. private _ssFilterRadii;
  76896. private _ssDiffusionD;
  76897. /**
  76898. * Post process to attach for screen space subsurface scattering
  76899. */
  76900. postProcess: SubSurfaceScatteringPostProcess;
  76901. /**
  76902. * Diffusion profile color for subsurface scattering
  76903. */
  76904. get ssDiffusionS(): number[];
  76905. /**
  76906. * Diffusion profile max color channel value for subsurface scattering
  76907. */
  76908. get ssDiffusionD(): number[];
  76909. /**
  76910. * Diffusion profile filter radius for subsurface scattering
  76911. */
  76912. get ssFilterRadii(): number[];
  76913. /**
  76914. * Is subsurface enabled
  76915. */
  76916. enabled: boolean;
  76917. /**
  76918. * Does the output of this prepass need to go through imageprocessing
  76919. */
  76920. needsImageProcessing: boolean;
  76921. /**
  76922. * Name of the configuration
  76923. */
  76924. name: string;
  76925. /**
  76926. * Diffusion profile colors for subsurface scattering
  76927. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76928. * See ...
  76929. * Note that you can only store up to 5 of them
  76930. */
  76931. ssDiffusionProfileColors: Color3[];
  76932. /**
  76933. * Defines the ratio real world => scene units.
  76934. * Used for subsurface scattering
  76935. */
  76936. metersPerUnit: number;
  76937. /**
  76938. * Textures that should be present in the MRT for this effect to work
  76939. */
  76940. readonly texturesRequired: number[];
  76941. private _scene;
  76942. /**
  76943. * Builds a subsurface configuration object
  76944. * @param scene The scene
  76945. */
  76946. constructor(scene: Scene);
  76947. /**
  76948. * Adds a new diffusion profile.
  76949. * Useful for more realistic subsurface scattering on diverse materials.
  76950. * @param color The color of the diffusion profile. Should be the average color of the material.
  76951. * @return The index of the diffusion profile for the material subsurface configuration
  76952. */
  76953. addDiffusionProfile(color: Color3): number;
  76954. /**
  76955. * Creates the sss post process
  76956. * @return The created post process
  76957. */
  76958. createPostProcess(): SubSurfaceScatteringPostProcess;
  76959. /**
  76960. * Deletes all diffusion profiles.
  76961. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76962. */
  76963. clearAllDiffusionProfiles(): void;
  76964. /**
  76965. * Disposes this object
  76966. */
  76967. dispose(): void;
  76968. /**
  76969. * @hidden
  76970. * https://zero-radiance.github.io/post/sampling-diffusion/
  76971. *
  76972. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76973. * ------------------------------------------------------------------------------------
  76974. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76975. * PDF[r, phi, s] = r * R[r, phi, s]
  76976. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76977. * ------------------------------------------------------------------------------------
  76978. * We importance sample the color channel with the widest scattering distance.
  76979. */
  76980. getDiffusionProfileParameters(color: Color3): number;
  76981. /**
  76982. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76983. * 'u' is the random number (the value of the CDF): [0, 1).
  76984. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76985. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76986. */
  76987. private _sampleBurleyDiffusionProfile;
  76988. }
  76989. }
  76990. declare module BABYLON {
  76991. interface AbstractScene {
  76992. /** @hidden (Backing field) */
  76993. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76994. /**
  76995. * Gets or Sets the current prepass renderer associated to the scene.
  76996. */
  76997. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76998. /**
  76999. * Enables the subsurface effect for prepass
  77000. * @returns the SubSurfaceConfiguration
  77001. */
  77002. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77003. /**
  77004. * Disables the subsurface effect for prepass
  77005. */
  77006. disableSubSurfaceForPrePass(): void;
  77007. }
  77008. /**
  77009. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77010. * in several rendering techniques.
  77011. */
  77012. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77013. /**
  77014. * The component name helpful to identify the component in the list of scene components.
  77015. */
  77016. readonly name: string;
  77017. /**
  77018. * The scene the component belongs to.
  77019. */
  77020. scene: Scene;
  77021. /**
  77022. * Creates a new instance of the component for the given scene
  77023. * @param scene Defines the scene to register the component in
  77024. */
  77025. constructor(scene: Scene);
  77026. /**
  77027. * Registers the component in a given scene
  77028. */
  77029. register(): void;
  77030. /**
  77031. * Serializes the component data to the specified json object
  77032. * @param serializationObject The object to serialize to
  77033. */
  77034. serialize(serializationObject: any): void;
  77035. /**
  77036. * Adds all the elements from the container to the scene
  77037. * @param container the container holding the elements
  77038. */
  77039. addFromContainer(container: AbstractScene): void;
  77040. /**
  77041. * Removes all the elements in the container from the scene
  77042. * @param container contains the elements to remove
  77043. * @param dispose if the removed element should be disposed (default: false)
  77044. */
  77045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77046. /**
  77047. * Rebuilds the elements related to this component in case of
  77048. * context lost for instance.
  77049. */
  77050. rebuild(): void;
  77051. /**
  77052. * Disposes the component and the associated resources
  77053. */
  77054. dispose(): void;
  77055. }
  77056. }
  77057. declare module BABYLON {
  77058. /** @hidden */
  77059. export var outlinePixelShader: {
  77060. name: string;
  77061. shader: string;
  77062. };
  77063. }
  77064. declare module BABYLON {
  77065. /** @hidden */
  77066. export var outlineVertexShader: {
  77067. name: string;
  77068. shader: string;
  77069. };
  77070. }
  77071. declare module BABYLON {
  77072. interface Scene {
  77073. /** @hidden */
  77074. _outlineRenderer: OutlineRenderer;
  77075. /**
  77076. * Gets the outline renderer associated with the scene
  77077. * @returns a OutlineRenderer
  77078. */
  77079. getOutlineRenderer(): OutlineRenderer;
  77080. }
  77081. interface AbstractMesh {
  77082. /** @hidden (Backing field) */
  77083. _renderOutline: boolean;
  77084. /**
  77085. * Gets or sets a boolean indicating if the outline must be rendered as well
  77086. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77087. */
  77088. renderOutline: boolean;
  77089. /** @hidden (Backing field) */
  77090. _renderOverlay: boolean;
  77091. /**
  77092. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77093. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77094. */
  77095. renderOverlay: boolean;
  77096. }
  77097. /**
  77098. * This class is responsible to draw the outline/overlay of meshes.
  77099. * It should not be used directly but through the available method on mesh.
  77100. */
  77101. export class OutlineRenderer implements ISceneComponent {
  77102. /**
  77103. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77104. */
  77105. private static _StencilReference;
  77106. /**
  77107. * The name of the component. Each component must have a unique name.
  77108. */
  77109. name: string;
  77110. /**
  77111. * The scene the component belongs to.
  77112. */
  77113. scene: Scene;
  77114. /**
  77115. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77116. */
  77117. zOffset: number;
  77118. private _engine;
  77119. private _effect;
  77120. private _cachedDefines;
  77121. private _savedDepthWrite;
  77122. /**
  77123. * Instantiates a new outline renderer. (There could be only one per scene).
  77124. * @param scene Defines the scene it belongs to
  77125. */
  77126. constructor(scene: Scene);
  77127. /**
  77128. * Register the component to one instance of a scene.
  77129. */
  77130. register(): void;
  77131. /**
  77132. * Rebuilds the elements related to this component in case of
  77133. * context lost for instance.
  77134. */
  77135. rebuild(): void;
  77136. /**
  77137. * Disposes the component and the associated resources.
  77138. */
  77139. dispose(): void;
  77140. /**
  77141. * Renders the outline in the canvas.
  77142. * @param subMesh Defines the sumesh to render
  77143. * @param batch Defines the batch of meshes in case of instances
  77144. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77145. */
  77146. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77147. /**
  77148. * Returns whether or not the outline renderer is ready for a given submesh.
  77149. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77150. * @param subMesh Defines the submesh to check readiness for
  77151. * @param useInstances Defines whether wee are trying to render instances or not
  77152. * @returns true if ready otherwise false
  77153. */
  77154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77155. private _beforeRenderingMesh;
  77156. private _afterRenderingMesh;
  77157. }
  77158. }
  77159. declare module BABYLON {
  77160. /**
  77161. * Defines the basic options interface of a Sprite Frame Source Size.
  77162. */
  77163. export interface ISpriteJSONSpriteSourceSize {
  77164. /**
  77165. * number of the original width of the Frame
  77166. */
  77167. w: number;
  77168. /**
  77169. * number of the original height of the Frame
  77170. */
  77171. h: number;
  77172. }
  77173. /**
  77174. * Defines the basic options interface of a Sprite Frame Data.
  77175. */
  77176. export interface ISpriteJSONSpriteFrameData {
  77177. /**
  77178. * number of the x offset of the Frame
  77179. */
  77180. x: number;
  77181. /**
  77182. * number of the y offset of the Frame
  77183. */
  77184. y: number;
  77185. /**
  77186. * number of the width of the Frame
  77187. */
  77188. w: number;
  77189. /**
  77190. * number of the height of the Frame
  77191. */
  77192. h: number;
  77193. }
  77194. /**
  77195. * Defines the basic options interface of a JSON Sprite.
  77196. */
  77197. export interface ISpriteJSONSprite {
  77198. /**
  77199. * string name of the Frame
  77200. */
  77201. filename: string;
  77202. /**
  77203. * ISpriteJSONSpriteFrame basic object of the frame data
  77204. */
  77205. frame: ISpriteJSONSpriteFrameData;
  77206. /**
  77207. * boolean to flag is the frame was rotated.
  77208. */
  77209. rotated: boolean;
  77210. /**
  77211. * boolean to flag is the frame was trimmed.
  77212. */
  77213. trimmed: boolean;
  77214. /**
  77215. * ISpriteJSONSpriteFrame basic object of the source data
  77216. */
  77217. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77218. /**
  77219. * ISpriteJSONSpriteFrame basic object of the source data
  77220. */
  77221. sourceSize: ISpriteJSONSpriteSourceSize;
  77222. }
  77223. /**
  77224. * Defines the basic options interface of a JSON atlas.
  77225. */
  77226. export interface ISpriteJSONAtlas {
  77227. /**
  77228. * Array of objects that contain the frame data.
  77229. */
  77230. frames: Array<ISpriteJSONSprite>;
  77231. /**
  77232. * object basic object containing the sprite meta data.
  77233. */
  77234. meta?: object;
  77235. }
  77236. }
  77237. declare module BABYLON {
  77238. /** @hidden */
  77239. export var spriteMapPixelShader: {
  77240. name: string;
  77241. shader: string;
  77242. };
  77243. }
  77244. declare module BABYLON {
  77245. /** @hidden */
  77246. export var spriteMapVertexShader: {
  77247. name: string;
  77248. shader: string;
  77249. };
  77250. }
  77251. declare module BABYLON {
  77252. /**
  77253. * Defines the basic options interface of a SpriteMap
  77254. */
  77255. export interface ISpriteMapOptions {
  77256. /**
  77257. * Vector2 of the number of cells in the grid.
  77258. */
  77259. stageSize?: Vector2;
  77260. /**
  77261. * Vector2 of the size of the output plane in World Units.
  77262. */
  77263. outputSize?: Vector2;
  77264. /**
  77265. * Vector3 of the position of the output plane in World Units.
  77266. */
  77267. outputPosition?: Vector3;
  77268. /**
  77269. * Vector3 of the rotation of the output plane.
  77270. */
  77271. outputRotation?: Vector3;
  77272. /**
  77273. * number of layers that the system will reserve in resources.
  77274. */
  77275. layerCount?: number;
  77276. /**
  77277. * number of max animation frames a single cell will reserve in resources.
  77278. */
  77279. maxAnimationFrames?: number;
  77280. /**
  77281. * number cell index of the base tile when the system compiles.
  77282. */
  77283. baseTile?: number;
  77284. /**
  77285. * boolean flip the sprite after its been repositioned by the framing data.
  77286. */
  77287. flipU?: boolean;
  77288. /**
  77289. * Vector3 scalar of the global RGB values of the SpriteMap.
  77290. */
  77291. colorMultiply?: Vector3;
  77292. }
  77293. /**
  77294. * Defines the IDisposable interface in order to be cleanable from resources.
  77295. */
  77296. export interface ISpriteMap extends IDisposable {
  77297. /**
  77298. * String name of the SpriteMap.
  77299. */
  77300. name: string;
  77301. /**
  77302. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77303. */
  77304. atlasJSON: ISpriteJSONAtlas;
  77305. /**
  77306. * Texture of the SpriteMap.
  77307. */
  77308. spriteSheet: Texture;
  77309. /**
  77310. * The parameters to initialize the SpriteMap with.
  77311. */
  77312. options: ISpriteMapOptions;
  77313. }
  77314. /**
  77315. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77316. */
  77317. export class SpriteMap implements ISpriteMap {
  77318. /** The Name of the spriteMap */
  77319. name: string;
  77320. /** The JSON file with the frame and meta data */
  77321. atlasJSON: ISpriteJSONAtlas;
  77322. /** The systems Sprite Sheet Texture */
  77323. spriteSheet: Texture;
  77324. /** Arguments passed with the Constructor */
  77325. options: ISpriteMapOptions;
  77326. /** Public Sprite Storage array, parsed from atlasJSON */
  77327. sprites: Array<ISpriteJSONSprite>;
  77328. /** Returns the Number of Sprites in the System */
  77329. get spriteCount(): number;
  77330. /** Returns the Position of Output Plane*/
  77331. get position(): Vector3;
  77332. /** Returns the Position of Output Plane*/
  77333. set position(v: Vector3);
  77334. /** Returns the Rotation of Output Plane*/
  77335. get rotation(): Vector3;
  77336. /** Returns the Rotation of Output Plane*/
  77337. set rotation(v: Vector3);
  77338. /** Sets the AnimationMap*/
  77339. get animationMap(): RawTexture;
  77340. /** Sets the AnimationMap*/
  77341. set animationMap(v: RawTexture);
  77342. /** Scene that the SpriteMap was created in */
  77343. private _scene;
  77344. /** Texture Buffer of Float32 that holds tile frame data*/
  77345. private _frameMap;
  77346. /** Texture Buffers of Float32 that holds tileMap data*/
  77347. private _tileMaps;
  77348. /** Texture Buffer of Float32 that holds Animation Data*/
  77349. private _animationMap;
  77350. /** Custom ShaderMaterial Central to the System*/
  77351. private _material;
  77352. /** Custom ShaderMaterial Central to the System*/
  77353. private _output;
  77354. /** Systems Time Ticker*/
  77355. private _time;
  77356. /**
  77357. * Creates a new SpriteMap
  77358. * @param name defines the SpriteMaps Name
  77359. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77360. * @param spriteSheet is the Texture that the Sprites are on.
  77361. * @param options a basic deployment configuration
  77362. * @param scene The Scene that the map is deployed on
  77363. */
  77364. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77365. /**
  77366. * Returns tileID location
  77367. * @returns Vector2 the cell position ID
  77368. */
  77369. getTileID(): Vector2;
  77370. /**
  77371. * Gets the UV location of the mouse over the SpriteMap.
  77372. * @returns Vector2 the UV position of the mouse interaction
  77373. */
  77374. getMousePosition(): Vector2;
  77375. /**
  77376. * Creates the "frame" texture Buffer
  77377. * -------------------------------------
  77378. * Structure of frames
  77379. * "filename": "Falling-Water-2.png",
  77380. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77381. * "rotated": true,
  77382. * "trimmed": true,
  77383. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77384. * "sourceSize": {"w":32,"h":32}
  77385. * @returns RawTexture of the frameMap
  77386. */
  77387. private _createFrameBuffer;
  77388. /**
  77389. * Creates the tileMap texture Buffer
  77390. * @param buffer normally and array of numbers, or a false to generate from scratch
  77391. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77392. * @returns RawTexture of the tileMap
  77393. */
  77394. private _createTileBuffer;
  77395. /**
  77396. * Modifies the data of the tileMaps
  77397. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77398. * @param pos is the iVector2 Coordinates of the Tile
  77399. * @param tile The SpriteIndex of the new Tile
  77400. */
  77401. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77402. /**
  77403. * Creates the animationMap texture Buffer
  77404. * @param buffer normally and array of numbers, or a false to generate from scratch
  77405. * @returns RawTexture of the animationMap
  77406. */
  77407. private _createTileAnimationBuffer;
  77408. /**
  77409. * Modifies the data of the animationMap
  77410. * @param cellID is the Index of the Sprite
  77411. * @param _frame is the target Animation frame
  77412. * @param toCell is the Target Index of the next frame of the animation
  77413. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77414. * @param speed is a global scalar of the time variable on the map.
  77415. */
  77416. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77417. /**
  77418. * Exports the .tilemaps file
  77419. */
  77420. saveTileMaps(): void;
  77421. /**
  77422. * Imports the .tilemaps file
  77423. * @param url of the .tilemaps file
  77424. */
  77425. loadTileMaps(url: string): void;
  77426. /**
  77427. * Release associated resources
  77428. */
  77429. dispose(): void;
  77430. }
  77431. }
  77432. declare module BABYLON {
  77433. /**
  77434. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77435. * @see https://doc.babylonjs.com/babylon101/sprites
  77436. */
  77437. export class SpritePackedManager extends SpriteManager {
  77438. /** defines the packed manager's name */
  77439. name: string;
  77440. /**
  77441. * Creates a new sprite manager from a packed sprite sheet
  77442. * @param name defines the manager's name
  77443. * @param imgUrl defines the sprite sheet url
  77444. * @param capacity defines the maximum allowed number of sprites
  77445. * @param scene defines the hosting scene
  77446. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77447. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77448. * @param samplingMode defines the sampling mode to use with spritesheet
  77449. * @param fromPacked set to true; do not alter
  77450. */
  77451. constructor(
  77452. /** defines the packed manager's name */
  77453. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77454. }
  77455. }
  77456. declare module BABYLON {
  77457. /**
  77458. * Defines the list of states available for a task inside a AssetsManager
  77459. */
  77460. export enum AssetTaskState {
  77461. /**
  77462. * Initialization
  77463. */
  77464. INIT = 0,
  77465. /**
  77466. * Running
  77467. */
  77468. RUNNING = 1,
  77469. /**
  77470. * Done
  77471. */
  77472. DONE = 2,
  77473. /**
  77474. * Error
  77475. */
  77476. ERROR = 3
  77477. }
  77478. /**
  77479. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77480. */
  77481. export abstract class AbstractAssetTask {
  77482. /**
  77483. * Task name
  77484. */ name: string;
  77485. /**
  77486. * Callback called when the task is successful
  77487. */
  77488. onSuccess: (task: any) => void;
  77489. /**
  77490. * Callback called when the task is not successful
  77491. */
  77492. onError: (task: any, message?: string, exception?: any) => void;
  77493. /**
  77494. * Creates a new AssetsManager
  77495. * @param name defines the name of the task
  77496. */
  77497. constructor(
  77498. /**
  77499. * Task name
  77500. */ name: string);
  77501. private _isCompleted;
  77502. private _taskState;
  77503. private _errorObject;
  77504. /**
  77505. * Get if the task is completed
  77506. */
  77507. get isCompleted(): boolean;
  77508. /**
  77509. * Gets the current state of the task
  77510. */
  77511. get taskState(): AssetTaskState;
  77512. /**
  77513. * Gets the current error object (if task is in error)
  77514. */
  77515. get errorObject(): {
  77516. message?: string;
  77517. exception?: any;
  77518. };
  77519. /**
  77520. * Internal only
  77521. * @hidden
  77522. */
  77523. _setErrorObject(message?: string, exception?: any): void;
  77524. /**
  77525. * Execute the current task
  77526. * @param scene defines the scene where you want your assets to be loaded
  77527. * @param onSuccess is a callback called when the task is successfully executed
  77528. * @param onError is a callback called if an error occurs
  77529. */
  77530. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77531. /**
  77532. * Execute the current task
  77533. * @param scene defines the scene where you want your assets to be loaded
  77534. * @param onSuccess is a callback called when the task is successfully executed
  77535. * @param onError is a callback called if an error occurs
  77536. */
  77537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77538. /**
  77539. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77540. * This can be used with failed tasks that have the reason for failure fixed.
  77541. */
  77542. reset(): void;
  77543. private onErrorCallback;
  77544. private onDoneCallback;
  77545. }
  77546. /**
  77547. * Define the interface used by progress events raised during assets loading
  77548. */
  77549. export interface IAssetsProgressEvent {
  77550. /**
  77551. * Defines the number of remaining tasks to process
  77552. */
  77553. remainingCount: number;
  77554. /**
  77555. * Defines the total number of tasks
  77556. */
  77557. totalCount: number;
  77558. /**
  77559. * Defines the task that was just processed
  77560. */
  77561. task: AbstractAssetTask;
  77562. }
  77563. /**
  77564. * Class used to share progress information about assets loading
  77565. */
  77566. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77567. /**
  77568. * Defines the number of remaining tasks to process
  77569. */
  77570. remainingCount: number;
  77571. /**
  77572. * Defines the total number of tasks
  77573. */
  77574. totalCount: number;
  77575. /**
  77576. * Defines the task that was just processed
  77577. */
  77578. task: AbstractAssetTask;
  77579. /**
  77580. * Creates a AssetsProgressEvent
  77581. * @param remainingCount defines the number of remaining tasks to process
  77582. * @param totalCount defines the total number of tasks
  77583. * @param task defines the task that was just processed
  77584. */
  77585. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77586. }
  77587. /**
  77588. * Define a task used by AssetsManager to load assets into a container
  77589. */
  77590. export class ContainerAssetTask extends AbstractAssetTask {
  77591. /**
  77592. * Defines the name of the task
  77593. */
  77594. name: string;
  77595. /**
  77596. * Defines the list of mesh's names you want to load
  77597. */
  77598. meshesNames: any;
  77599. /**
  77600. * Defines the root url to use as a base to load your meshes and associated resources
  77601. */
  77602. rootUrl: string;
  77603. /**
  77604. * Defines the filename or File of the scene to load from
  77605. */
  77606. sceneFilename: string | File;
  77607. /**
  77608. * Get the loaded asset container
  77609. */
  77610. loadedContainer: AssetContainer;
  77611. /**
  77612. * Gets the list of loaded meshes
  77613. */
  77614. loadedMeshes: Array<AbstractMesh>;
  77615. /**
  77616. * Gets the list of loaded particle systems
  77617. */
  77618. loadedParticleSystems: Array<IParticleSystem>;
  77619. /**
  77620. * Gets the list of loaded skeletons
  77621. */
  77622. loadedSkeletons: Array<Skeleton>;
  77623. /**
  77624. * Gets the list of loaded animation groups
  77625. */
  77626. loadedAnimationGroups: Array<AnimationGroup>;
  77627. /**
  77628. * Callback called when the task is successful
  77629. */
  77630. onSuccess: (task: ContainerAssetTask) => void;
  77631. /**
  77632. * Callback called when the task is successful
  77633. */
  77634. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77635. /**
  77636. * Creates a new ContainerAssetTask
  77637. * @param name defines the name of the task
  77638. * @param meshesNames defines the list of mesh's names you want to load
  77639. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77640. * @param sceneFilename defines the filename or File of the scene to load from
  77641. */
  77642. constructor(
  77643. /**
  77644. * Defines the name of the task
  77645. */
  77646. name: string,
  77647. /**
  77648. * Defines the list of mesh's names you want to load
  77649. */
  77650. meshesNames: any,
  77651. /**
  77652. * Defines the root url to use as a base to load your meshes and associated resources
  77653. */
  77654. rootUrl: string,
  77655. /**
  77656. * Defines the filename or File of the scene to load from
  77657. */
  77658. sceneFilename: string | File);
  77659. /**
  77660. * Execute the current task
  77661. * @param scene defines the scene where you want your assets to be loaded
  77662. * @param onSuccess is a callback called when the task is successfully executed
  77663. * @param onError is a callback called if an error occurs
  77664. */
  77665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77666. }
  77667. /**
  77668. * Define a task used by AssetsManager to load meshes
  77669. */
  77670. export class MeshAssetTask extends AbstractAssetTask {
  77671. /**
  77672. * Defines the name of the task
  77673. */
  77674. name: string;
  77675. /**
  77676. * Defines the list of mesh's names you want to load
  77677. */
  77678. meshesNames: any;
  77679. /**
  77680. * Defines the root url to use as a base to load your meshes and associated resources
  77681. */
  77682. rootUrl: string;
  77683. /**
  77684. * Defines the filename or File of the scene to load from
  77685. */
  77686. sceneFilename: string | File;
  77687. /**
  77688. * Gets the list of loaded meshes
  77689. */
  77690. loadedMeshes: Array<AbstractMesh>;
  77691. /**
  77692. * Gets the list of loaded particle systems
  77693. */
  77694. loadedParticleSystems: Array<IParticleSystem>;
  77695. /**
  77696. * Gets the list of loaded skeletons
  77697. */
  77698. loadedSkeletons: Array<Skeleton>;
  77699. /**
  77700. * Gets the list of loaded animation groups
  77701. */
  77702. loadedAnimationGroups: Array<AnimationGroup>;
  77703. /**
  77704. * Callback called when the task is successful
  77705. */
  77706. onSuccess: (task: MeshAssetTask) => void;
  77707. /**
  77708. * Callback called when the task is successful
  77709. */
  77710. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77711. /**
  77712. * Creates a new MeshAssetTask
  77713. * @param name defines the name of the task
  77714. * @param meshesNames defines the list of mesh's names you want to load
  77715. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77716. * @param sceneFilename defines the filename or File of the scene to load from
  77717. */
  77718. constructor(
  77719. /**
  77720. * Defines the name of the task
  77721. */
  77722. name: string,
  77723. /**
  77724. * Defines the list of mesh's names you want to load
  77725. */
  77726. meshesNames: any,
  77727. /**
  77728. * Defines the root url to use as a base to load your meshes and associated resources
  77729. */
  77730. rootUrl: string,
  77731. /**
  77732. * Defines the filename or File of the scene to load from
  77733. */
  77734. sceneFilename: string | File);
  77735. /**
  77736. * Execute the current task
  77737. * @param scene defines the scene where you want your assets to be loaded
  77738. * @param onSuccess is a callback called when the task is successfully executed
  77739. * @param onError is a callback called if an error occurs
  77740. */
  77741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77742. }
  77743. /**
  77744. * Define a task used by AssetsManager to load text content
  77745. */
  77746. export class TextFileAssetTask extends AbstractAssetTask {
  77747. /**
  77748. * Defines the name of the task
  77749. */
  77750. name: string;
  77751. /**
  77752. * Defines the location of the file to load
  77753. */
  77754. url: string;
  77755. /**
  77756. * Gets the loaded text string
  77757. */
  77758. text: string;
  77759. /**
  77760. * Callback called when the task is successful
  77761. */
  77762. onSuccess: (task: TextFileAssetTask) => void;
  77763. /**
  77764. * Callback called when the task is successful
  77765. */
  77766. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77767. /**
  77768. * Creates a new TextFileAssetTask object
  77769. * @param name defines the name of the task
  77770. * @param url defines the location of the file to load
  77771. */
  77772. constructor(
  77773. /**
  77774. * Defines the name of the task
  77775. */
  77776. name: string,
  77777. /**
  77778. * Defines the location of the file to load
  77779. */
  77780. url: string);
  77781. /**
  77782. * Execute the current task
  77783. * @param scene defines the scene where you want your assets to be loaded
  77784. * @param onSuccess is a callback called when the task is successfully executed
  77785. * @param onError is a callback called if an error occurs
  77786. */
  77787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77788. }
  77789. /**
  77790. * Define a task used by AssetsManager to load binary data
  77791. */
  77792. export class BinaryFileAssetTask extends AbstractAssetTask {
  77793. /**
  77794. * Defines the name of the task
  77795. */
  77796. name: string;
  77797. /**
  77798. * Defines the location of the file to load
  77799. */
  77800. url: string;
  77801. /**
  77802. * Gets the lodaded data (as an array buffer)
  77803. */
  77804. data: ArrayBuffer;
  77805. /**
  77806. * Callback called when the task is successful
  77807. */
  77808. onSuccess: (task: BinaryFileAssetTask) => void;
  77809. /**
  77810. * Callback called when the task is successful
  77811. */
  77812. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77813. /**
  77814. * Creates a new BinaryFileAssetTask object
  77815. * @param name defines the name of the new task
  77816. * @param url defines the location of the file to load
  77817. */
  77818. constructor(
  77819. /**
  77820. * Defines the name of the task
  77821. */
  77822. name: string,
  77823. /**
  77824. * Defines the location of the file to load
  77825. */
  77826. url: string);
  77827. /**
  77828. * Execute the current task
  77829. * @param scene defines the scene where you want your assets to be loaded
  77830. * @param onSuccess is a callback called when the task is successfully executed
  77831. * @param onError is a callback called if an error occurs
  77832. */
  77833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77834. }
  77835. /**
  77836. * Define a task used by AssetsManager to load images
  77837. */
  77838. export class ImageAssetTask extends AbstractAssetTask {
  77839. /**
  77840. * Defines the name of the task
  77841. */
  77842. name: string;
  77843. /**
  77844. * Defines the location of the image to load
  77845. */
  77846. url: string;
  77847. /**
  77848. * Gets the loaded images
  77849. */
  77850. image: HTMLImageElement;
  77851. /**
  77852. * Callback called when the task is successful
  77853. */
  77854. onSuccess: (task: ImageAssetTask) => void;
  77855. /**
  77856. * Callback called when the task is successful
  77857. */
  77858. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77859. /**
  77860. * Creates a new ImageAssetTask
  77861. * @param name defines the name of the task
  77862. * @param url defines the location of the image to load
  77863. */
  77864. constructor(
  77865. /**
  77866. * Defines the name of the task
  77867. */
  77868. name: string,
  77869. /**
  77870. * Defines the location of the image to load
  77871. */
  77872. url: string);
  77873. /**
  77874. * Execute the current task
  77875. * @param scene defines the scene where you want your assets to be loaded
  77876. * @param onSuccess is a callback called when the task is successfully executed
  77877. * @param onError is a callback called if an error occurs
  77878. */
  77879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77880. }
  77881. /**
  77882. * Defines the interface used by texture loading tasks
  77883. */
  77884. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77885. /**
  77886. * Gets the loaded texture
  77887. */
  77888. texture: TEX;
  77889. }
  77890. /**
  77891. * Define a task used by AssetsManager to load 2D textures
  77892. */
  77893. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77894. /**
  77895. * Defines the name of the task
  77896. */
  77897. name: string;
  77898. /**
  77899. * Defines the location of the file to load
  77900. */
  77901. url: string;
  77902. /**
  77903. * Defines if mipmap should not be generated (default is false)
  77904. */
  77905. noMipmap?: boolean | undefined;
  77906. /**
  77907. * Defines if texture must be inverted on Y axis (default is true)
  77908. */
  77909. invertY: boolean;
  77910. /**
  77911. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77912. */
  77913. samplingMode: number;
  77914. /**
  77915. * Gets the loaded texture
  77916. */
  77917. texture: Texture;
  77918. /**
  77919. * Callback called when the task is successful
  77920. */
  77921. onSuccess: (task: TextureAssetTask) => void;
  77922. /**
  77923. * Callback called when the task is successful
  77924. */
  77925. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77926. /**
  77927. * Creates a new TextureAssetTask object
  77928. * @param name defines the name of the task
  77929. * @param url defines the location of the file to load
  77930. * @param noMipmap defines if mipmap should not be generated (default is false)
  77931. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77932. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77933. */
  77934. constructor(
  77935. /**
  77936. * Defines the name of the task
  77937. */
  77938. name: string,
  77939. /**
  77940. * Defines the location of the file to load
  77941. */
  77942. url: string,
  77943. /**
  77944. * Defines if mipmap should not be generated (default is false)
  77945. */
  77946. noMipmap?: boolean | undefined,
  77947. /**
  77948. * Defines if texture must be inverted on Y axis (default is true)
  77949. */
  77950. invertY?: boolean,
  77951. /**
  77952. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77953. */
  77954. samplingMode?: number);
  77955. /**
  77956. * Execute the current task
  77957. * @param scene defines the scene where you want your assets to be loaded
  77958. * @param onSuccess is a callback called when the task is successfully executed
  77959. * @param onError is a callback called if an error occurs
  77960. */
  77961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77962. }
  77963. /**
  77964. * Define a task used by AssetsManager to load cube textures
  77965. */
  77966. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77967. /**
  77968. * Defines the name of the task
  77969. */
  77970. name: string;
  77971. /**
  77972. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77973. */
  77974. url: string;
  77975. /**
  77976. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77977. */
  77978. extensions?: string[] | undefined;
  77979. /**
  77980. * Defines if mipmaps should not be generated (default is false)
  77981. */
  77982. noMipmap?: boolean | undefined;
  77983. /**
  77984. * Defines the explicit list of files (undefined by default)
  77985. */
  77986. files?: string[] | undefined;
  77987. /**
  77988. * Gets the loaded texture
  77989. */
  77990. texture: CubeTexture;
  77991. /**
  77992. * Callback called when the task is successful
  77993. */
  77994. onSuccess: (task: CubeTextureAssetTask) => void;
  77995. /**
  77996. * Callback called when the task is successful
  77997. */
  77998. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77999. /**
  78000. * Creates a new CubeTextureAssetTask
  78001. * @param name defines the name of the task
  78002. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78003. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78004. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78005. * @param files defines the explicit list of files (undefined by default)
  78006. */
  78007. constructor(
  78008. /**
  78009. * Defines the name of the task
  78010. */
  78011. name: string,
  78012. /**
  78013. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78014. */
  78015. url: string,
  78016. /**
  78017. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78018. */
  78019. extensions?: string[] | undefined,
  78020. /**
  78021. * Defines if mipmaps should not be generated (default is false)
  78022. */
  78023. noMipmap?: boolean | undefined,
  78024. /**
  78025. * Defines the explicit list of files (undefined by default)
  78026. */
  78027. files?: string[] | undefined);
  78028. /**
  78029. * Execute the current task
  78030. * @param scene defines the scene where you want your assets to be loaded
  78031. * @param onSuccess is a callback called when the task is successfully executed
  78032. * @param onError is a callback called if an error occurs
  78033. */
  78034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78035. }
  78036. /**
  78037. * Define a task used by AssetsManager to load HDR cube textures
  78038. */
  78039. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78040. /**
  78041. * Defines the name of the task
  78042. */
  78043. name: string;
  78044. /**
  78045. * Defines the location of the file to load
  78046. */
  78047. url: string;
  78048. /**
  78049. * Defines the desired size (the more it increases the longer the generation will be)
  78050. */
  78051. size: number;
  78052. /**
  78053. * Defines if mipmaps should not be generated (default is false)
  78054. */
  78055. noMipmap: boolean;
  78056. /**
  78057. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78058. */
  78059. generateHarmonics: boolean;
  78060. /**
  78061. * 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)
  78062. */
  78063. gammaSpace: boolean;
  78064. /**
  78065. * Internal Use Only
  78066. */
  78067. reserved: boolean;
  78068. /**
  78069. * Gets the loaded texture
  78070. */
  78071. texture: HDRCubeTexture;
  78072. /**
  78073. * Callback called when the task is successful
  78074. */
  78075. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78076. /**
  78077. * Callback called when the task is successful
  78078. */
  78079. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78080. /**
  78081. * Creates a new HDRCubeTextureAssetTask object
  78082. * @param name defines the name of the task
  78083. * @param url defines the location of the file to load
  78084. * @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.
  78085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78086. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78087. * @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)
  78088. * @param reserved Internal use only
  78089. */
  78090. constructor(
  78091. /**
  78092. * Defines the name of the task
  78093. */
  78094. name: string,
  78095. /**
  78096. * Defines the location of the file to load
  78097. */
  78098. url: string,
  78099. /**
  78100. * Defines the desired size (the more it increases the longer the generation will be)
  78101. */
  78102. size: number,
  78103. /**
  78104. * Defines if mipmaps should not be generated (default is false)
  78105. */
  78106. noMipmap?: boolean,
  78107. /**
  78108. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78109. */
  78110. generateHarmonics?: boolean,
  78111. /**
  78112. * 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)
  78113. */
  78114. gammaSpace?: boolean,
  78115. /**
  78116. * Internal Use Only
  78117. */
  78118. reserved?: boolean);
  78119. /**
  78120. * Execute the current task
  78121. * @param scene defines the scene where you want your assets to be loaded
  78122. * @param onSuccess is a callback called when the task is successfully executed
  78123. * @param onError is a callback called if an error occurs
  78124. */
  78125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78126. }
  78127. /**
  78128. * Define a task used by AssetsManager to load Equirectangular cube textures
  78129. */
  78130. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78131. /**
  78132. * Defines the name of the task
  78133. */
  78134. name: string;
  78135. /**
  78136. * Defines the location of the file to load
  78137. */
  78138. url: string;
  78139. /**
  78140. * Defines the desired size (the more it increases the longer the generation will be)
  78141. */
  78142. size: number;
  78143. /**
  78144. * Defines if mipmaps should not be generated (default is false)
  78145. */
  78146. noMipmap: boolean;
  78147. /**
  78148. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78149. * but the standard material would require them in Gamma space) (default is true)
  78150. */
  78151. gammaSpace: boolean;
  78152. /**
  78153. * Gets the loaded texture
  78154. */
  78155. texture: EquiRectangularCubeTexture;
  78156. /**
  78157. * Callback called when the task is successful
  78158. */
  78159. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78160. /**
  78161. * Callback called when the task is successful
  78162. */
  78163. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78164. /**
  78165. * Creates a new EquiRectangularCubeTextureAssetTask object
  78166. * @param name defines the name of the task
  78167. * @param url defines the location of the file to load
  78168. * @param size defines the desired size (the more it increases the longer the generation will be)
  78169. * If the size is omitted this implies you are using a preprocessed cubemap.
  78170. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78171. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78172. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78173. * (default is true)
  78174. */
  78175. constructor(
  78176. /**
  78177. * Defines the name of the task
  78178. */
  78179. name: string,
  78180. /**
  78181. * Defines the location of the file to load
  78182. */
  78183. url: string,
  78184. /**
  78185. * Defines the desired size (the more it increases the longer the generation will be)
  78186. */
  78187. size: number,
  78188. /**
  78189. * Defines if mipmaps should not be generated (default is false)
  78190. */
  78191. noMipmap?: boolean,
  78192. /**
  78193. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78194. * but the standard material would require them in Gamma space) (default is true)
  78195. */
  78196. gammaSpace?: boolean);
  78197. /**
  78198. * Execute the current task
  78199. * @param scene defines the scene where you want your assets to be loaded
  78200. * @param onSuccess is a callback called when the task is successfully executed
  78201. * @param onError is a callback called if an error occurs
  78202. */
  78203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78204. }
  78205. /**
  78206. * This class can be used to easily import assets into a scene
  78207. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78208. */
  78209. export class AssetsManager {
  78210. private _scene;
  78211. private _isLoading;
  78212. protected _tasks: AbstractAssetTask[];
  78213. protected _waitingTasksCount: number;
  78214. protected _totalTasksCount: number;
  78215. /**
  78216. * Callback called when all tasks are processed
  78217. */
  78218. onFinish: (tasks: AbstractAssetTask[]) => void;
  78219. /**
  78220. * Callback called when a task is successful
  78221. */
  78222. onTaskSuccess: (task: AbstractAssetTask) => void;
  78223. /**
  78224. * Callback called when a task had an error
  78225. */
  78226. onTaskError: (task: AbstractAssetTask) => void;
  78227. /**
  78228. * Callback called when a task is done (whatever the result is)
  78229. */
  78230. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78231. /**
  78232. * Observable called when all tasks are processed
  78233. */
  78234. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78235. /**
  78236. * Observable called when a task had an error
  78237. */
  78238. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78239. /**
  78240. * Observable called when all tasks were executed
  78241. */
  78242. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78243. /**
  78244. * Observable called when a task is done (whatever the result is)
  78245. */
  78246. onProgressObservable: Observable<IAssetsProgressEvent>;
  78247. /**
  78248. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78249. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78250. */
  78251. useDefaultLoadingScreen: boolean;
  78252. /**
  78253. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78254. * when all assets have been downloaded.
  78255. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78256. */
  78257. autoHideLoadingUI: boolean;
  78258. /**
  78259. * Creates a new AssetsManager
  78260. * @param scene defines the scene to work on
  78261. */
  78262. constructor(scene: Scene);
  78263. /**
  78264. * Add a ContainerAssetTask to the list of active tasks
  78265. * @param taskName defines the name of the new task
  78266. * @param meshesNames defines the name of meshes to load
  78267. * @param rootUrl defines the root url to use to locate files
  78268. * @param sceneFilename defines the filename of the scene file
  78269. * @returns a new ContainerAssetTask object
  78270. */
  78271. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78272. /**
  78273. * Add a MeshAssetTask to the list of active tasks
  78274. * @param taskName defines the name of the new task
  78275. * @param meshesNames defines the name of meshes to load
  78276. * @param rootUrl defines the root url to use to locate files
  78277. * @param sceneFilename defines the filename of the scene file
  78278. * @returns a new MeshAssetTask object
  78279. */
  78280. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78281. /**
  78282. * Add a TextFileAssetTask to the list of active tasks
  78283. * @param taskName defines the name of the new task
  78284. * @param url defines the url of the file to load
  78285. * @returns a new TextFileAssetTask object
  78286. */
  78287. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78288. /**
  78289. * Add a BinaryFileAssetTask to the list of active tasks
  78290. * @param taskName defines the name of the new task
  78291. * @param url defines the url of the file to load
  78292. * @returns a new BinaryFileAssetTask object
  78293. */
  78294. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78295. /**
  78296. * Add a ImageAssetTask to the list of active tasks
  78297. * @param taskName defines the name of the new task
  78298. * @param url defines the url of the file to load
  78299. * @returns a new ImageAssetTask object
  78300. */
  78301. addImageTask(taskName: string, url: string): ImageAssetTask;
  78302. /**
  78303. * Add a TextureAssetTask to the list of active tasks
  78304. * @param taskName defines the name of the new task
  78305. * @param url defines the url of the file to load
  78306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78307. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78308. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78309. * @returns a new TextureAssetTask object
  78310. */
  78311. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78312. /**
  78313. * Add a CubeTextureAssetTask to the list of active tasks
  78314. * @param taskName defines the name of the new task
  78315. * @param url defines the url of the file to load
  78316. * @param extensions defines the extension to use to load the cube map (can be null)
  78317. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78318. * @param files defines the list of files to load (can be null)
  78319. * @returns a new CubeTextureAssetTask object
  78320. */
  78321. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78322. /**
  78323. *
  78324. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78325. * @param taskName defines the name of the new task
  78326. * @param url defines the url of the file to load
  78327. * @param size defines the size you want for the cubemap (can be null)
  78328. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78329. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78330. * @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)
  78331. * @param reserved Internal use only
  78332. * @returns a new HDRCubeTextureAssetTask object
  78333. */
  78334. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78335. /**
  78336. *
  78337. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78338. * @param taskName defines the name of the new task
  78339. * @param url defines the url of the file to load
  78340. * @param size defines the size you want for the cubemap (can be null)
  78341. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78342. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78343. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78344. * @returns a new EquiRectangularCubeTextureAssetTask object
  78345. */
  78346. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78347. /**
  78348. * Remove a task from the assets manager.
  78349. * @param task the task to remove
  78350. */
  78351. removeTask(task: AbstractAssetTask): void;
  78352. private _decreaseWaitingTasksCount;
  78353. private _runTask;
  78354. /**
  78355. * Reset the AssetsManager and remove all tasks
  78356. * @return the current instance of the AssetsManager
  78357. */
  78358. reset(): AssetsManager;
  78359. /**
  78360. * Start the loading process
  78361. * @return the current instance of the AssetsManager
  78362. */
  78363. load(): AssetsManager;
  78364. /**
  78365. * Start the loading process as an async operation
  78366. * @return a promise returning the list of failed tasks
  78367. */
  78368. loadAsync(): Promise<void>;
  78369. }
  78370. }
  78371. declare module BABYLON {
  78372. /**
  78373. * Wrapper class for promise with external resolve and reject.
  78374. */
  78375. export class Deferred<T> {
  78376. /**
  78377. * The promise associated with this deferred object.
  78378. */
  78379. readonly promise: Promise<T>;
  78380. private _resolve;
  78381. private _reject;
  78382. /**
  78383. * The resolve method of the promise associated with this deferred object.
  78384. */
  78385. get resolve(): (value: T | PromiseLike<T>) => void;
  78386. /**
  78387. * The reject method of the promise associated with this deferred object.
  78388. */
  78389. get reject(): (reason?: any) => void;
  78390. /**
  78391. * Constructor for this deferred object.
  78392. */
  78393. constructor();
  78394. }
  78395. }
  78396. declare module BABYLON {
  78397. /**
  78398. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78399. */
  78400. export class MeshExploder {
  78401. private _centerMesh;
  78402. private _meshes;
  78403. private _meshesOrigins;
  78404. private _toCenterVectors;
  78405. private _scaledDirection;
  78406. private _newPosition;
  78407. private _centerPosition;
  78408. /**
  78409. * Explodes meshes from a center mesh.
  78410. * @param meshes The meshes to explode.
  78411. * @param centerMesh The mesh to be center of explosion.
  78412. */
  78413. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78414. private _setCenterMesh;
  78415. /**
  78416. * Get class name
  78417. * @returns "MeshExploder"
  78418. */
  78419. getClassName(): string;
  78420. /**
  78421. * "Exploded meshes"
  78422. * @returns Array of meshes with the centerMesh at index 0.
  78423. */
  78424. getMeshes(): Array<Mesh>;
  78425. /**
  78426. * Explodes meshes giving a specific direction
  78427. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78428. */
  78429. explode(direction?: number): void;
  78430. }
  78431. }
  78432. declare module BABYLON {
  78433. /**
  78434. * Class used to help managing file picking and drag'n'drop
  78435. */
  78436. export class FilesInput {
  78437. /**
  78438. * List of files ready to be loaded
  78439. */
  78440. static get FilesToLoad(): {
  78441. [key: string]: File;
  78442. };
  78443. /**
  78444. * Callback called when a file is processed
  78445. */
  78446. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  78447. /**
  78448. * Function used when loading the scene file
  78449. */
  78450. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  78451. private _engine;
  78452. private _currentScene;
  78453. private _sceneLoadedCallback;
  78454. private _progressCallback;
  78455. private _additionalRenderLoopLogicCallback;
  78456. private _textureLoadingCallback;
  78457. private _startingProcessingFilesCallback;
  78458. private _onReloadCallback;
  78459. private _errorCallback;
  78460. private _elementToMonitor;
  78461. private _sceneFileToLoad;
  78462. private _filesToLoad;
  78463. /**
  78464. * Creates a new FilesInput
  78465. * @param engine defines the rendering engine
  78466. * @param scene defines the hosting scene
  78467. * @param sceneLoadedCallback callback called when scene is loaded
  78468. * @param progressCallback callback called to track progress
  78469. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78470. * @param textureLoadingCallback callback called when a texture is loading
  78471. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78472. * @param onReloadCallback callback called when a reload is requested
  78473. * @param errorCallback callback call if an error occurs
  78474. */
  78475. 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>);
  78476. private _dragEnterHandler;
  78477. private _dragOverHandler;
  78478. private _dropHandler;
  78479. /**
  78480. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78481. * @param elementToMonitor defines the DOM element to track
  78482. */
  78483. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78484. /** Gets the current list of files to load */
  78485. get filesToLoad(): File[];
  78486. /**
  78487. * Release all associated resources
  78488. */
  78489. dispose(): void;
  78490. private renderFunction;
  78491. private drag;
  78492. private drop;
  78493. private _traverseFolder;
  78494. private _processFiles;
  78495. /**
  78496. * Load files from a drop event
  78497. * @param event defines the drop event to use as source
  78498. */
  78499. loadFiles(event: any): void;
  78500. private _processReload;
  78501. /**
  78502. * Reload the current scene from the loaded files
  78503. */
  78504. reload(): void;
  78505. }
  78506. }
  78507. declare module BABYLON {
  78508. /**
  78509. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78510. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78511. */
  78512. export class SceneOptimization {
  78513. /**
  78514. * Defines the priority of this optimization (0 by default which means first in the list)
  78515. */
  78516. priority: number;
  78517. /**
  78518. * Gets a string describing the action executed by the current optimization
  78519. * @returns description string
  78520. */
  78521. getDescription(): string;
  78522. /**
  78523. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78524. * @param scene defines the current scene where to apply this optimization
  78525. * @param optimizer defines the current optimizer
  78526. * @returns true if everything that can be done was applied
  78527. */
  78528. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78529. /**
  78530. * Creates the SceneOptimization object
  78531. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78532. * @param desc defines the description associated with the optimization
  78533. */
  78534. constructor(
  78535. /**
  78536. * Defines the priority of this optimization (0 by default which means first in the list)
  78537. */
  78538. priority?: number);
  78539. }
  78540. /**
  78541. * Defines an optimization used to reduce the size of render target textures
  78542. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78543. */
  78544. export class TextureOptimization extends SceneOptimization {
  78545. /**
  78546. * Defines the priority of this optimization (0 by default which means first in the list)
  78547. */
  78548. priority: number;
  78549. /**
  78550. * 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
  78551. */
  78552. maximumSize: number;
  78553. /**
  78554. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78555. */
  78556. step: number;
  78557. /**
  78558. * Gets a string describing the action executed by the current optimization
  78559. * @returns description string
  78560. */
  78561. getDescription(): string;
  78562. /**
  78563. * Creates the TextureOptimization object
  78564. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78565. * @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
  78566. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78567. */
  78568. constructor(
  78569. /**
  78570. * Defines the priority of this optimization (0 by default which means first in the list)
  78571. */
  78572. priority?: number,
  78573. /**
  78574. * 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
  78575. */
  78576. maximumSize?: number,
  78577. /**
  78578. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78579. */
  78580. step?: number);
  78581. /**
  78582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78583. * @param scene defines the current scene where to apply this optimization
  78584. * @param optimizer defines the current optimizer
  78585. * @returns true if everything that can be done was applied
  78586. */
  78587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78588. }
  78589. /**
  78590. * Defines an optimization used to increase or decrease the rendering resolution
  78591. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78592. */
  78593. export class HardwareScalingOptimization extends SceneOptimization {
  78594. /**
  78595. * Defines the priority of this optimization (0 by default which means first in the list)
  78596. */
  78597. priority: number;
  78598. /**
  78599. * Defines the maximum scale to use (2 by default)
  78600. */
  78601. maximumScale: number;
  78602. /**
  78603. * Defines the step to use between two passes (0.5 by default)
  78604. */
  78605. step: number;
  78606. private _currentScale;
  78607. private _directionOffset;
  78608. /**
  78609. * Gets a string describing the action executed by the current optimization
  78610. * @return description string
  78611. */
  78612. getDescription(): string;
  78613. /**
  78614. * Creates the HardwareScalingOptimization object
  78615. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78616. * @param maximumScale defines the maximum scale to use (2 by default)
  78617. * @param step defines the step to use between two passes (0.5 by default)
  78618. */
  78619. constructor(
  78620. /**
  78621. * Defines the priority of this optimization (0 by default which means first in the list)
  78622. */
  78623. priority?: number,
  78624. /**
  78625. * Defines the maximum scale to use (2 by default)
  78626. */
  78627. maximumScale?: number,
  78628. /**
  78629. * Defines the step to use between two passes (0.5 by default)
  78630. */
  78631. step?: number);
  78632. /**
  78633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78634. * @param scene defines the current scene where to apply this optimization
  78635. * @param optimizer defines the current optimizer
  78636. * @returns true if everything that can be done was applied
  78637. */
  78638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78639. }
  78640. /**
  78641. * Defines an optimization used to remove shadows
  78642. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78643. */
  78644. export class ShadowsOptimization extends SceneOptimization {
  78645. /**
  78646. * Gets a string describing the action executed by the current optimization
  78647. * @return description string
  78648. */
  78649. getDescription(): string;
  78650. /**
  78651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78652. * @param scene defines the current scene where to apply this optimization
  78653. * @param optimizer defines the current optimizer
  78654. * @returns true if everything that can be done was applied
  78655. */
  78656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78657. }
  78658. /**
  78659. * Defines an optimization used to turn post-processes off
  78660. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78661. */
  78662. export class PostProcessesOptimization extends SceneOptimization {
  78663. /**
  78664. * Gets a string describing the action executed by the current optimization
  78665. * @return description string
  78666. */
  78667. getDescription(): string;
  78668. /**
  78669. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78670. * @param scene defines the current scene where to apply this optimization
  78671. * @param optimizer defines the current optimizer
  78672. * @returns true if everything that can be done was applied
  78673. */
  78674. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78675. }
  78676. /**
  78677. * Defines an optimization used to turn lens flares off
  78678. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78679. */
  78680. export class LensFlaresOptimization extends SceneOptimization {
  78681. /**
  78682. * Gets a string describing the action executed by the current optimization
  78683. * @return description string
  78684. */
  78685. getDescription(): string;
  78686. /**
  78687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78688. * @param scene defines the current scene where to apply this optimization
  78689. * @param optimizer defines the current optimizer
  78690. * @returns true if everything that can be done was applied
  78691. */
  78692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78693. }
  78694. /**
  78695. * Defines an optimization based on user defined callback.
  78696. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78697. */
  78698. export class CustomOptimization extends SceneOptimization {
  78699. /**
  78700. * Callback called to apply the custom optimization.
  78701. */
  78702. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78703. /**
  78704. * Callback called to get custom description
  78705. */
  78706. onGetDescription: () => string;
  78707. /**
  78708. * Gets a string describing the action executed by the current optimization
  78709. * @returns description string
  78710. */
  78711. getDescription(): string;
  78712. /**
  78713. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78714. * @param scene defines the current scene where to apply this optimization
  78715. * @param optimizer defines the current optimizer
  78716. * @returns true if everything that can be done was applied
  78717. */
  78718. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78719. }
  78720. /**
  78721. * Defines an optimization used to turn particles off
  78722. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78723. */
  78724. export class ParticlesOptimization extends SceneOptimization {
  78725. /**
  78726. * Gets a string describing the action executed by the current optimization
  78727. * @return description string
  78728. */
  78729. getDescription(): string;
  78730. /**
  78731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78732. * @param scene defines the current scene where to apply this optimization
  78733. * @param optimizer defines the current optimizer
  78734. * @returns true if everything that can be done was applied
  78735. */
  78736. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78737. }
  78738. /**
  78739. * Defines an optimization used to turn render targets off
  78740. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78741. */
  78742. export class RenderTargetsOptimization extends SceneOptimization {
  78743. /**
  78744. * Gets a string describing the action executed by the current optimization
  78745. * @return description string
  78746. */
  78747. getDescription(): string;
  78748. /**
  78749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78750. * @param scene defines the current scene where to apply this optimization
  78751. * @param optimizer defines the current optimizer
  78752. * @returns true if everything that can be done was applied
  78753. */
  78754. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78755. }
  78756. /**
  78757. * Defines an optimization used to merge meshes with compatible materials
  78758. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78759. */
  78760. export class MergeMeshesOptimization extends SceneOptimization {
  78761. private static _UpdateSelectionTree;
  78762. /**
  78763. * Gets or sets a boolean which defines if optimization octree has to be updated
  78764. */
  78765. static get UpdateSelectionTree(): boolean;
  78766. /**
  78767. * Gets or sets a boolean which defines if optimization octree has to be updated
  78768. */
  78769. static set UpdateSelectionTree(value: boolean);
  78770. /**
  78771. * Gets a string describing the action executed by the current optimization
  78772. * @return description string
  78773. */
  78774. getDescription(): string;
  78775. private _canBeMerged;
  78776. /**
  78777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78778. * @param scene defines the current scene where to apply this optimization
  78779. * @param optimizer defines the current optimizer
  78780. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78781. * @returns true if everything that can be done was applied
  78782. */
  78783. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78784. }
  78785. /**
  78786. * Defines a list of options used by SceneOptimizer
  78787. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78788. */
  78789. export class SceneOptimizerOptions {
  78790. /**
  78791. * Defines the target frame rate to reach (60 by default)
  78792. */
  78793. targetFrameRate: number;
  78794. /**
  78795. * Defines the interval between two checks (2000ms by default)
  78796. */
  78797. trackerDuration: number;
  78798. /**
  78799. * Gets the list of optimizations to apply
  78800. */
  78801. optimizations: SceneOptimization[];
  78802. /**
  78803. * Creates a new list of options used by SceneOptimizer
  78804. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78805. * @param trackerDuration defines the interval between two checks (2000ms by default)
  78806. */
  78807. constructor(
  78808. /**
  78809. * Defines the target frame rate to reach (60 by default)
  78810. */
  78811. targetFrameRate?: number,
  78812. /**
  78813. * Defines the interval between two checks (2000ms by default)
  78814. */
  78815. trackerDuration?: number);
  78816. /**
  78817. * Add a new optimization
  78818. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78819. * @returns the current SceneOptimizerOptions
  78820. */
  78821. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78822. /**
  78823. * Add a new custom optimization
  78824. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78825. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78826. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78827. * @returns the current SceneOptimizerOptions
  78828. */
  78829. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78830. /**
  78831. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78832. * @param targetFrameRate defines the target frame rate (60 by default)
  78833. * @returns a SceneOptimizerOptions object
  78834. */
  78835. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78836. /**
  78837. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78838. * @param targetFrameRate defines the target frame rate (60 by default)
  78839. * @returns a SceneOptimizerOptions object
  78840. */
  78841. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78842. /**
  78843. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78844. * @param targetFrameRate defines the target frame rate (60 by default)
  78845. * @returns a SceneOptimizerOptions object
  78846. */
  78847. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78848. }
  78849. /**
  78850. * Class used to run optimizations in order to reach a target frame rate
  78851. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78852. */
  78853. export class SceneOptimizer implements IDisposable {
  78854. private _isRunning;
  78855. private _options;
  78856. private _scene;
  78857. private _currentPriorityLevel;
  78858. private _targetFrameRate;
  78859. private _trackerDuration;
  78860. private _currentFrameRate;
  78861. private _sceneDisposeObserver;
  78862. private _improvementMode;
  78863. /**
  78864. * Defines an observable called when the optimizer reaches the target frame rate
  78865. */
  78866. onSuccessObservable: Observable<SceneOptimizer>;
  78867. /**
  78868. * Defines an observable called when the optimizer enables an optimization
  78869. */
  78870. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78871. /**
  78872. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78873. */
  78874. onFailureObservable: Observable<SceneOptimizer>;
  78875. /**
  78876. * Gets a boolean indicating if the optimizer is in improvement mode
  78877. */
  78878. get isInImprovementMode(): boolean;
  78879. /**
  78880. * Gets the current priority level (0 at start)
  78881. */
  78882. get currentPriorityLevel(): number;
  78883. /**
  78884. * Gets the current frame rate checked by the SceneOptimizer
  78885. */
  78886. get currentFrameRate(): number;
  78887. /**
  78888. * Gets or sets the current target frame rate (60 by default)
  78889. */
  78890. get targetFrameRate(): number;
  78891. /**
  78892. * Gets or sets the current target frame rate (60 by default)
  78893. */
  78894. set targetFrameRate(value: number);
  78895. /**
  78896. * Gets or sets the current interval between two checks (every 2000ms by default)
  78897. */
  78898. get trackerDuration(): number;
  78899. /**
  78900. * Gets or sets the current interval between two checks (every 2000ms by default)
  78901. */
  78902. set trackerDuration(value: number);
  78903. /**
  78904. * Gets the list of active optimizations
  78905. */
  78906. get optimizations(): SceneOptimization[];
  78907. /**
  78908. * Creates a new SceneOptimizer
  78909. * @param scene defines the scene to work on
  78910. * @param options defines the options to use with the SceneOptimizer
  78911. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78912. * @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)
  78913. */
  78914. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78915. /**
  78916. * Stops the current optimizer
  78917. */
  78918. stop(): void;
  78919. /**
  78920. * Reset the optimizer to initial step (current priority level = 0)
  78921. */
  78922. reset(): void;
  78923. /**
  78924. * Start the optimizer. By default it will try to reach a specific framerate
  78925. * but if the optimizer is set with improvementMode === true then it will run all optimization while frame rate is above the target frame rate
  78926. */
  78927. start(): void;
  78928. private _checkCurrentState;
  78929. /**
  78930. * Release all resources
  78931. */
  78932. dispose(): void;
  78933. /**
  78934. * Helper function to create a SceneOptimizer with one single line of code
  78935. * @param scene defines the scene to work on
  78936. * @param options defines the options to use with the SceneOptimizer
  78937. * @param onSuccess defines a callback to call on success
  78938. * @param onFailure defines a callback to call on failure
  78939. * @returns the new SceneOptimizer object
  78940. */
  78941. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78942. }
  78943. }
  78944. declare module BABYLON {
  78945. /**
  78946. * Class used to serialize a scene into a string
  78947. */
  78948. export class SceneSerializer {
  78949. /**
  78950. * Clear cache used by a previous serialization
  78951. */
  78952. static ClearCache(): void;
  78953. /**
  78954. * Serialize a scene into a JSON compatible object
  78955. * Note that if the current engine does not support synchronous texture reading (like WebGPU), you should use SerializeAsync instead
  78956. * as else you may not retrieve the proper base64 encoded texture data (when using the Texture.ForceSerializeBuffers flag)
  78957. * @param scene defines the scene to serialize
  78958. * @returns a JSON compatible object
  78959. */
  78960. static Serialize(scene: Scene): any;
  78961. private static _Serialize;
  78962. /**
  78963. * Serialize a scene into a JSON compatible object
  78964. * @param scene defines the scene to serialize
  78965. * @returns a JSON promise compatible object
  78966. */
  78967. static SerializeAsync(scene: Scene): Promise<any>;
  78968. private static _CollectPromises;
  78969. /**
  78970. * Serialize a mesh into a JSON compatible object
  78971. * @param toSerialize defines the mesh to serialize
  78972. * @param withParents defines if parents must be serialized as well
  78973. * @param withChildren defines if children must be serialized as well
  78974. * @returns a JSON compatible object
  78975. */
  78976. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78977. }
  78978. }
  78979. declare module BABYLON {
  78980. /**
  78981. * This represents the different options available for the video capture.
  78982. */
  78983. export interface VideoRecorderOptions {
  78984. /** Defines the mime type of the video. */
  78985. mimeType: string;
  78986. /** Defines the FPS the video should be recorded at. */
  78987. fps: number;
  78988. /** Defines the chunk size for the recording data. */
  78989. recordChunckSize: number;
  78990. /** The audio tracks to attach to the recording. */
  78991. audioTracks?: MediaStreamTrack[];
  78992. }
  78993. /**
  78994. * This can help with recording videos from BabylonJS.
  78995. * This is based on the available WebRTC functionalities of the browser.
  78996. *
  78997. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78998. */
  78999. export class VideoRecorder {
  79000. private static readonly _defaultOptions;
  79001. /**
  79002. * Returns whether or not the VideoRecorder is available in your browser.
  79003. * @param engine Defines the Babylon Engine.
  79004. * @returns true if supported otherwise false.
  79005. */
  79006. static IsSupported(engine: Engine): boolean;
  79007. private readonly _options;
  79008. private _canvas;
  79009. private _mediaRecorder;
  79010. private _recordedChunks;
  79011. private _fileName;
  79012. private _resolve;
  79013. private _reject;
  79014. /**
  79015. * True when a recording is already in progress.
  79016. */
  79017. get isRecording(): boolean;
  79018. /**
  79019. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79020. * @param engine Defines the BabylonJS Engine you wish to record.
  79021. * @param options Defines options that can be used to customize the capture.
  79022. */
  79023. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79024. /**
  79025. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79026. */
  79027. stopRecording(): void;
  79028. /**
  79029. * Starts recording the canvas for a max duration specified in parameters.
  79030. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79031. * If null no automatic download will start and you can rely on the promise to get the data back.
  79032. * @param maxDuration Defines the maximum recording time in seconds.
  79033. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79034. * @return A promise callback at the end of the recording with the video data in Blob.
  79035. */
  79036. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79037. /**
  79038. * Releases internal resources used during the recording.
  79039. */
  79040. dispose(): void;
  79041. private _handleDataAvailable;
  79042. private _handleError;
  79043. private _handleStop;
  79044. }
  79045. }
  79046. declare module BABYLON {
  79047. /**
  79048. * Class containing a set of static utilities functions for screenshots
  79049. */
  79050. export class ScreenshotTools {
  79051. /**
  79052. * Captures a screenshot of the current rendering
  79053. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79054. * @param engine defines the rendering engine
  79055. * @param camera defines the source camera
  79056. * @param size This parameter can be set to a single number or to an object with the
  79057. * following (optional) properties: precision, width, height. If a single number is passed,
  79058. * it will be used for both width and height. If an object is passed, the screenshot size
  79059. * will be derived from the parameters. The precision property is a multiplier allowing
  79060. * rendering at a higher or lower resolution
  79061. * @param successCallback defines the callback receives a single parameter which contains the
  79062. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79063. * src parameter of an <img> to display it
  79064. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79065. * Check your browser for supported MIME types
  79066. * @param forceDownload force the system to download the image even if a successCallback is provided
  79067. */
  79068. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  79069. /**
  79070. * Captures a screenshot of the current rendering
  79071. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79072. * @param engine defines the rendering engine
  79073. * @param camera defines the source camera
  79074. * @param size This parameter can be set to a single number or to an object with the
  79075. * following (optional) properties: precision, width, height. If a single number is passed,
  79076. * it will be used for both width and height. If an object is passed, the screenshot size
  79077. * will be derived from the parameters. The precision property is a multiplier allowing
  79078. * rendering at a higher or lower resolution
  79079. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79080. * Check your browser for supported MIME types
  79081. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79082. * to the src parameter of an <img> to display it
  79083. */
  79084. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79085. /**
  79086. * 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)
  79087. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79088. * @param engine defines the rendering engine
  79089. * @param camera defines the source camera
  79090. * @param width defines the expected width
  79091. * @param height defines the expected height
  79092. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79093. * Check your browser for supported MIME types
  79094. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79095. * to the src parameter of an <img> to display it
  79096. */
  79097. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  79098. /**
  79099. * Generates an image screenshot from the specified camera.
  79100. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79101. * @param engine The engine to use for rendering
  79102. * @param camera The camera to use for rendering
  79103. * @param size This parameter can be set to a single number or to an object with the
  79104. * following (optional) properties: precision, width, height. If a single number is passed,
  79105. * it will be used for both width and height. If an object is passed, the screenshot size
  79106. * will be derived from the parameters. The precision property is a multiplier allowing
  79107. * rendering at a higher or lower resolution
  79108. * @param successCallback The callback receives a single parameter which contains the
  79109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79110. * src parameter of an <img> to display it
  79111. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79112. * Check your browser for supported MIME types
  79113. * @param samples Texture samples (default: 1)
  79114. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79115. * @param fileName A name for for the downloaded file.
  79116. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79117. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79118. */
  79119. 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;
  79120. /**
  79121. * Generates an image screenshot from the specified camera.
  79122. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79123. * @param engine The engine to use for rendering
  79124. * @param camera The camera to use for rendering
  79125. * @param size This parameter can be set to a single number or to an object with the
  79126. * following (optional) properties: precision, width, height. If a single number is passed,
  79127. * it will be used for both width and height. If an object is passed, the screenshot size
  79128. * will be derived from the parameters. The precision property is a multiplier allowing
  79129. * rendering at a higher or lower resolution
  79130. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79131. * Check your browser for supported MIME types
  79132. * @param samples Texture samples (default: 1)
  79133. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79134. * @param fileName A name for for the downloaded file.
  79135. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79136. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79137. * to the src parameter of an <img> to display it
  79138. */
  79139. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79140. /**
  79141. * Gets height and width for screenshot size
  79142. * @private
  79143. */
  79144. private static _getScreenshotSize;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. /**
  79149. * Interface for a data buffer
  79150. */
  79151. export interface IDataBuffer {
  79152. /**
  79153. * Reads bytes from the data buffer.
  79154. * @param byteOffset The byte offset to read
  79155. * @param byteLength The byte length to read
  79156. * @returns A promise that resolves when the bytes are read
  79157. */
  79158. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79159. /**
  79160. * The byte length of the buffer.
  79161. */
  79162. readonly byteLength: number;
  79163. }
  79164. /**
  79165. * Utility class for reading from a data buffer
  79166. */
  79167. export class DataReader {
  79168. /**
  79169. * The data buffer associated with this data reader.
  79170. */
  79171. readonly buffer: IDataBuffer;
  79172. /**
  79173. * The current byte offset from the beginning of the data buffer.
  79174. */
  79175. byteOffset: number;
  79176. private _dataView;
  79177. private _dataByteOffset;
  79178. /**
  79179. * Constructor
  79180. * @param buffer The buffer to read
  79181. */
  79182. constructor(buffer: IDataBuffer);
  79183. /**
  79184. * Loads the given byte length.
  79185. * @param byteLength The byte length to load
  79186. * @returns A promise that resolves when the load is complete
  79187. */
  79188. loadAsync(byteLength: number): Promise<void>;
  79189. /**
  79190. * Read a unsigned 32-bit integer from the currently loaded data range.
  79191. * @returns The 32-bit integer read
  79192. */
  79193. readUint32(): number;
  79194. /**
  79195. * Read a byte array from the currently loaded data range.
  79196. * @param byteLength The byte length to read
  79197. * @returns The byte array read
  79198. */
  79199. readUint8Array(byteLength: number): Uint8Array;
  79200. /**
  79201. * Read a string from the currently loaded data range.
  79202. * @param byteLength The byte length to read
  79203. * @returns The string read
  79204. */
  79205. readString(byteLength: number): string;
  79206. /**
  79207. * Skips the given byte length the currently loaded data range.
  79208. * @param byteLength The byte length to skip
  79209. */
  79210. skipBytes(byteLength: number): void;
  79211. }
  79212. }
  79213. declare module BABYLON {
  79214. /**
  79215. * Class for storing data to local storage if available or in-memory storage otherwise
  79216. */
  79217. export class DataStorage {
  79218. private static _Storage;
  79219. private static _GetStorage;
  79220. /**
  79221. * Reads a string from the data storage
  79222. * @param key The key to read
  79223. * @param defaultValue The value if the key doesn't exist
  79224. * @returns The string value
  79225. */
  79226. static ReadString(key: string, defaultValue: string): string;
  79227. /**
  79228. * Writes a string to the data storage
  79229. * @param key The key to write
  79230. * @param value The value to write
  79231. */
  79232. static WriteString(key: string, value: string): void;
  79233. /**
  79234. * Reads a boolean from the data storage
  79235. * @param key The key to read
  79236. * @param defaultValue The value if the key doesn't exist
  79237. * @returns The boolean value
  79238. */
  79239. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79240. /**
  79241. * Writes a boolean to the data storage
  79242. * @param key The key to write
  79243. * @param value The value to write
  79244. */
  79245. static WriteBoolean(key: string, value: boolean): void;
  79246. /**
  79247. * Reads a number from the data storage
  79248. * @param key The key to read
  79249. * @param defaultValue The value if the key doesn't exist
  79250. * @returns The number value
  79251. */
  79252. static ReadNumber(key: string, defaultValue: number): number;
  79253. /**
  79254. * Writes a number to the data storage
  79255. * @param key The key to write
  79256. * @param value The value to write
  79257. */
  79258. static WriteNumber(key: string, value: number): void;
  79259. }
  79260. }
  79261. declare module BABYLON {
  79262. /**
  79263. * Class used to record delta files between 2 scene states
  79264. */
  79265. export class SceneRecorder {
  79266. private _trackedScene;
  79267. private _savedJSON;
  79268. /**
  79269. * Track a given scene. This means the current scene state will be considered the original state
  79270. * @param scene defines the scene to track
  79271. */
  79272. track(scene: Scene): void;
  79273. /**
  79274. * Get the delta between current state and original state
  79275. * @returns a any containing the delta
  79276. */
  79277. getDelta(): any;
  79278. private _compareArray;
  79279. private _compareObjects;
  79280. private _compareCollections;
  79281. private static GetShadowGeneratorById;
  79282. /**
  79283. * Apply a given delta to a given scene
  79284. * @param deltaJSON defines the JSON containing the delta
  79285. * @param scene defines the scene to apply the delta to
  79286. */
  79287. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79288. private static _ApplyPropertiesToEntity;
  79289. private static _ApplyDeltaForEntity;
  79290. }
  79291. }
  79292. declare module BABYLON {
  79293. /**
  79294. * A 3D trajectory consisting of an order list of vectors describing a
  79295. * path of motion through 3D space.
  79296. */
  79297. export class Trajectory {
  79298. private _points;
  79299. private readonly _segmentLength;
  79300. /**
  79301. * Serialize to JSON.
  79302. * @returns serialized JSON string
  79303. */
  79304. serialize(): string;
  79305. /**
  79306. * Deserialize from JSON.
  79307. * @param json serialized JSON string
  79308. * @returns deserialized Trajectory
  79309. */
  79310. static Deserialize(json: string): Trajectory;
  79311. /**
  79312. * Create a new empty Trajectory.
  79313. * @param segmentLength radius of discretization for Trajectory points
  79314. */
  79315. constructor(segmentLength?: number);
  79316. /**
  79317. * Get the length of the Trajectory.
  79318. * @returns length of the Trajectory
  79319. */
  79320. getLength(): number;
  79321. /**
  79322. * Append a new point to the Trajectory.
  79323. * NOTE: This implementation has many allocations.
  79324. * @param point point to append to the Trajectory
  79325. */
  79326. add(point: DeepImmutable<Vector3>): void;
  79327. /**
  79328. * Create a new Trajectory with a segment length chosen to make it
  79329. * probable that the new Trajectory will have a specified number of
  79330. * segments. This operation is imprecise.
  79331. * @param targetResolution number of segments desired
  79332. * @returns new Trajectory with approximately the requested number of segments
  79333. */
  79334. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79335. /**
  79336. * Convert Trajectory segments into tokenized representation. This
  79337. * representation is an array of numbers where each nth number is the
  79338. * index of the token which is most similar to the nth segment of the
  79339. * Trajectory.
  79340. * @param tokens list of vectors which serve as discrete tokens
  79341. * @returns list of indices of most similar token per segment
  79342. */
  79343. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79344. private static _forwardDir;
  79345. private static _inverseFromVec;
  79346. private static _upDir;
  79347. private static _fromToVec;
  79348. private static _lookMatrix;
  79349. /**
  79350. * Transform the rotation (i.e., direction) of a segment to isolate
  79351. * the relative transformation represented by the segment. This operation
  79352. * may or may not succeed due to singularities in the equations that define
  79353. * motion relativity in this context.
  79354. * @param priorVec the origin of the prior segment
  79355. * @param fromVec the origin of the current segment
  79356. * @param toVec the destination of the current segment
  79357. * @param result reference to output variable
  79358. * @returns whether or not transformation was successful
  79359. */
  79360. private static _transformSegmentDirToRef;
  79361. private static _bestMatch;
  79362. private static _score;
  79363. private static _bestScore;
  79364. /**
  79365. * Determine which token vector is most similar to the
  79366. * segment vector.
  79367. * @param segment segment vector
  79368. * @param tokens token vector list
  79369. * @returns index of the most similar token to the segment
  79370. */
  79371. private static _tokenizeSegment;
  79372. }
  79373. /**
  79374. * Class representing a set of known, named trajectories to which Trajectories can be
  79375. * added and using which Trajectories can be recognized.
  79376. */
  79377. export class TrajectoryClassifier {
  79378. private _maximumAllowableMatchCost;
  79379. private _vector3Alphabet;
  79380. private _levenshteinAlphabet;
  79381. private _nameToDescribedTrajectory;
  79382. /**
  79383. * Serialize to JSON.
  79384. * @returns JSON serialization
  79385. */
  79386. serialize(): string;
  79387. /**
  79388. * Deserialize from JSON.
  79389. * @param json JSON serialization
  79390. * @returns deserialized TrajectorySet
  79391. */
  79392. static Deserialize(json: string): TrajectoryClassifier;
  79393. /**
  79394. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79395. * VERY naive, need to be generating these things from known
  79396. * sets. Better version later, probably eliminating this one.
  79397. * @returns auto-generated TrajectorySet
  79398. */
  79399. static Generate(): TrajectoryClassifier;
  79400. private constructor();
  79401. /**
  79402. * Add a new Trajectory to the set with a given name.
  79403. * @param trajectory new Trajectory to be added
  79404. * @param classification name to which to add the Trajectory
  79405. */
  79406. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79407. /**
  79408. * Remove a known named trajectory and all Trajectories associated with it.
  79409. * @param classification name to remove
  79410. * @returns whether anything was removed
  79411. */
  79412. deleteClassification(classification: string): boolean;
  79413. /**
  79414. * Attempt to recognize a Trajectory from among all the classifications
  79415. * already known to the classifier.
  79416. * @param trajectory Trajectory to be recognized
  79417. * @returns classification of Trajectory if recognized, null otherwise
  79418. */
  79419. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79420. }
  79421. }
  79422. declare module BABYLON {
  79423. /**
  79424. * An interface for all Hit test features
  79425. */
  79426. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79427. /**
  79428. * Triggered when new babylon (transformed) hit test results are available
  79429. */
  79430. onHitTestResultObservable: Observable<T[]>;
  79431. }
  79432. /**
  79433. * Options used for hit testing
  79434. */
  79435. export interface IWebXRLegacyHitTestOptions {
  79436. /**
  79437. * Only test when user interacted with the scene. Default - hit test every frame
  79438. */
  79439. testOnPointerDownOnly?: boolean;
  79440. /**
  79441. * The node to use to transform the local results to world coordinates
  79442. */
  79443. worldParentNode?: TransformNode;
  79444. }
  79445. /**
  79446. * Interface defining the babylon result of raycasting/hit-test
  79447. */
  79448. export interface IWebXRLegacyHitResult {
  79449. /**
  79450. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79451. */
  79452. transformationMatrix: Matrix;
  79453. /**
  79454. * The native hit test result
  79455. */
  79456. xrHitResult: XRHitResult | XRHitTestResult;
  79457. }
  79458. /**
  79459. * The currently-working hit-test module.
  79460. * Hit test (or Ray-casting) is used to interact with the real world.
  79461. * For further information read here - https://github.com/immersive-web/hit-test
  79462. */
  79463. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79464. /**
  79465. * options to use when constructing this feature
  79466. */
  79467. readonly options: IWebXRLegacyHitTestOptions;
  79468. private _direction;
  79469. private _mat;
  79470. private _onSelectEnabled;
  79471. private _origin;
  79472. /**
  79473. * The module's name
  79474. */
  79475. static readonly Name: string;
  79476. /**
  79477. * The (Babylon) version of this module.
  79478. * This is an integer representing the implementation version.
  79479. * This number does not correspond to the WebXR specs version
  79480. */
  79481. static readonly Version: number;
  79482. /**
  79483. * Populated with the last native XR Hit Results
  79484. */
  79485. lastNativeXRHitResults: XRHitResult[];
  79486. /**
  79487. * Triggered when new babylon (transformed) hit test results are available
  79488. */
  79489. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79490. /**
  79491. * Creates a new instance of the (legacy version) hit test feature
  79492. * @param _xrSessionManager an instance of WebXRSessionManager
  79493. * @param options options to use when constructing this feature
  79494. */
  79495. constructor(_xrSessionManager: WebXRSessionManager,
  79496. /**
  79497. * options to use when constructing this feature
  79498. */
  79499. options?: IWebXRLegacyHitTestOptions);
  79500. /**
  79501. * execute a hit test with an XR Ray
  79502. *
  79503. * @param xrSession a native xrSession that will execute this hit test
  79504. * @param xrRay the ray (position and direction) to use for ray-casting
  79505. * @param referenceSpace native XR reference space to use for the hit-test
  79506. * @param filter filter function that will filter the results
  79507. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79508. */
  79509. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79510. /**
  79511. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79512. * @param event the (select) event to use to select with
  79513. * @param referenceSpace the reference space to use for this hit test
  79514. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79515. */
  79516. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79517. /**
  79518. * attach this feature
  79519. * Will usually be called by the features manager
  79520. *
  79521. * @returns true if successful.
  79522. */
  79523. attach(): boolean;
  79524. /**
  79525. * detach this feature.
  79526. * Will usually be called by the features manager
  79527. *
  79528. * @returns true if successful.
  79529. */
  79530. detach(): boolean;
  79531. /**
  79532. * Dispose this feature and all of the resources attached
  79533. */
  79534. dispose(): void;
  79535. protected _onXRFrame(frame: XRFrame): void;
  79536. private _onHitTestResults;
  79537. private _onSelect;
  79538. }
  79539. }
  79540. declare module BABYLON {
  79541. /**
  79542. * Options used for hit testing (version 2)
  79543. */
  79544. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79545. /**
  79546. * Do not create a permanent hit test. Will usually be used when only
  79547. * transient inputs are needed.
  79548. */
  79549. disablePermanentHitTest?: boolean;
  79550. /**
  79551. * Enable transient (for example touch-based) hit test inspections
  79552. */
  79553. enableTransientHitTest?: boolean;
  79554. /**
  79555. * Offset ray for the permanent hit test
  79556. */
  79557. offsetRay?: Vector3;
  79558. /**
  79559. * Offset ray for the transient hit test
  79560. */
  79561. transientOffsetRay?: Vector3;
  79562. /**
  79563. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79564. */
  79565. useReferenceSpace?: boolean;
  79566. /**
  79567. * Override the default entity type(s) of the hit-test result
  79568. */
  79569. entityTypes?: XRHitTestTrackableType[];
  79570. }
  79571. /**
  79572. * Interface defining the babylon result of hit-test
  79573. */
  79574. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79575. /**
  79576. * The input source that generated this hit test (if transient)
  79577. */
  79578. inputSource?: XRInputSource;
  79579. /**
  79580. * Is this a transient hit test
  79581. */
  79582. isTransient?: boolean;
  79583. /**
  79584. * Position of the hit test result
  79585. */
  79586. position: Vector3;
  79587. /**
  79588. * Rotation of the hit test result
  79589. */
  79590. rotationQuaternion: Quaternion;
  79591. /**
  79592. * The native hit test result
  79593. */
  79594. xrHitResult: XRHitTestResult;
  79595. }
  79596. /**
  79597. * The currently-working hit-test module.
  79598. * Hit test (or Ray-casting) is used to interact with the real world.
  79599. * For further information read here - https://github.com/immersive-web/hit-test
  79600. *
  79601. * Tested on chrome (mobile) 80.
  79602. */
  79603. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79604. /**
  79605. * options to use when constructing this feature
  79606. */
  79607. readonly options: IWebXRHitTestOptions;
  79608. private _tmpMat;
  79609. private _tmpPos;
  79610. private _tmpQuat;
  79611. private _transientXrHitTestSource;
  79612. private _xrHitTestSource;
  79613. private initHitTestSource;
  79614. /**
  79615. * The module's name
  79616. */
  79617. static readonly Name: string;
  79618. /**
  79619. * The (Babylon) version of this module.
  79620. * This is an integer representing the implementation version.
  79621. * This number does not correspond to the WebXR specs version
  79622. */
  79623. static readonly Version: number;
  79624. /**
  79625. * When set to true, each hit test will have its own position/rotation objects
  79626. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79627. * the developers will clone them or copy them as they see fit.
  79628. */
  79629. autoCloneTransformation: boolean;
  79630. /**
  79631. * Triggered when new babylon (transformed) hit test results are available
  79632. * Note - this will be called when results come back from the device. It can be an empty array!!
  79633. */
  79634. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79635. /**
  79636. * Use this to temporarily pause hit test checks.
  79637. */
  79638. paused: boolean;
  79639. /**
  79640. * Creates a new instance of the hit test feature
  79641. * @param _xrSessionManager an instance of WebXRSessionManager
  79642. * @param options options to use when constructing this feature
  79643. */
  79644. constructor(_xrSessionManager: WebXRSessionManager,
  79645. /**
  79646. * options to use when constructing this feature
  79647. */
  79648. options?: IWebXRHitTestOptions);
  79649. /**
  79650. * attach this feature
  79651. * Will usually be called by the features manager
  79652. *
  79653. * @returns true if successful.
  79654. */
  79655. attach(): boolean;
  79656. /**
  79657. * detach this feature.
  79658. * Will usually be called by the features manager
  79659. *
  79660. * @returns true if successful.
  79661. */
  79662. detach(): boolean;
  79663. /**
  79664. * Dispose this feature and all of the resources attached
  79665. */
  79666. dispose(): void;
  79667. protected _onXRFrame(frame: XRFrame): void;
  79668. private _processWebXRHitTestResult;
  79669. }
  79670. }
  79671. declare module BABYLON {
  79672. /**
  79673. * Configuration options of the anchor system
  79674. */
  79675. export interface IWebXRAnchorSystemOptions {
  79676. /**
  79677. * a node that will be used to convert local to world coordinates
  79678. */
  79679. worldParentNode?: TransformNode;
  79680. /**
  79681. * If set to true a reference of the created anchors will be kept until the next session starts
  79682. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79683. */
  79684. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79685. }
  79686. /**
  79687. * A babylon container for an XR Anchor
  79688. */
  79689. export interface IWebXRAnchor {
  79690. /**
  79691. * A babylon-assigned ID for this anchor
  79692. */
  79693. id: number;
  79694. /**
  79695. * Transformation matrix to apply to an object attached to this anchor
  79696. */
  79697. transformationMatrix: Matrix;
  79698. /**
  79699. * The native anchor object
  79700. */
  79701. xrAnchor: XRAnchor;
  79702. /**
  79703. * if defined, this object will be constantly updated by the anchor's position and rotation
  79704. */
  79705. attachedNode?: TransformNode;
  79706. /**
  79707. * Remove this anchor from the scene
  79708. */
  79709. remove(): void;
  79710. }
  79711. /**
  79712. * An implementation of the anchor system for WebXR.
  79713. * For further information see https://github.com/immersive-web/anchors/
  79714. */
  79715. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79716. private _options;
  79717. private _lastFrameDetected;
  79718. private _trackedAnchors;
  79719. private _referenceSpaceForFrameAnchors;
  79720. private _futureAnchors;
  79721. /**
  79722. * The module's name
  79723. */
  79724. static readonly Name: string;
  79725. /**
  79726. * The (Babylon) version of this module.
  79727. * This is an integer representing the implementation version.
  79728. * This number does not correspond to the WebXR specs version
  79729. */
  79730. static readonly Version: number;
  79731. /**
  79732. * Observers registered here will be executed when a new anchor was added to the session
  79733. */
  79734. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79735. /**
  79736. * Observers registered here will be executed when an anchor was removed from the session
  79737. */
  79738. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79739. /**
  79740. * Observers registered here will be executed when an existing anchor updates
  79741. * This can execute N times every frame
  79742. */
  79743. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79744. /**
  79745. * Set the reference space to use for anchor creation, when not using a hit test.
  79746. * Will default to the session's reference space if not defined
  79747. */
  79748. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79749. /**
  79750. * constructs a new anchor system
  79751. * @param _xrSessionManager an instance of WebXRSessionManager
  79752. * @param _options configuration object for this feature
  79753. */
  79754. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79755. private _tmpVector;
  79756. private _tmpQuaternion;
  79757. private _populateTmpTransformation;
  79758. /**
  79759. * Create a new anchor point using a hit test result at a specific point in the scene
  79760. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79761. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79762. *
  79763. * @param hitTestResult The hit test result to use for this anchor creation
  79764. * @param position an optional position offset for this anchor
  79765. * @param rotationQuaternion an optional rotation offset for this anchor
  79766. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79767. */
  79768. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79769. /**
  79770. * Add a new anchor at a specific position and rotation
  79771. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79772. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79773. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79774. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79775. *
  79776. * @param position the position in which to add an anchor
  79777. * @param rotationQuaternion an optional rotation for the anchor transformation
  79778. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79779. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79780. */
  79781. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79782. /**
  79783. * Get the list of anchors currently being tracked by the system
  79784. */
  79785. get anchors(): IWebXRAnchor[];
  79786. /**
  79787. * detach this feature.
  79788. * Will usually be called by the features manager
  79789. *
  79790. * @returns true if successful.
  79791. */
  79792. detach(): boolean;
  79793. /**
  79794. * Dispose this feature and all of the resources attached
  79795. */
  79796. dispose(): void;
  79797. protected _onXRFrame(frame: XRFrame): void;
  79798. /**
  79799. * avoiding using Array.find for global support.
  79800. * @param xrAnchor the plane to find in the array
  79801. */
  79802. private _findIndexInAnchorArray;
  79803. private _updateAnchorWithXRFrame;
  79804. private _createAnchorAtTransformation;
  79805. }
  79806. }
  79807. declare module BABYLON {
  79808. /**
  79809. * Options used in the plane detector module
  79810. */
  79811. export interface IWebXRPlaneDetectorOptions {
  79812. /**
  79813. * The node to use to transform the local results to world coordinates
  79814. */
  79815. worldParentNode?: TransformNode;
  79816. /**
  79817. * If set to true a reference of the created planes will be kept until the next session starts
  79818. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79819. */
  79820. doNotRemovePlanesOnSessionEnded?: boolean;
  79821. /**
  79822. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79823. */
  79824. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79825. }
  79826. /**
  79827. * A babylon interface for a WebXR plane.
  79828. * A Plane is actually a polygon, built from N points in space
  79829. *
  79830. * Supported in chrome 79, not supported in canary 81 ATM
  79831. */
  79832. export interface IWebXRPlane {
  79833. /**
  79834. * a babylon-assigned ID for this polygon
  79835. */
  79836. id: number;
  79837. /**
  79838. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79839. */
  79840. polygonDefinition: Array<Vector3>;
  79841. /**
  79842. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79843. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79844. */
  79845. transformationMatrix: Matrix;
  79846. /**
  79847. * the native xr-plane object
  79848. */
  79849. xrPlane: XRPlane;
  79850. }
  79851. /**
  79852. * The plane detector is used to detect planes in the real world when in AR
  79853. * For more information see https://github.com/immersive-web/real-world-geometry/
  79854. */
  79855. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79856. private _options;
  79857. private _detectedPlanes;
  79858. private _enabled;
  79859. private _lastFrameDetected;
  79860. /**
  79861. * The module's name
  79862. */
  79863. static readonly Name: string;
  79864. /**
  79865. * The (Babylon) version of this module.
  79866. * This is an integer representing the implementation version.
  79867. * This number does not correspond to the WebXR specs version
  79868. */
  79869. static readonly Version: number;
  79870. /**
  79871. * Observers registered here will be executed when a new plane was added to the session
  79872. */
  79873. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79874. /**
  79875. * Observers registered here will be executed when a plane is no longer detected in the session
  79876. */
  79877. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79878. /**
  79879. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79880. * This can execute N times every frame
  79881. */
  79882. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79883. /**
  79884. * construct a new Plane Detector
  79885. * @param _xrSessionManager an instance of xr Session manager
  79886. * @param _options configuration to use when constructing this feature
  79887. */
  79888. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79889. /**
  79890. * detach this feature.
  79891. * Will usually be called by the features manager
  79892. *
  79893. * @returns true if successful.
  79894. */
  79895. detach(): boolean;
  79896. /**
  79897. * Dispose this feature and all of the resources attached
  79898. */
  79899. dispose(): void;
  79900. /**
  79901. * Check if the needed objects are defined.
  79902. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79903. */
  79904. isCompatible(): boolean;
  79905. protected _onXRFrame(frame: XRFrame): void;
  79906. private _init;
  79907. private _updatePlaneWithXRPlane;
  79908. /**
  79909. * avoiding using Array.find for global support.
  79910. * @param xrPlane the plane to find in the array
  79911. */
  79912. private _findIndexInPlaneArray;
  79913. }
  79914. }
  79915. declare module BABYLON {
  79916. /**
  79917. * Options interface for the background remover plugin
  79918. */
  79919. export interface IWebXRBackgroundRemoverOptions {
  79920. /**
  79921. * Further background meshes to disable when entering AR
  79922. */
  79923. backgroundMeshes?: AbstractMesh[];
  79924. /**
  79925. * flags to configure the removal of the environment helper.
  79926. * If not set, the entire background will be removed. If set, flags should be set as well.
  79927. */
  79928. environmentHelperRemovalFlags?: {
  79929. /**
  79930. * Should the skybox be removed (default false)
  79931. */
  79932. skyBox?: boolean;
  79933. /**
  79934. * Should the ground be removed (default false)
  79935. */
  79936. ground?: boolean;
  79937. };
  79938. /**
  79939. * don't disable the environment helper
  79940. */
  79941. ignoreEnvironmentHelper?: boolean;
  79942. }
  79943. /**
  79944. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79945. */
  79946. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79947. /**
  79948. * read-only options to be used in this module
  79949. */
  79950. readonly options: IWebXRBackgroundRemoverOptions;
  79951. /**
  79952. * The module's name
  79953. */
  79954. static readonly Name: string;
  79955. /**
  79956. * The (Babylon) version of this module.
  79957. * This is an integer representing the implementation version.
  79958. * This number does not correspond to the WebXR specs version
  79959. */
  79960. static readonly Version: number;
  79961. /**
  79962. * registered observers will be triggered when the background state changes
  79963. */
  79964. onBackgroundStateChangedObservable: Observable<boolean>;
  79965. /**
  79966. * constructs a new background remover module
  79967. * @param _xrSessionManager the session manager for this module
  79968. * @param options read-only options to be used in this module
  79969. */
  79970. constructor(_xrSessionManager: WebXRSessionManager,
  79971. /**
  79972. * read-only options to be used in this module
  79973. */
  79974. options?: IWebXRBackgroundRemoverOptions);
  79975. /**
  79976. * attach this feature
  79977. * Will usually be called by the features manager
  79978. *
  79979. * @returns true if successful.
  79980. */
  79981. attach(): boolean;
  79982. /**
  79983. * detach this feature.
  79984. * Will usually be called by the features manager
  79985. *
  79986. * @returns true if successful.
  79987. */
  79988. detach(): boolean;
  79989. /**
  79990. * Dispose this feature and all of the resources attached
  79991. */
  79992. dispose(): void;
  79993. protected _onXRFrame(_xrFrame: XRFrame): void;
  79994. private _setBackgroundState;
  79995. }
  79996. }
  79997. declare module BABYLON {
  79998. /**
  79999. * Options for the controller physics feature
  80000. */
  80001. export class IWebXRControllerPhysicsOptions {
  80002. /**
  80003. * Should the headset get its own impostor
  80004. */
  80005. enableHeadsetImpostor?: boolean;
  80006. /**
  80007. * Optional parameters for the headset impostor
  80008. */
  80009. headsetImpostorParams?: {
  80010. /**
  80011. * The type of impostor to create. Default is sphere
  80012. */
  80013. impostorType: number;
  80014. /**
  80015. * the size of the impostor. Defaults to 10cm
  80016. */
  80017. impostorSize?: number | {
  80018. width: number;
  80019. height: number;
  80020. depth: number;
  80021. };
  80022. /**
  80023. * Friction definitions
  80024. */
  80025. friction?: number;
  80026. /**
  80027. * Restitution
  80028. */
  80029. restitution?: number;
  80030. };
  80031. /**
  80032. * The physics properties of the future impostors
  80033. */
  80034. physicsProperties?: {
  80035. /**
  80036. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80037. * Note that this requires a physics engine that supports mesh impostors!
  80038. */
  80039. useControllerMesh?: boolean;
  80040. /**
  80041. * The type of impostor to create. Default is sphere
  80042. */
  80043. impostorType?: number;
  80044. /**
  80045. * the size of the impostor. Defaults to 10cm
  80046. */
  80047. impostorSize?: number | {
  80048. width: number;
  80049. height: number;
  80050. depth: number;
  80051. };
  80052. /**
  80053. * Friction definitions
  80054. */
  80055. friction?: number;
  80056. /**
  80057. * Restitution
  80058. */
  80059. restitution?: number;
  80060. };
  80061. /**
  80062. * the xr input to use with this pointer selection
  80063. */
  80064. xrInput: WebXRInput;
  80065. }
  80066. /**
  80067. * Add physics impostor to your webxr controllers,
  80068. * including naive calculation of their linear and angular velocity
  80069. */
  80070. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80071. private readonly _options;
  80072. private _attachController;
  80073. private _controllers;
  80074. private _debugMode;
  80075. private _delta;
  80076. private _headsetImpostor?;
  80077. private _headsetMesh?;
  80078. private _lastTimestamp;
  80079. private _tmpQuaternion;
  80080. private _tmpVector;
  80081. /**
  80082. * The module's name
  80083. */
  80084. static readonly Name: string;
  80085. /**
  80086. * The (Babylon) version of this module.
  80087. * This is an integer representing the implementation version.
  80088. * This number does not correspond to the webxr specs version
  80089. */
  80090. static readonly Version: number;
  80091. /**
  80092. * Construct a new Controller Physics Feature
  80093. * @param _xrSessionManager the corresponding xr session manager
  80094. * @param _options options to create this feature with
  80095. */
  80096. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80097. /**
  80098. * @hidden
  80099. * enable debugging - will show console outputs and the impostor mesh
  80100. */
  80101. _enablePhysicsDebug(): void;
  80102. /**
  80103. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80104. * @param xrController the controller to add
  80105. */
  80106. addController(xrController: WebXRInputSource): void;
  80107. /**
  80108. * attach this feature
  80109. * Will usually be called by the features manager
  80110. *
  80111. * @returns true if successful.
  80112. */
  80113. attach(): boolean;
  80114. /**
  80115. * detach this feature.
  80116. * Will usually be called by the features manager
  80117. *
  80118. * @returns true if successful.
  80119. */
  80120. detach(): boolean;
  80121. /**
  80122. * Get the headset impostor, if enabled
  80123. * @returns the impostor
  80124. */
  80125. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80126. /**
  80127. * Get the physics impostor of a specific controller.
  80128. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80129. * @param controller the controller or the controller id of which to get the impostor
  80130. * @returns the impostor or null
  80131. */
  80132. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80133. /**
  80134. * Update the physics properties provided in the constructor
  80135. * @param newProperties the new properties object
  80136. */
  80137. setPhysicsProperties(newProperties: {
  80138. impostorType?: number;
  80139. impostorSize?: number | {
  80140. width: number;
  80141. height: number;
  80142. depth: number;
  80143. };
  80144. friction?: number;
  80145. restitution?: number;
  80146. }): void;
  80147. protected _onXRFrame(_xrFrame: any): void;
  80148. private _detachController;
  80149. }
  80150. }
  80151. declare module BABYLON {
  80152. /**
  80153. * A babylon interface for a "WebXR" feature point.
  80154. * Represents the position and confidence value of a given feature point.
  80155. */
  80156. export interface IWebXRFeaturePoint {
  80157. /**
  80158. * Represents the position of the feature point in world space.
  80159. */
  80160. position: Vector3;
  80161. /**
  80162. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80163. */
  80164. confidenceValue: number;
  80165. }
  80166. /**
  80167. * The feature point system is used to detect feature points from real world geometry.
  80168. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80169. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80170. */
  80171. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80172. private _enabled;
  80173. private _featurePointCloud;
  80174. /**
  80175. * The module's name
  80176. */
  80177. static readonly Name: string;
  80178. /**
  80179. * The (Babylon) version of this module.
  80180. * This is an integer representing the implementation version.
  80181. * This number does not correspond to the WebXR specs version
  80182. */
  80183. static readonly Version: number;
  80184. /**
  80185. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80186. * Will notify the observers about which feature points have been added.
  80187. */
  80188. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80189. /**
  80190. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80191. * Will notify the observers about which feature points have been updated.
  80192. */
  80193. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80194. /**
  80195. * The current feature point cloud maintained across frames.
  80196. */
  80197. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80198. /**
  80199. * construct the feature point system
  80200. * @param _xrSessionManager an instance of xr Session manager
  80201. */
  80202. constructor(_xrSessionManager: WebXRSessionManager);
  80203. /**
  80204. * Detach this feature.
  80205. * Will usually be called by the features manager
  80206. *
  80207. * @returns true if successful.
  80208. */
  80209. detach(): boolean;
  80210. /**
  80211. * Dispose this feature and all of the resources attached
  80212. */
  80213. dispose(): void;
  80214. /**
  80215. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80216. */
  80217. protected _onXRFrame(frame: XRFrame): void;
  80218. /**
  80219. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80220. */
  80221. private _init;
  80222. }
  80223. }
  80224. declare module BABYLON {
  80225. /**
  80226. * Configuration interface for the hand tracking feature
  80227. */
  80228. export interface IWebXRHandTrackingOptions {
  80229. /**
  80230. * The xrInput that will be used as source for new hands
  80231. */
  80232. xrInput: WebXRInput;
  80233. /**
  80234. * Configuration object for the joint meshes
  80235. */
  80236. jointMeshes?: {
  80237. /**
  80238. * Should the meshes created be invisible (defaults to false)
  80239. */
  80240. invisible?: boolean;
  80241. /**
  80242. * A source mesh to be used to create instances. Defaults to a sphere.
  80243. * This mesh will be the source for all other (25) meshes.
  80244. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80245. */
  80246. sourceMesh?: Mesh;
  80247. /**
  80248. * This function will be called after a mesh was created for a specific joint.
  80249. * Using this function you can either manipulate the instance or return a new mesh.
  80250. * When returning a new mesh the instance created before will be disposed
  80251. */
  80252. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80253. /**
  80254. * Should the source mesh stay visible. Defaults to false
  80255. */
  80256. keepOriginalVisible?: boolean;
  80257. /**
  80258. * Scale factor for all instances (defaults to 2)
  80259. */
  80260. scaleFactor?: number;
  80261. /**
  80262. * Should each instance have its own physics impostor
  80263. */
  80264. enablePhysics?: boolean;
  80265. /**
  80266. * If enabled, override default physics properties
  80267. */
  80268. physicsProps?: {
  80269. friction?: number;
  80270. restitution?: number;
  80271. impostorType?: number;
  80272. };
  80273. /**
  80274. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  80275. */
  80276. disableDefaultHandMesh?: boolean;
  80277. /**
  80278. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  80279. */
  80280. handMeshes?: {
  80281. right: AbstractMesh;
  80282. left: AbstractMesh;
  80283. };
  80284. /**
  80285. * Are the meshes prepared for a left-handed system. Default hand meshes are right-handed.
  80286. */
  80287. leftHandedSystemMeshes?: boolean;
  80288. /**
  80289. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  80290. */
  80291. rigMapping?: {
  80292. right: string[];
  80293. left: string[];
  80294. };
  80295. };
  80296. }
  80297. /**
  80298. * Parts of the hands divided to writs and finger names
  80299. */
  80300. export const enum HandPart {
  80301. /**
  80302. * HandPart - Wrist
  80303. */
  80304. WRIST = "wrist",
  80305. /**
  80306. * HandPart - The Thumb
  80307. */
  80308. THUMB = "thumb",
  80309. /**
  80310. * HandPart - Index finger
  80311. */
  80312. INDEX = "index",
  80313. /**
  80314. * HandPart - Middle finger
  80315. */
  80316. MIDDLE = "middle",
  80317. /**
  80318. * HandPart - Ring finger
  80319. */
  80320. RING = "ring",
  80321. /**
  80322. * HandPart - Little finger
  80323. */
  80324. LITTLE = "little"
  80325. }
  80326. /**
  80327. * Representing a single hand (with its corresponding native XRHand object)
  80328. */
  80329. export class WebXRHand implements IDisposable {
  80330. /** the controller to which the hand correlates */
  80331. readonly xrController: WebXRInputSource;
  80332. /** the meshes to be used to track the hand joints */
  80333. readonly trackedMeshes: AbstractMesh[];
  80334. private _handMesh?;
  80335. private _rigMapping?;
  80336. private _leftHandedMeshes?;
  80337. private _scene;
  80338. private _defaultHandMesh;
  80339. private _transformNodeMapping;
  80340. private _boneMapping;
  80341. private _useBones;
  80342. /**
  80343. * Hand-parts definition (key is HandPart)
  80344. */
  80345. handPartsDefinition: {
  80346. [key: string]: number[];
  80347. };
  80348. /**
  80349. * Observers will be triggered when the mesh for this hand was initialized.
  80350. */
  80351. onHandMeshReadyObservable: Observable<WebXRHand>;
  80352. /**
  80353. * Populate the HandPartsDefinition object.
  80354. * This is called as a side effect since certain browsers don't have XRHand defined.
  80355. */
  80356. private generateHandPartsDefinition;
  80357. /**
  80358. * Construct a new hand object
  80359. * @param xrController the controller to which the hand correlates
  80360. * @param trackedMeshes the meshes to be used to track the hand joints
  80361. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  80362. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  80363. * @param disableDefaultHandMesh should the default mesh creation be disabled
  80364. * @param _leftHandedMeshes are the hand meshes left-handed-system meshes
  80365. */
  80366. constructor(
  80367. /** the controller to which the hand correlates */
  80368. xrController: WebXRInputSource,
  80369. /** the meshes to be used to track the hand joints */
  80370. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean, _leftHandedMeshes?: boolean | undefined);
  80371. /**
  80372. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  80373. */
  80374. get handMesh(): AbstractMesh | undefined;
  80375. /**
  80376. * Update this hand from the latest xr frame
  80377. * @param xrFrame xrFrame to update from
  80378. * @param referenceSpace The current viewer reference space
  80379. * @param scaleFactor optional scale factor for the meshes
  80380. */
  80381. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80382. /**
  80383. * Get meshes of part of the hand
  80384. * @param part the part of hand to get
  80385. * @returns An array of meshes that correlate to the hand part requested
  80386. */
  80387. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80388. /**
  80389. * Dispose this Hand object
  80390. */
  80391. dispose(): void;
  80392. private _generateDefaultHandMesh;
  80393. }
  80394. /**
  80395. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80396. */
  80397. export class WebXRHandTracking extends WebXRAbstractFeature {
  80398. /**
  80399. * options to use when constructing this feature
  80400. */
  80401. readonly options: IWebXRHandTrackingOptions;
  80402. private static _idCounter;
  80403. /**
  80404. * The module's name
  80405. */
  80406. static readonly Name: string;
  80407. /**
  80408. * The (Babylon) version of this module.
  80409. * This is an integer representing the implementation version.
  80410. * This number does not correspond to the WebXR specs version
  80411. */
  80412. static readonly Version: number;
  80413. /**
  80414. * This observable will notify registered observers when a new hand object was added and initialized
  80415. */
  80416. onHandAddedObservable: Observable<WebXRHand>;
  80417. /**
  80418. * This observable will notify its observers right before the hand object is disposed
  80419. */
  80420. onHandRemovedObservable: Observable<WebXRHand>;
  80421. private _hands;
  80422. /**
  80423. * Creates a new instance of the hit test feature
  80424. * @param _xrSessionManager an instance of WebXRSessionManager
  80425. * @param options options to use when constructing this feature
  80426. */
  80427. constructor(_xrSessionManager: WebXRSessionManager,
  80428. /**
  80429. * options to use when constructing this feature
  80430. */
  80431. options: IWebXRHandTrackingOptions);
  80432. /**
  80433. * Check if the needed objects are defined.
  80434. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80435. */
  80436. isCompatible(): boolean;
  80437. /**
  80438. * attach this feature
  80439. * Will usually be called by the features manager
  80440. *
  80441. * @returns true if successful.
  80442. */
  80443. attach(): boolean;
  80444. /**
  80445. * detach this feature.
  80446. * Will usually be called by the features manager
  80447. *
  80448. * @returns true if successful.
  80449. */
  80450. detach(): boolean;
  80451. /**
  80452. * Dispose this feature and all of the resources attached
  80453. */
  80454. dispose(): void;
  80455. /**
  80456. * Get the hand object according to the controller id
  80457. * @param controllerId the controller id to which we want to get the hand
  80458. * @returns null if not found or the WebXRHand object if found
  80459. */
  80460. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80461. /**
  80462. * Get a hand object according to the requested handedness
  80463. * @param handedness the handedness to request
  80464. * @returns null if not found or the WebXRHand object if found
  80465. */
  80466. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80467. protected _onXRFrame(_xrFrame: XRFrame): void;
  80468. private _attachHand;
  80469. private _detachHand;
  80470. }
  80471. }
  80472. declare module BABYLON {
  80473. /**
  80474. * Options used in the mesh detector module
  80475. */
  80476. export interface IWebXRMeshDetectorOptions {
  80477. /**
  80478. * The node to use to transform the local results to world coordinates
  80479. */
  80480. worldParentNode?: TransformNode;
  80481. /**
  80482. * If set to true a reference of the created meshes will be kept until the next session starts
  80483. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  80484. */
  80485. doNotRemoveMeshesOnSessionEnded?: boolean;
  80486. /**
  80487. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  80488. */
  80489. preferredDetectorOptions?: XRGeometryDetectorOptions;
  80490. /**
  80491. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  80492. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  80493. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  80494. */
  80495. convertCoordinateSystems?: boolean;
  80496. }
  80497. /**
  80498. * A babylon interface for a XR mesh's vertex data.
  80499. *
  80500. * Currently not supported by WebXR, available only with BabylonNative
  80501. */
  80502. export interface IWebXRVertexData {
  80503. /**
  80504. * A babylon-assigned ID for this mesh
  80505. */
  80506. id: number;
  80507. /**
  80508. * Data required for constructing a mesh in Babylon.js.
  80509. */
  80510. xrMesh: XRMesh;
  80511. /**
  80512. * The node to use to transform the local results to world coordinates.
  80513. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  80514. */
  80515. worldParentNode?: TransformNode;
  80516. /**
  80517. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  80518. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80519. */
  80520. positions?: Float32Array;
  80521. /**
  80522. * An array of indices in babylon space. Indices have a counterclockwise winding order.
  80523. * Indices will only be populated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80524. */
  80525. indices?: Uint32Array;
  80526. /**
  80527. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  80528. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  80529. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  80530. */
  80531. normals?: Float32Array;
  80532. /**
  80533. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  80534. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  80535. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  80536. */
  80537. transformationMatrix?: Matrix;
  80538. }
  80539. /**
  80540. * The mesh detector is used to detect meshes in the real world when in AR
  80541. */
  80542. export class WebXRMeshDetector extends WebXRAbstractFeature {
  80543. private _options;
  80544. private _detectedMeshes;
  80545. /**
  80546. * The module's name
  80547. */
  80548. static readonly Name: string;
  80549. /**
  80550. * The (Babylon) version of this module.
  80551. * This is an integer representing the implementation version.
  80552. * This number does not correspond to the WebXR specs version
  80553. */
  80554. static readonly Version: number;
  80555. /**
  80556. * Observers registered here will be executed when a new mesh was added to the session
  80557. */
  80558. onMeshAddedObservable: Observable<IWebXRVertexData>;
  80559. /**
  80560. * Observers registered here will be executed when a mesh is no longer detected in the session
  80561. */
  80562. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  80563. /**
  80564. * Observers registered here will be executed when an existing mesh updates
  80565. */
  80566. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  80567. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  80568. detach(): boolean;
  80569. dispose(): void;
  80570. protected _onXRFrame(frame: XRFrame): void;
  80571. private _init;
  80572. private _updateVertexDataWithXRMesh;
  80573. }
  80574. }
  80575. declare module BABYLON {
  80576. /**
  80577. * Options interface for the background remover plugin
  80578. */
  80579. export interface IWebXRImageTrackingOptions {
  80580. /**
  80581. * A required array with images to track
  80582. */
  80583. images: {
  80584. /**
  80585. * The source of the image. can be a URL or an image bitmap
  80586. */
  80587. src: string | ImageBitmap;
  80588. /**
  80589. * The estimated width in the real world (in meters)
  80590. */
  80591. estimatedRealWorldWidth: number;
  80592. }[];
  80593. }
  80594. /**
  80595. * An object representing an image tracked by the system
  80596. */
  80597. export interface IWebXRTrackedImage {
  80598. /**
  80599. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  80600. */
  80601. id: number;
  80602. /**
  80603. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  80604. */
  80605. emulated?: boolean;
  80606. /**
  80607. * Just in case it is needed - the image bitmap that is being tracked
  80608. */
  80609. originalBitmap: ImageBitmap;
  80610. /**
  80611. * The native XR result image tracking result, untouched
  80612. */
  80613. xrTrackingResult?: XRImageTrackingResult;
  80614. /**
  80615. * Width in real world (meters)
  80616. */
  80617. realWorldWidth?: number;
  80618. /**
  80619. * A transformation matrix of this current image in the current reference space.
  80620. */
  80621. transformationMatrix: Matrix;
  80622. /**
  80623. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  80624. */
  80625. ratio?: number;
  80626. }
  80627. /**
  80628. * Image tracking for immersive AR sessions.
  80629. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  80630. */
  80631. export class WebXRImageTracking extends WebXRAbstractFeature {
  80632. /**
  80633. * read-only options to be used in this module
  80634. */
  80635. readonly options: IWebXRImageTrackingOptions;
  80636. /**
  80637. * The module's name
  80638. */
  80639. static readonly Name: string;
  80640. /**
  80641. * The (Babylon) version of this module.
  80642. * This is an integer representing the implementation version.
  80643. * This number does not correspond to the WebXR specs version
  80644. */
  80645. static readonly Version: number;
  80646. /**
  80647. * This will be triggered if the underlying system deems an image untrackable.
  80648. * The index is the index of the image from the array used to initialize the feature.
  80649. */
  80650. onUntrackableImageFoundObservable: Observable<number>;
  80651. /**
  80652. * An image was deemed trackable, and the system will start tracking it.
  80653. */
  80654. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  80655. /**
  80656. * The image was found and its state was updated.
  80657. */
  80658. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  80659. private _trackedImages;
  80660. private _originalTrackingRequest;
  80661. /**
  80662. * constructs the image tracking feature
  80663. * @param _xrSessionManager the session manager for this module
  80664. * @param options read-only options to be used in this module
  80665. */
  80666. constructor(_xrSessionManager: WebXRSessionManager,
  80667. /**
  80668. * read-only options to be used in this module
  80669. */
  80670. options: IWebXRImageTrackingOptions);
  80671. /**
  80672. * attach this feature
  80673. * Will usually be called by the features manager
  80674. *
  80675. * @returns true if successful.
  80676. */
  80677. attach(): boolean;
  80678. /**
  80679. * detach this feature.
  80680. * Will usually be called by the features manager
  80681. *
  80682. * @returns true if successful.
  80683. */
  80684. detach(): boolean;
  80685. /**
  80686. * Check if the needed objects are defined.
  80687. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80688. */
  80689. isCompatible(): boolean;
  80690. /**
  80691. * Get a tracked image by its ID.
  80692. *
  80693. * @param id the id of the image to load (position in the init array)
  80694. * @returns a trackable image, if exists in this location
  80695. */
  80696. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  80697. /**
  80698. * Dispose this feature and all of the resources attached
  80699. */
  80700. dispose(): void;
  80701. /**
  80702. * Extends the session init object if needed
  80703. * @returns augmentation object fo the xr session init object.
  80704. */
  80705. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  80706. protected _onXRFrame(_xrFrame: XRFrame): void;
  80707. private _init;
  80708. }
  80709. }
  80710. declare module BABYLON {
  80711. /**
  80712. * The motion controller class for all microsoft mixed reality controllers
  80713. */
  80714. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80715. protected readonly _mapping: {
  80716. defaultButton: {
  80717. valueNodeName: string;
  80718. unpressedNodeName: string;
  80719. pressedNodeName: string;
  80720. };
  80721. defaultAxis: {
  80722. valueNodeName: string;
  80723. minNodeName: string;
  80724. maxNodeName: string;
  80725. };
  80726. buttons: {
  80727. "xr-standard-trigger": {
  80728. rootNodeName: string;
  80729. componentProperty: string;
  80730. states: string[];
  80731. };
  80732. "xr-standard-squeeze": {
  80733. rootNodeName: string;
  80734. componentProperty: string;
  80735. states: string[];
  80736. };
  80737. "xr-standard-touchpad": {
  80738. rootNodeName: string;
  80739. labelAnchorNodeName: string;
  80740. touchPointNodeName: string;
  80741. };
  80742. "xr-standard-thumbstick": {
  80743. rootNodeName: string;
  80744. componentProperty: string;
  80745. states: string[];
  80746. };
  80747. };
  80748. axes: {
  80749. "xr-standard-touchpad": {
  80750. "x-axis": {
  80751. rootNodeName: string;
  80752. };
  80753. "y-axis": {
  80754. rootNodeName: string;
  80755. };
  80756. };
  80757. "xr-standard-thumbstick": {
  80758. "x-axis": {
  80759. rootNodeName: string;
  80760. };
  80761. "y-axis": {
  80762. rootNodeName: string;
  80763. };
  80764. };
  80765. };
  80766. };
  80767. /**
  80768. * The base url used to load the left and right controller models
  80769. */
  80770. static MODEL_BASE_URL: string;
  80771. /**
  80772. * The name of the left controller model file
  80773. */
  80774. static MODEL_LEFT_FILENAME: string;
  80775. /**
  80776. * The name of the right controller model file
  80777. */
  80778. static MODEL_RIGHT_FILENAME: string;
  80779. profileId: string;
  80780. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80781. protected _getFilenameAndPath(): {
  80782. filename: string;
  80783. path: string;
  80784. };
  80785. protected _getModelLoadingConstraints(): boolean;
  80786. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80787. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80788. protected _updateModel(): void;
  80789. }
  80790. }
  80791. declare module BABYLON {
  80792. /**
  80793. * The motion controller class for oculus touch (quest, rift).
  80794. * This class supports legacy mapping as well the standard xr mapping
  80795. */
  80796. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80797. private _forceLegacyControllers;
  80798. private _modelRootNode;
  80799. /**
  80800. * The base url used to load the left and right controller models
  80801. */
  80802. static MODEL_BASE_URL: string;
  80803. /**
  80804. * The name of the left controller model file
  80805. */
  80806. static MODEL_LEFT_FILENAME: string;
  80807. /**
  80808. * The name of the right controller model file
  80809. */
  80810. static MODEL_RIGHT_FILENAME: string;
  80811. /**
  80812. * Base Url for the Quest controller model.
  80813. */
  80814. static QUEST_MODEL_BASE_URL: string;
  80815. profileId: string;
  80816. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80817. protected _getFilenameAndPath(): {
  80818. filename: string;
  80819. path: string;
  80820. };
  80821. protected _getModelLoadingConstraints(): boolean;
  80822. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80823. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80824. protected _updateModel(): void;
  80825. /**
  80826. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80827. * between the touch and touch 2.
  80828. */
  80829. private _isQuest;
  80830. }
  80831. }
  80832. declare module BABYLON {
  80833. /**
  80834. * The motion controller class for the standard HTC-Vive controllers
  80835. */
  80836. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80837. private _modelRootNode;
  80838. /**
  80839. * The base url used to load the left and right controller models
  80840. */
  80841. static MODEL_BASE_URL: string;
  80842. /**
  80843. * File name for the controller model.
  80844. */
  80845. static MODEL_FILENAME: string;
  80846. profileId: string;
  80847. /**
  80848. * Create a new Vive motion controller object
  80849. * @param scene the scene to use to create this controller
  80850. * @param gamepadObject the corresponding gamepad object
  80851. * @param handedness the handedness of the controller
  80852. */
  80853. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80854. protected _getFilenameAndPath(): {
  80855. filename: string;
  80856. path: string;
  80857. };
  80858. protected _getModelLoadingConstraints(): boolean;
  80859. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80860. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80861. protected _updateModel(): void;
  80862. }
  80863. }
  80864. declare module BABYLON {
  80865. /** @hidden */
  80866. export class WebGPUCacheRenderPipelineString extends WebGPUCacheRenderPipeline {
  80867. private static _Cache;
  80868. protected _getRenderPipeline(param: {
  80869. token: any;
  80870. pipeline: Nullable<GPURenderPipeline>;
  80871. }): void;
  80872. protected _setRenderPipeline(param: {
  80873. token: any;
  80874. pipeline: Nullable<GPURenderPipeline>;
  80875. }): void;
  80876. }
  80877. }
  80878. declare module BABYLON {
  80879. /** @hidden */
  80880. export var blurPixelShader: {
  80881. name: string;
  80882. shader: string;
  80883. };
  80884. }
  80885. declare module BABYLON {
  80886. /** @hidden */
  80887. export var pointCloudVertexDeclaration: {
  80888. name: string;
  80889. shader: string;
  80890. };
  80891. }
  80892. // Mixins
  80893. interface Window {
  80894. mozIndexedDB: IDBFactory;
  80895. webkitIndexedDB: IDBFactory;
  80896. msIndexedDB: IDBFactory;
  80897. webkitURL: typeof URL;
  80898. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80899. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80900. WebGLRenderingContext: WebGLRenderingContext;
  80901. MSGesture: MSGesture;
  80902. CANNON: any;
  80903. AudioContext: AudioContext;
  80904. webkitAudioContext: AudioContext;
  80905. PointerEvent: any;
  80906. Math: Math;
  80907. Uint8Array: Uint8ArrayConstructor;
  80908. Float32Array: Float32ArrayConstructor;
  80909. mozURL: typeof URL;
  80910. msURL: typeof URL;
  80911. VRFrameData: any; // WebVR, from specs 1.1
  80912. DracoDecoderModule: any;
  80913. setImmediate(handler: (...args: any[]) => void): number;
  80914. }
  80915. interface HTMLCanvasElement {
  80916. requestPointerLock(): void;
  80917. msRequestPointerLock?(): void;
  80918. mozRequestPointerLock?(): void;
  80919. webkitRequestPointerLock?(): void;
  80920. /** Track whether a record is in progress */
  80921. isRecording: boolean;
  80922. /** Capture Stream method defined by some browsers */
  80923. captureStream(fps?: number): MediaStream;
  80924. }
  80925. interface CanvasRenderingContext2D {
  80926. msImageSmoothingEnabled: boolean;
  80927. }
  80928. interface MouseEvent {
  80929. mozMovementX: number;
  80930. mozMovementY: number;
  80931. webkitMovementX: number;
  80932. webkitMovementY: number;
  80933. msMovementX: number;
  80934. msMovementY: number;
  80935. }
  80936. interface Navigator {
  80937. mozGetVRDevices: (any: any) => any;
  80938. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80939. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80940. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80941. webkitGetGamepads(): Gamepad[];
  80942. msGetGamepads(): Gamepad[];
  80943. webkitGamepads(): Gamepad[];
  80944. }
  80945. interface HTMLVideoElement {
  80946. mozSrcObject: any;
  80947. }
  80948. interface Math {
  80949. fround(x: number): number;
  80950. imul(a: number, b: number): number;
  80951. log2(x: number): number;
  80952. }
  80953. interface WebGLRenderingContext {
  80954. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80955. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80956. vertexAttribDivisor(index: number, divisor: number): void;
  80957. createVertexArray(): any;
  80958. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80959. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80960. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80961. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80962. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80963. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80964. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80965. // Queries
  80966. createQuery(): WebGLQuery;
  80967. deleteQuery(query: WebGLQuery): void;
  80968. beginQuery(target: number, query: WebGLQuery): void;
  80969. endQuery(target: number): void;
  80970. getQueryParameter(query: WebGLQuery, pname: number): any;
  80971. getQuery(target: number, pname: number): any;
  80972. MAX_SAMPLES: number;
  80973. RGBA8: number;
  80974. READ_FRAMEBUFFER: number;
  80975. DRAW_FRAMEBUFFER: number;
  80976. UNIFORM_BUFFER: number;
  80977. HALF_FLOAT_OES: number;
  80978. RGBA16F: number;
  80979. RGBA32F: number;
  80980. R32F: number;
  80981. RG32F: number;
  80982. RGB32F: number;
  80983. R16F: number;
  80984. RG16F: number;
  80985. RGB16F: number;
  80986. RED: number;
  80987. RG: number;
  80988. R8: number;
  80989. RG8: number;
  80990. UNSIGNED_INT_24_8: number;
  80991. DEPTH24_STENCIL8: number;
  80992. MIN: number;
  80993. MAX: number;
  80994. /* Multiple Render Targets */
  80995. drawBuffers(buffers: number[]): void;
  80996. readBuffer(src: number): void;
  80997. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80998. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80999. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  81000. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  81001. // Occlusion Query
  81002. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81003. ANY_SAMPLES_PASSED: number;
  81004. QUERY_RESULT_AVAILABLE: number;
  81005. QUERY_RESULT: number;
  81006. }
  81007. interface WebGLProgram {
  81008. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  81009. }
  81010. interface EXT_disjoint_timer_query {
  81011. QUERY_COUNTER_BITS_EXT: number;
  81012. TIME_ELAPSED_EXT: number;
  81013. TIMESTAMP_EXT: number;
  81014. GPU_DISJOINT_EXT: number;
  81015. QUERY_RESULT_EXT: number;
  81016. QUERY_RESULT_AVAILABLE_EXT: number;
  81017. queryCounterEXT(query: WebGLQuery, target: number): void;
  81018. createQueryEXT(): WebGLQuery;
  81019. beginQueryEXT(target: number, query: WebGLQuery): void;
  81020. endQueryEXT(target: number): void;
  81021. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  81022. deleteQueryEXT(query: WebGLQuery): void;
  81023. }
  81024. interface WebGLUniformLocation {
  81025. _currentState: any;
  81026. }
  81027. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  81028. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  81029. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  81030. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81031. interface WebGLRenderingContext {
  81032. readonly RASTERIZER_DISCARD: number;
  81033. readonly DEPTH_COMPONENT24: number;
  81034. readonly TEXTURE_3D: number;
  81035. readonly TEXTURE_2D_ARRAY: number;
  81036. readonly TEXTURE_COMPARE_FUNC: number;
  81037. readonly TEXTURE_COMPARE_MODE: number;
  81038. readonly COMPARE_REF_TO_TEXTURE: number;
  81039. readonly TEXTURE_WRAP_R: number;
  81040. readonly HALF_FLOAT: number;
  81041. readonly RGB8: number;
  81042. readonly RED_INTEGER: number;
  81043. readonly RG_INTEGER: number;
  81044. readonly RGB_INTEGER: number;
  81045. readonly RGBA_INTEGER: number;
  81046. readonly R8_SNORM: number;
  81047. readonly RG8_SNORM: number;
  81048. readonly RGB8_SNORM: number;
  81049. readonly RGBA8_SNORM: number;
  81050. readonly R8I: number;
  81051. readonly RG8I: number;
  81052. readonly RGB8I: number;
  81053. readonly RGBA8I: number;
  81054. readonly R8UI: number;
  81055. readonly RG8UI: number;
  81056. readonly RGB8UI: number;
  81057. readonly RGBA8UI: number;
  81058. readonly R16I: number;
  81059. readonly RG16I: number;
  81060. readonly RGB16I: number;
  81061. readonly RGBA16I: number;
  81062. readonly R16UI: number;
  81063. readonly RG16UI: number;
  81064. readonly RGB16UI: number;
  81065. readonly RGBA16UI: number;
  81066. readonly R32I: number;
  81067. readonly RG32I: number;
  81068. readonly RGB32I: number;
  81069. readonly RGBA32I: number;
  81070. readonly R32UI: number;
  81071. readonly RG32UI: number;
  81072. readonly RGB32UI: number;
  81073. readonly RGBA32UI: number;
  81074. readonly RGB10_A2UI: number;
  81075. readonly R11F_G11F_B10F: number;
  81076. readonly RGB9_E5: number;
  81077. readonly RGB10_A2: number;
  81078. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  81079. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  81080. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  81081. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81082. readonly DEPTH_COMPONENT32F: number;
  81083. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  81084. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  81085. 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;
  81086. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  81087. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  81088. readonly TRANSFORM_FEEDBACK: number;
  81089. readonly INTERLEAVED_ATTRIBS: number;
  81090. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  81091. createTransformFeedback(): WebGLTransformFeedback;
  81092. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  81093. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  81094. beginTransformFeedback(primitiveMode: number): void;
  81095. endTransformFeedback(): void;
  81096. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  81097. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81098. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81099. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  81100. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  81101. }
  81102. interface ImageBitmap {
  81103. readonly width: number;
  81104. readonly height: number;
  81105. close(): void;
  81106. }
  81107. interface WebGLQuery extends WebGLObject {
  81108. }
  81109. declare var WebGLQuery: {
  81110. prototype: WebGLQuery;
  81111. new(): WebGLQuery;
  81112. };
  81113. interface WebGLSampler extends WebGLObject {
  81114. }
  81115. declare var WebGLSampler: {
  81116. prototype: WebGLSampler;
  81117. new(): WebGLSampler;
  81118. };
  81119. interface WebGLSync extends WebGLObject {
  81120. }
  81121. declare var WebGLSync: {
  81122. prototype: WebGLSync;
  81123. new(): WebGLSync;
  81124. };
  81125. interface WebGLTransformFeedback extends WebGLObject {
  81126. }
  81127. declare var WebGLTransformFeedback: {
  81128. prototype: WebGLTransformFeedback;
  81129. new(): WebGLTransformFeedback;
  81130. };
  81131. interface WebGLVertexArrayObject extends WebGLObject {
  81132. }
  81133. declare var WebGLVertexArrayObject: {
  81134. prototype: WebGLVertexArrayObject;
  81135. new(): WebGLVertexArrayObject;
  81136. };
  81137. interface Navigator {
  81138. readonly gpu: GPU | undefined;
  81139. }
  81140. interface GPUColorDict {
  81141. a: number;
  81142. b: number;
  81143. g: number;
  81144. r: number;
  81145. }
  81146. type GPUColor = [number, number, number, number] | GPUColorDict;
  81147. interface GPUOrigin2DDict {
  81148. x?: number;
  81149. y?: number;
  81150. }
  81151. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  81152. interface GPUOrigin3DDict {
  81153. x?: number;
  81154. y?: number;
  81155. z?: number;
  81156. }
  81157. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  81158. interface GPUExtent3DDict {
  81159. width: number;
  81160. height: number;
  81161. depth: number;
  81162. }
  81163. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  81164. type GPUBindingResource =
  81165. | GPUSampler
  81166. | GPUTextureView
  81167. | GPUBufferBinding;
  81168. type GPUExtensionName =
  81169. | "texture-compression-bc"
  81170. | "timestamp-query"
  81171. | "pipeline-statistics-query"
  81172. | "depth-clamping"
  81173. | "depth24unorm-stencil8"
  81174. | "depth32float-stencil8";
  81175. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  81176. type GPUBindingType =
  81177. | "uniform-buffer"
  81178. | "storage-buffer"
  81179. | "readonly-storage-buffer"
  81180. | "sampler"
  81181. | "comparison-sampler"
  81182. | "sampled-texture"
  81183. | "readonly-storage-texture"
  81184. | "writeonly-storage-texture";
  81185. type GPUBlendFactor =
  81186. | "zero"
  81187. | "one"
  81188. | "src-color"
  81189. | "one-minus-src-color"
  81190. | "src-alpha"
  81191. | "one-minus-src-alpha"
  81192. | "dst-color"
  81193. | "one-minus-dst-color"
  81194. | "dst-alpha"
  81195. | "one-minus-dst-alpha"
  81196. | "src-alpha-saturated"
  81197. | "blend-color"
  81198. | "one-minus-blend-color";
  81199. type GPUBlendOperation =
  81200. | "add"
  81201. | "subtract"
  81202. | "reverse-subtract"
  81203. | "min"
  81204. | "max";
  81205. type GPUCompareFunction =
  81206. | "never"
  81207. | "less"
  81208. | "equal"
  81209. | "less-equal"
  81210. | "greater"
  81211. | "not-equal"
  81212. | "greater-equal"
  81213. | "always";
  81214. type GPUCullMode = "none" | "front" | "back";
  81215. type GPUFilterMode = "nearest" | "linear";
  81216. type GPUFrontFace = "ccw" | "cw";
  81217. type GPUIndexFormat = "uint16" | "uint32";
  81218. type GPUInputStepMode = "vertex" | "instance";
  81219. type GPULoadOp = "load";
  81220. type GPUPrimitiveTopology =
  81221. | "point-list"
  81222. | "line-list"
  81223. | "line-strip"
  81224. | "triangle-list"
  81225. | "triangle-strip";
  81226. type GPUStencilOperation =
  81227. | "keep"
  81228. | "zero"
  81229. | "replace"
  81230. | "invert"
  81231. | "increment-clamp"
  81232. | "decrement-clamp"
  81233. | "increment-wrap"
  81234. | "decrement-wrap";
  81235. type GPUStoreOp = "store" | "clear";
  81236. type GPUTextureDimension = "1d" | "2d" | "3d";
  81237. type GPUTextureFormat =
  81238. | "r8unorm"
  81239. | "r8snorm"
  81240. | "r8uint"
  81241. | "r8sint"
  81242. | "r16uint"
  81243. | "r16sint"
  81244. | "r16float"
  81245. | "rg8unorm"
  81246. | "rg8snorm"
  81247. | "rg8uint"
  81248. | "rg8sint"
  81249. | "r32uint"
  81250. | "r32sint"
  81251. | "r32float"
  81252. | "rg16uint"
  81253. | "rg16sint"
  81254. | "rg16float"
  81255. | "rgba8unorm"
  81256. | "rgba8unorm-srgb"
  81257. | "rgba8snorm"
  81258. | "rgba8uint"
  81259. | "rgba8sint"
  81260. | "bgra8unorm"
  81261. | "bgra8unorm-srgb"
  81262. | "rgb9e5ufloat"
  81263. | "rgb10a2unorm"
  81264. | "rg11b10ufloat"
  81265. | "rg32uint"
  81266. | "rg32sint"
  81267. | "rg32float"
  81268. | "rgba16uint"
  81269. | "rgba16sint"
  81270. | "rgba16float"
  81271. | "rgba32uint"
  81272. | "rgba32sint"
  81273. | "rgba32float"
  81274. | "stencil8"
  81275. | "depth16unorm"
  81276. | "depth24plus"
  81277. | "depth24plus-stencil8"
  81278. | "depth32float"
  81279. | "bc1-rgba-unorm"
  81280. | "bc1-rgba-unorm-srgb"
  81281. | "bc2-rgba-unorm"
  81282. | "bc2-rgba-unorm-srgb"
  81283. | "bc3-rgba-unorm"
  81284. | "bc3-rgba-unorm-srgb"
  81285. | "bc4-r-unorm"
  81286. | "bc4-r-snorm"
  81287. | "bc5-rg-unorm"
  81288. | "bc5-rg-snorm"
  81289. | "bc6h-rgb-ufloat"
  81290. | "bc6h-rgb-float"
  81291. | "bc7-rgba-unorm"
  81292. | "bc7-rgba-unorm-srgb"
  81293. | "depth24unorm-stencil8"
  81294. | "depth32float-stencil8";
  81295. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  81296. type GPUTextureViewDimension =
  81297. | "1d"
  81298. | "2d"
  81299. | "2d-array"
  81300. | "cube"
  81301. | "cube-array"
  81302. | "3d";
  81303. type GPUVertexFormat =
  81304. | "uchar2"
  81305. | "uchar4"
  81306. | "char2"
  81307. | "char4"
  81308. | "uchar2norm"
  81309. | "uchar4norm"
  81310. | "char2norm"
  81311. | "char4norm"
  81312. | "ushort2"
  81313. | "ushort4"
  81314. | "short2"
  81315. | "short4"
  81316. | "ushort2norm"
  81317. | "ushort4norm"
  81318. | "short2norm"
  81319. | "short4norm"
  81320. | "half2"
  81321. | "half4"
  81322. | "float"
  81323. | "float2"
  81324. | "float3"
  81325. | "float4"
  81326. | "uint"
  81327. | "uint2"
  81328. | "uint3"
  81329. | "uint4"
  81330. | "int"
  81331. | "int2"
  81332. | "int3"
  81333. | "int4";
  81334. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  81335. type GPUBufferUsageFlags = number;
  81336. type GPUColorWriteFlags = number;
  81337. type GPUShaderStageFlags = number;
  81338. type GPUTextureUsageFlags = number;
  81339. type GPUMapModeFlags = number;
  81340. interface GPUBindGroupEntry {
  81341. binding: number;
  81342. resource: GPUBindingResource;
  81343. }
  81344. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  81345. layout: GPUBindGroupLayout;
  81346. entries: Iterable<GPUBindGroupEntry>;
  81347. }
  81348. interface GPUBindGroupLayoutEntry {
  81349. binding: number;
  81350. visibility: GPUShaderStageFlags;
  81351. type: GPUBindingType;
  81352. hasDynamicOffset?: boolean;
  81353. minBufferBindingSize?: number;
  81354. viewDimension?: GPUTextureViewDimension;
  81355. textureComponentType?: GPUTextureComponentType;
  81356. storageTextureFormat?: GPUTextureFormat;
  81357. }
  81358. interface GPUBindGroupLayoutDescriptor
  81359. extends GPUObjectDescriptorBase {
  81360. entries: Iterable<GPUBindGroupLayoutEntry>;
  81361. }
  81362. interface GPUBlendDescriptor {
  81363. dstFactor?: GPUBlendFactor;
  81364. operation?: GPUBlendOperation;
  81365. srcFactor?: GPUBlendFactor;
  81366. }
  81367. interface GPUColorStateDescriptor {
  81368. format: GPUTextureFormat;
  81369. alphaBlend?: GPUBlendDescriptor;
  81370. colorBlend?: GPUBlendDescriptor;
  81371. writeMask?: GPUColorWriteFlags;
  81372. }
  81373. interface GPUBufferBinding {
  81374. buffer: GPUBuffer;
  81375. offset?: number;
  81376. size?: number;
  81377. }
  81378. interface GPUTextureDataLayout {
  81379. offset?: number;
  81380. bytesPerRow: number;
  81381. rowsPerImage?: number;
  81382. }
  81383. interface GPUBufferCopyView extends GPUTextureDataLayout {
  81384. buffer: GPUBuffer;
  81385. }
  81386. interface GPUTextureCopyView {
  81387. texture: GPUTexture;
  81388. mipLevel?: number;
  81389. origin?: GPUOrigin3D;
  81390. }
  81391. interface GPUImageBitmapCopyView {
  81392. imageBitmap: ImageBitmap;
  81393. origin?: GPUOrigin2D;
  81394. }
  81395. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  81396. size: number;
  81397. usage: GPUBufferUsageFlags;
  81398. mappedAtCreation?: boolean;
  81399. }
  81400. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  81401. label?: string;
  81402. measureExecutionTime?: boolean;
  81403. }
  81404. interface GPUComputePipelineDescriptor
  81405. extends GPUPipelineDescriptorBase {
  81406. computeStage: GPUProgrammableStageDescriptor;
  81407. }
  81408. interface GPUDepthStencilStateDescriptor {
  81409. format: GPUTextureFormat;
  81410. depthWriteEnabled?: boolean;
  81411. depthCompare?: GPUCompareFunction;
  81412. stencilFront?: GPUStencilStateFaceDescriptor;
  81413. stencilBack?: GPUStencilStateFaceDescriptor;
  81414. stencilReadMask?: number;
  81415. stencilWriteMask?: number;
  81416. }
  81417. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  81418. extensions?: Iterable<GPUExtensionName>;
  81419. limits?: GPULimits;
  81420. }
  81421. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  81422. initialValue?: number;
  81423. label?: string;
  81424. signalQueue?: GPUQueue;
  81425. }
  81426. interface GPUVertexAttributeDescriptor {
  81427. format: GPUVertexFormat;
  81428. offset: number;
  81429. shaderLocation: number;
  81430. }
  81431. interface GPUVertexBufferLayoutDescriptor {
  81432. arrayStride: number;
  81433. stepMode?: GPUInputStepMode;
  81434. attributes: Iterable<GPUVertexAttributeDescriptor>;
  81435. }
  81436. interface GPUVertexStateDescriptor {
  81437. indexFormat?: GPUIndexFormat;
  81438. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  81439. }
  81440. interface GPULimits {
  81441. maxBindGroups?: number;
  81442. maxDynamicUniformBuffersPerPipelineLayout?: number;
  81443. maxDynamicStorageBuffersPerPipelineLayout?: number;
  81444. maxSampledTexturesPerShaderStage?: number;
  81445. maxSamplersPerShaderStage?: number;
  81446. maxStorageBuffersPerShaderStage?: number;
  81447. maxStorageTexturesPerShaderStage?: number;
  81448. maxUniformBuffersPerShaderStage?: number;
  81449. maxUniformBufferBindingSize?: number;
  81450. }
  81451. interface GPUPipelineDescriptorBase {
  81452. label?: string;
  81453. layout?: GPUPipelineLayout;
  81454. }
  81455. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  81456. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  81457. }
  81458. interface GPUProgrammableStageDescriptor {
  81459. module: GPUShaderModule;
  81460. entryPoint: string;
  81461. }
  81462. interface GPURasterizationStateDescriptor {
  81463. frontFace?: GPUFrontFace;
  81464. cullMode?: GPUCullMode;
  81465. clampDepth?: boolean;
  81466. depthBias?: number;
  81467. depthBiasSlopeScale?: number;
  81468. depthBiasClamp?: number;
  81469. }
  81470. interface GPURenderPassColorAttachmentDescriptor {
  81471. attachment: GPUTextureView;
  81472. resolveTarget?: GPUTextureView;
  81473. loadValue: GPULoadOp | GPUColor;
  81474. storeOp?: GPUStoreOp;
  81475. }
  81476. interface GPURenderPassDepthStencilAttachmentDescriptor {
  81477. attachment: GPUTextureView;
  81478. depthLoadValue: GPULoadOp | number;
  81479. depthStoreOp: GPUStoreOp;
  81480. depthReadOnly?: boolean;
  81481. stencilLoadValue: GPULoadOp | number;
  81482. stencilStoreOp: GPUStoreOp;
  81483. stencilReadOnly?: boolean;
  81484. }
  81485. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  81486. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  81487. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  81488. }
  81489. interface GPURenderPipelineDescriptor
  81490. extends GPUPipelineDescriptorBase {
  81491. vertexStage: GPUProgrammableStageDescriptor;
  81492. fragmentStage?: GPUProgrammableStageDescriptor;
  81493. primitiveTopology: GPUPrimitiveTopology;
  81494. rasterizationState?: GPURasterizationStateDescriptor;
  81495. colorStates: Iterable<GPUColorStateDescriptor>;
  81496. depthStencilState?: GPUDepthStencilStateDescriptor;
  81497. vertexState?: GPUVertexStateDescriptor;
  81498. sampleCount?: number;
  81499. sampleMask?: number;
  81500. alphaToCoverageEnabled?: boolean;
  81501. }
  81502. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  81503. addressModeU?: GPUAddressMode;
  81504. addressModeV?: GPUAddressMode;
  81505. addressModeW?: GPUAddressMode;
  81506. magFilter?: GPUFilterMode;
  81507. minFilter?: GPUFilterMode;
  81508. mipmapFilter?: GPUFilterMode;
  81509. lodMinClamp?: number;
  81510. lodMaxClamp?: number;
  81511. compare?: GPUCompareFunction;
  81512. maxAnisotropy?: number;
  81513. }
  81514. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  81515. code: Uint32Array | string;
  81516. label?: string;
  81517. sourceMap?: object;
  81518. }
  81519. interface GPUStencilStateFaceDescriptor {
  81520. compare?: GPUCompareFunction;
  81521. depthFailOp?: GPUStencilOperation;
  81522. passOp?: GPUStencilOperation;
  81523. failOp?: GPUStencilOperation;
  81524. }
  81525. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  81526. device: GPUDevice;
  81527. format: GPUTextureFormat;
  81528. usage?: GPUTextureUsageFlags;
  81529. }
  81530. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  81531. size: GPUExtent3D;
  81532. mipLevelCount?: number;
  81533. sampleCount?: number;
  81534. dimension?: GPUTextureDimension;
  81535. format: GPUTextureFormat;
  81536. usage: GPUTextureUsageFlags;
  81537. }
  81538. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  81539. format?: GPUTextureFormat;
  81540. dimension?: GPUTextureViewDimension;
  81541. aspect?: GPUTextureAspect;
  81542. baseArrayLayer?: number;
  81543. baseMipLevel?: number;
  81544. arrayLayerCount?: number;
  81545. mipLevelCount?: number;
  81546. }
  81547. declare class GPUAdapter {
  81548. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  81549. private __brand: void;
  81550. readonly name: string;
  81551. readonly extensions: GPUExtensionName[];
  81552. readonly limits: Required<GPULimits>;
  81553. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  81554. }
  81555. declare class GPUBindGroup implements GPUObjectBase {
  81556. private __brand: void;
  81557. label: string | undefined;
  81558. }
  81559. declare class GPUBindGroupLayout implements GPUObjectBase {
  81560. private __brand: void;
  81561. label: string | undefined;
  81562. }
  81563. declare class GPUBuffer implements GPUObjectBase {
  81564. private __brand: void;
  81565. label: string | undefined;
  81566. destroy(): void;
  81567. unmap(): void;
  81568. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  81569. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  81570. }
  81571. declare class GPUCommandBuffer implements GPUObjectBase {
  81572. private __brand: void;
  81573. label: string | undefined;
  81574. readonly executionTime: Promise<number>;
  81575. }
  81576. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  81577. declare class GPUCommandEncoder implements GPUObjectBase {
  81578. private __brand: void;
  81579. label: string | undefined;
  81580. beginComputePass(
  81581. descriptor?: GPUComputePassDescriptor
  81582. ): GPUComputePassEncoder;
  81583. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  81584. copyBufferToBuffer(
  81585. source: GPUBuffer,
  81586. sourceOffset: number,
  81587. destination: GPUBuffer,
  81588. destinationOffset: number,
  81589. size: number
  81590. ): void;
  81591. copyBufferToTexture(
  81592. source: GPUBufferCopyView,
  81593. destination: GPUTextureCopyView,
  81594. copySize: GPUExtent3D
  81595. ): void;
  81596. copyTextureToBuffer(
  81597. source: GPUTextureCopyView,
  81598. destination: GPUBufferCopyView,
  81599. copySize: GPUExtent3D
  81600. ): void;
  81601. copyTextureToTexture(
  81602. source: GPUTextureCopyView,
  81603. destination: GPUTextureCopyView,
  81604. copySize: GPUExtent3D
  81605. ): void;
  81606. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  81607. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81608. popDebugGroup(): void;
  81609. pushDebugGroup(groupLabel: string): void;
  81610. insertDebugMarker(markerLabel: string): void;
  81611. }
  81612. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  81613. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  81614. private __brand: void;
  81615. label: string | undefined;
  81616. setBindGroup(
  81617. index: number,
  81618. bindGroup: GPUBindGroup,
  81619. dynamicOffsets?: Iterable<number>
  81620. ): void;
  81621. popDebugGroup(): void;
  81622. pushDebugGroup(groupLabel: string): void;
  81623. insertDebugMarker(markerLabel: string): void;
  81624. setPipeline(pipeline: GPUComputePipeline): void;
  81625. dispatch(x: number, y?: number, z?: number): void;
  81626. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81627. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81628. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81629. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81630. endPass(): void;
  81631. }
  81632. declare class GPUComputePipeline implements GPUPipelineBase {
  81633. private __brand: void;
  81634. label: string | undefined;
  81635. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81636. }
  81637. interface GPUObjectBase {
  81638. label: string | undefined;
  81639. }
  81640. interface GPUObjectDescriptorBase {
  81641. label?: string;
  81642. }
  81643. // SwapChain / CanvasContext
  81644. declare class GPUCanvasContext {
  81645. private __brand: void;
  81646. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  81647. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  81648. }
  81649. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  81650. private __brand: void;
  81651. label: string | undefined;
  81652. readonly adapter: GPUAdapter;
  81653. readonly extensions: GPUExtensionName[];
  81654. readonly limits: Required<GPULimits>;
  81655. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  81656. createBindGroupLayout(
  81657. descriptor: GPUBindGroupLayoutDescriptor
  81658. ): GPUBindGroupLayout;
  81659. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81660. createPipelineLayout(
  81661. descriptor: GPUPipelineLayoutDescriptor
  81662. ): GPUPipelineLayout;
  81663. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81664. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81665. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81666. createComputePipeline(
  81667. descriptor: GPUComputePipelineDescriptor
  81668. ): GPUComputePipeline;
  81669. createRenderPipeline(
  81670. descriptor: GPURenderPipelineDescriptor
  81671. ): GPURenderPipeline;
  81672. createReadyComputePipeline(
  81673. descriptor: GPUComputePipelineDescriptor
  81674. ): Promise<GPUComputePipeline>;
  81675. createReadyRenderPipeline(
  81676. descriptor: GPURenderPipelineDescriptor
  81677. ): Promise<GPURenderPipeline>;
  81678. createCommandEncoder(
  81679. descriptor?: GPUCommandEncoderDescriptor
  81680. ): GPUCommandEncoder;
  81681. createRenderBundleEncoder(
  81682. descriptor: GPURenderBundleEncoderDescriptor
  81683. ): GPURenderBundleEncoder;
  81684. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81685. defaultQueue: GPUQueue;
  81686. pushErrorScope(filter: GPUErrorFilter): void;
  81687. popErrorScope(): Promise<GPUError | null>;
  81688. onuncapturederror: Event | undefined;
  81689. readonly lost: Promise<GPUDeviceLostInfo>;
  81690. }
  81691. declare class GPUFence implements GPUObjectBase {
  81692. private __brand: void;
  81693. label: string | undefined;
  81694. getCompletedValue(): number;
  81695. onCompletion(completionValue: number): Promise<void>;
  81696. }
  81697. interface GPUPipelineBase extends GPUObjectBase {
  81698. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81699. }
  81700. declare class GPUPipelineLayout implements GPUObjectBase {
  81701. private __brand: void;
  81702. label: string | undefined;
  81703. }
  81704. interface GPUProgrammablePassEncoder {
  81705. setBindGroup(
  81706. index: number,
  81707. bindGroup: GPUBindGroup,
  81708. dynamicOffsets?: Iterable<number>
  81709. ): void;
  81710. popDebugGroup(): void;
  81711. pushDebugGroup(groupLabel: string): void;
  81712. insertDebugMarker(markerLabel: string): void;
  81713. }
  81714. declare class GPUQueue implements GPUObjectBase {
  81715. private __brand: void;
  81716. label: string | undefined;
  81717. signal(fence: GPUFence, signalValue: number): void;
  81718. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81719. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81720. writeBuffer(buffer: GPUBuffer,
  81721. bufferOffset: number,
  81722. data: BufferSource | ArrayBuffer,
  81723. dataOffset?: number,
  81724. size?: number): void;
  81725. writeTexture(destination: GPUTextureCopyView,
  81726. data: BufferSource | ArrayBuffer,
  81727. dataLayout: GPUTextureDataLayout,
  81728. size: GPUExtent3D): void;
  81729. copyImageBitmapToTexture(
  81730. source: GPUImageBitmapCopyView,
  81731. destination: GPUTextureCopyView,
  81732. copySize: GPUExtent3D
  81733. ): void;
  81734. }
  81735. type GPUQueryType =
  81736. | "occlusion"
  81737. | "timestamp"
  81738. | "pipeline-statistics";
  81739. type GPUPipelineStatisticName =
  81740. | "vertex-shader-invocations"
  81741. | "clipper-invocations"
  81742. | "clipper-primitives-out"
  81743. | "fragment-shader-invocations"
  81744. | "compute-shader-invocations";
  81745. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81746. type: GPUQueryType;
  81747. count: number;
  81748. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81749. }
  81750. declare class GPUQuerySet implements GPUObjectBase {
  81751. private __brand: void;
  81752. label: string | undefined;
  81753. destroy(): void;
  81754. }
  81755. interface GPURenderEncoderBase {
  81756. setPipeline(pipeline: GPURenderPipeline): void;
  81757. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81758. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81759. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81760. draw(
  81761. vertexCount: number,
  81762. instanceCount?: number,
  81763. firstVertex?: number,
  81764. firstInstance?: number
  81765. ): void;
  81766. drawIndexed(
  81767. indexCount: number,
  81768. instanceCount?: number,
  81769. firstIndex?: number,
  81770. baseVertex?: number,
  81771. firstInstance?: number
  81772. ): void;
  81773. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81774. drawIndexedIndirect(
  81775. indirectBuffer: GPUBuffer,
  81776. indirectOffset: number
  81777. ): void;
  81778. }
  81779. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81780. private __brand: void;
  81781. label: string | undefined;
  81782. setBindGroup(
  81783. index: number,
  81784. bindGroup: GPUBindGroup,
  81785. dynamicOffsets?: Iterable<number>
  81786. ): void;
  81787. popDebugGroup(): void;
  81788. pushDebugGroup(groupLabel: string): void;
  81789. insertDebugMarker(markerLabel: string): void;
  81790. setPipeline(pipeline: GPURenderPipeline): void;
  81791. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81792. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81793. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81794. draw(
  81795. vertexCount: number,
  81796. instanceCount?: number,
  81797. firstVertex?: number,
  81798. firstInstance?: number
  81799. ): void;
  81800. drawIndexed(
  81801. indexCount: number,
  81802. instanceCount?: number,
  81803. firstIndex?: number,
  81804. baseVertex?: number,
  81805. firstInstance?: number
  81806. ): void;
  81807. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81808. drawIndexedIndirect(
  81809. indirectBuffer: GPUBuffer,
  81810. indirectOffset: number
  81811. ): void;
  81812. setViewport(
  81813. x: number,
  81814. y: number,
  81815. width: number,
  81816. height: number,
  81817. minDepth: number,
  81818. maxDepth: number
  81819. ): void;
  81820. setScissorRect(x: number, y: number, width: number, height: number): void;
  81821. setBlendColor(color: GPUColor): void;
  81822. setStencilReference(reference: number): void;
  81823. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81824. beginOcclusionQuery(queryIndex: number): void;
  81825. endOcclusionQuery(): void;
  81826. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81827. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81828. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81829. endPass(): void;
  81830. }
  81831. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81832. declare class GPURenderBundle implements GPUObjectBase {
  81833. private __brand: void;
  81834. label: string | undefined;
  81835. }
  81836. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81837. private __brand: void;
  81838. label: string | undefined;
  81839. setBindGroup(
  81840. index: number,
  81841. bindGroup: GPUBindGroup,
  81842. dynamicOffsets?: Iterable<number>
  81843. ): void;
  81844. popDebugGroup(): void;
  81845. pushDebugGroup(groupLabel: string): void;
  81846. insertDebugMarker(markerLabel: string): void;
  81847. setPipeline(pipeline: GPURenderPipeline): void;
  81848. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81849. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81850. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81851. draw(
  81852. vertexCount: number,
  81853. instanceCount?: number,
  81854. firstVertex?: number,
  81855. firstInstance?: number
  81856. ): void;
  81857. drawIndexed(
  81858. indexCount: number,
  81859. instanceCount?: number,
  81860. firstIndex?: number,
  81861. baseVertex?: number,
  81862. firstInstance?: number
  81863. ): void;
  81864. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81865. drawIndexedIndirect(
  81866. indirectBuffer: GPUBuffer,
  81867. indirectOffset: number
  81868. ): void;
  81869. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81870. }
  81871. interface GPURenderBundleEncoderDescriptor
  81872. extends GPUObjectDescriptorBase {
  81873. colorFormats: Iterable<GPUTextureFormat>;
  81874. depthStencilFormat?: GPUTextureFormat;
  81875. sampleCount?: number;
  81876. }
  81877. declare class GPURenderPipeline implements GPUPipelineBase {
  81878. private __brand: void;
  81879. label: string | undefined;
  81880. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81881. }
  81882. declare class GPUSampler implements GPUObjectBase {
  81883. private __brand: void;
  81884. label: string | undefined;
  81885. }
  81886. type GPUCompilationMessageType =
  81887. | "error"
  81888. | "warning"
  81889. | "info";
  81890. interface GPUCompilationMessage {
  81891. readonly message: string;
  81892. readonly type: GPUCompilationMessageType;
  81893. readonly lineNum: number;
  81894. readonly linePos: number;
  81895. }
  81896. interface GPUCompilationInfo {
  81897. readonly messages: readonly GPUCompilationMessage[];
  81898. }
  81899. declare class GPUShaderModule implements GPUObjectBase {
  81900. private __brand: void;
  81901. label: string | undefined;
  81902. compilationInfo(): Promise<GPUCompilationInfo>;
  81903. }
  81904. declare class GPUSwapChain implements GPUObjectBase {
  81905. private __brand: void;
  81906. label: string | undefined;
  81907. getCurrentTexture(): GPUTexture;
  81908. }
  81909. declare class GPUTexture implements GPUObjectBase {
  81910. private __brand: void;
  81911. label: string | undefined;
  81912. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81913. destroy(): void;
  81914. }
  81915. declare class GPUTextureView implements GPUObjectBase {
  81916. private __brand: void;
  81917. label: string | undefined;
  81918. }
  81919. type GPUPowerPreference = "low-power" | "high-performance";
  81920. interface GPURequestAdapterOptions {
  81921. powerPreference?: GPUPowerPreference;
  81922. }
  81923. declare class GPU {
  81924. private __brand: void;
  81925. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81926. }
  81927. // ****************************************************************************
  81928. // ERROR SCOPES
  81929. // ****************************************************************************
  81930. type GPUErrorFilter = "out-of-memory" | "validation";
  81931. declare class GPUOutOfMemoryError {
  81932. private __brand: void;
  81933. constructor();
  81934. }
  81935. declare class GPUValidationError {
  81936. private __brand: void;
  81937. constructor(message: string);
  81938. readonly message: string;
  81939. }
  81940. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81941. // ****************************************************************************
  81942. // TELEMETRY
  81943. // ****************************************************************************
  81944. declare class GPUUncapturedErrorEvent extends Event {
  81945. private __brand: void;
  81946. constructor(
  81947. type: string,
  81948. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81949. );
  81950. readonly error: GPUError;
  81951. }
  81952. interface GPUUncapturedErrorEventInit extends EventInit {
  81953. error: GPUError;
  81954. }
  81955. declare class GPUDeviceLostInfo {
  81956. private __brand: void;
  81957. readonly message: string;
  81958. }
  81959. // Type definitions for WebVR API
  81960. // Project: https://w3c.github.io/webvr/
  81961. // Definitions by: six a <https://github.com/lostfictions>
  81962. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81963. interface VRDisplay extends EventTarget {
  81964. /**
  81965. * Dictionary of capabilities describing the VRDisplay.
  81966. */
  81967. readonly capabilities: VRDisplayCapabilities;
  81968. /**
  81969. * z-depth defining the far plane of the eye view frustum
  81970. * enables mapping of values in the render target depth
  81971. * attachment to scene coordinates. Initially set to 10000.0.
  81972. */
  81973. depthFar: number;
  81974. /**
  81975. * z-depth defining the near plane of the eye view frustum
  81976. * enables mapping of values in the render target depth
  81977. * attachment to scene coordinates. Initially set to 0.01.
  81978. */
  81979. depthNear: number;
  81980. /**
  81981. * An identifier for this distinct VRDisplay. Used as an
  81982. * association point in the Gamepad API.
  81983. */
  81984. readonly displayId: number;
  81985. /**
  81986. * A display name, a user-readable name identifying it.
  81987. */
  81988. readonly displayName: string;
  81989. readonly isConnected: boolean;
  81990. readonly isPresenting: boolean;
  81991. /**
  81992. * If this VRDisplay supports room-scale experiences, the optional
  81993. * stage attribute contains details on the room-scale parameters.
  81994. */
  81995. readonly stageParameters: VRStageParameters | null;
  81996. /**
  81997. * Passing the value returned by `requestAnimationFrame` to
  81998. * `cancelAnimationFrame` will unregister the callback.
  81999. * @param handle Define the hanle of the request to cancel
  82000. */
  82001. cancelAnimationFrame(handle: number): void;
  82002. /**
  82003. * Stops presenting to the VRDisplay.
  82004. * @returns a promise to know when it stopped
  82005. */
  82006. exitPresent(): Promise<void>;
  82007. /**
  82008. * Return the current VREyeParameters for the given eye.
  82009. * @param whichEye Define the eye we want the parameter for
  82010. * @returns the eye parameters
  82011. */
  82012. getEyeParameters(whichEye: string): VREyeParameters;
  82013. /**
  82014. * Populates the passed VRFrameData with the information required to render
  82015. * the current frame.
  82016. * @param frameData Define the data structure to populate
  82017. * @returns true if ok otherwise false
  82018. */
  82019. getFrameData(frameData: VRFrameData): boolean;
  82020. /**
  82021. * Get the layers currently being presented.
  82022. * @returns the list of VR layers
  82023. */
  82024. getLayers(): VRLayer[];
  82025. /**
  82026. * Return a VRPose containing the future predicted pose of the VRDisplay
  82027. * when the current frame will be presented. The value returned will not
  82028. * change until JavaScript has returned control to the browser.
  82029. *
  82030. * The VRPose will contain the position, orientation, velocity,
  82031. * and acceleration of each of these properties.
  82032. * @returns the pose object
  82033. */
  82034. getPose(): VRPose;
  82035. /**
  82036. * Return the current instantaneous pose of the VRDisplay, with no
  82037. * prediction applied.
  82038. * @returns the current instantaneous pose
  82039. */
  82040. getImmediatePose(): VRPose;
  82041. /**
  82042. * The callback passed to `requestAnimationFrame` will be called
  82043. * any time a new frame should be rendered. When the VRDisplay is
  82044. * presenting the callback will be called at the native refresh
  82045. * rate of the HMD. When not presenting this function acts
  82046. * identically to how window.requestAnimationFrame acts. Content should
  82047. * make no assumptions of frame rate or vsync behavior as the HMD runs
  82048. * asynchronously from other displays and at differing refresh rates.
  82049. * @param callback Define the action to run next frame
  82050. * @returns the request handle it
  82051. */
  82052. requestAnimationFrame(callback: FrameRequestCallback): number;
  82053. /**
  82054. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  82055. * Repeat calls while already presenting will update the VRLayers being displayed.
  82056. * @param layers Define the list of layer to present
  82057. * @returns a promise to know when the request has been fulfilled
  82058. */
  82059. requestPresent(layers: VRLayer[]): Promise<void>;
  82060. /**
  82061. * Reset the pose for this display, treating its current position and
  82062. * orientation as the "origin/zero" values. VRPose.position,
  82063. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  82064. * updated when calling resetPose(). This should be called in only
  82065. * sitting-space experiences.
  82066. */
  82067. resetPose(): void;
  82068. /**
  82069. * The VRLayer provided to the VRDisplay will be captured and presented
  82070. * in the HMD. Calling this function has the same effect on the source
  82071. * canvas as any other operation that uses its source image, and canvases
  82072. * created without preserveDrawingBuffer set to true will be cleared.
  82073. * @param pose Define the pose to submit
  82074. */
  82075. submitFrame(pose?: VRPose): void;
  82076. }
  82077. declare var VRDisplay: {
  82078. prototype: VRDisplay;
  82079. new(): VRDisplay;
  82080. };
  82081. interface VRLayer {
  82082. leftBounds?: number[] | Float32Array | null;
  82083. rightBounds?: number[] | Float32Array | null;
  82084. source?: HTMLCanvasElement | null;
  82085. }
  82086. interface VRDisplayCapabilities {
  82087. readonly canPresent: boolean;
  82088. readonly hasExternalDisplay: boolean;
  82089. readonly hasOrientation: boolean;
  82090. readonly hasPosition: boolean;
  82091. readonly maxLayers: number;
  82092. }
  82093. interface VREyeParameters {
  82094. /** @deprecated */
  82095. readonly fieldOfView: VRFieldOfView;
  82096. readonly offset: Float32Array;
  82097. readonly renderHeight: number;
  82098. readonly renderWidth: number;
  82099. }
  82100. interface VRFieldOfView {
  82101. readonly downDegrees: number;
  82102. readonly leftDegrees: number;
  82103. readonly rightDegrees: number;
  82104. readonly upDegrees: number;
  82105. }
  82106. interface VRFrameData {
  82107. readonly leftProjectionMatrix: Float32Array;
  82108. readonly leftViewMatrix: Float32Array;
  82109. readonly pose: VRPose;
  82110. readonly rightProjectionMatrix: Float32Array;
  82111. readonly rightViewMatrix: Float32Array;
  82112. readonly timestamp: number;
  82113. }
  82114. interface VRPose {
  82115. readonly angularAcceleration: Float32Array | null;
  82116. readonly angularVelocity: Float32Array | null;
  82117. readonly linearAcceleration: Float32Array | null;
  82118. readonly linearVelocity: Float32Array | null;
  82119. readonly orientation: Float32Array | null;
  82120. readonly position: Float32Array | null;
  82121. readonly timestamp: number;
  82122. }
  82123. interface VRStageParameters {
  82124. sittingToStandingTransform?: Float32Array;
  82125. sizeX?: number;
  82126. sizeY?: number;
  82127. }
  82128. interface Navigator {
  82129. getVRDisplays(): Promise<VRDisplay[]>;
  82130. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  82131. }
  82132. interface Window {
  82133. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  82134. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  82135. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  82136. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82137. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  82138. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  82139. }
  82140. interface Gamepad {
  82141. readonly displayId: number;
  82142. }
  82143. /**
  82144. * Available session modes
  82145. */
  82146. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  82147. /**
  82148. * Reference space types
  82149. */
  82150. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  82151. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  82152. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  82153. /**
  82154. * Handedness types
  82155. */
  82156. type XRHandedness = "none" | "left" | "right";
  82157. /**
  82158. * InputSource target ray modes
  82159. */
  82160. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  82161. /**
  82162. * Eye types
  82163. */
  82164. type XREye = "none" | "left" | "right";
  82165. /**
  82166. * Type of XR events available
  82167. */
  82168. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  82169. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  82170. type XRPlaneSet = Set<XRPlane>;
  82171. type XRAnchorSet = Set<XRAnchor>;
  82172. type XREventHandler = (callback: any) => void;
  82173. interface XRLayer extends EventTarget {}
  82174. interface XRSessionInit {
  82175. optionalFeatures?: string[];
  82176. requiredFeatures?: string[];
  82177. trackedImages?: XRTrackedImageInit[];
  82178. }
  82179. interface XRSessionEvent extends Event {
  82180. readonly session: XRSession;
  82181. }
  82182. interface XRSystem {
  82183. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  82184. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  82185. }
  82186. interface XRViewport {
  82187. readonly x: number;
  82188. readonly y: number;
  82189. readonly width: number;
  82190. readonly height: number;
  82191. }
  82192. interface XRWebGLLayerInit {
  82193. antialias?: boolean;
  82194. depth?: boolean;
  82195. stencil?: boolean;
  82196. alpha?: boolean;
  82197. multiview?: boolean;
  82198. framebufferScaleFactor?: number;
  82199. }
  82200. declare class XRWebGLLayer {
  82201. static getNativeFramebufferScaleFactor(session: XRSession): number;
  82202. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  82203. readonly antialias: boolean;
  82204. readonly framebuffer: WebGLFramebuffer;
  82205. readonly framebufferWidth: number;
  82206. readonly framebufferHeight: number;
  82207. readonly ignoreDepthValues: boolean;
  82208. getViewport: (view: XRView) => XRViewport;
  82209. }
  82210. // tslint:disable-next-line no-empty-interface
  82211. interface XRSpace extends EventTarget {}
  82212. interface XRRenderState {
  82213. readonly baseLayer?: XRWebGLLayer;
  82214. readonly depthFar: number;
  82215. readonly depthNear: number;
  82216. readonly inlineVerticalFieldOfView?: number;
  82217. }
  82218. interface XRRenderStateInit extends XRRenderState {
  82219. baseLayer: XRWebGLLayer;
  82220. depthFar: number;
  82221. depthNear: number;
  82222. inlineVerticalFieldOfView?: number;
  82223. layers?: XRLayer[];
  82224. }
  82225. interface XRReferenceSpace extends XRSpace {
  82226. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  82227. onreset: XREventHandler;
  82228. }
  82229. interface XRBoundedReferenceSpace extends XRSpace {
  82230. readonly boundsGeometry: DOMPointReadOnly[];
  82231. }
  82232. interface XRInputSource {
  82233. readonly handedness: XRHandedness;
  82234. readonly targetRayMode: XRTargetRayMode;
  82235. readonly targetRaySpace: XRSpace;
  82236. readonly gripSpace?: XRSpace;
  82237. readonly gamepad?: Gamepad;
  82238. readonly profiles: Array<string>;
  82239. readonly hand?: XRHand;
  82240. }
  82241. interface XRPose {
  82242. readonly transform: XRRigidTransform;
  82243. readonly emulatedPosition: boolean;
  82244. }
  82245. interface XRWorldInformation {
  82246. detectedPlanes?: XRPlaneSet;
  82247. }
  82248. interface XRFrame {
  82249. readonly session: XRSession;
  82250. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  82251. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  82252. // AR
  82253. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  82254. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  82255. // Anchors
  82256. trackedAnchors?: XRAnchorSet;
  82257. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  82258. // World geometries
  82259. worldInformation?: XRWorldInformation;
  82260. // Hand tracking
  82261. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  82262. // Image tracking
  82263. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  82264. }
  82265. interface XRInputSourceEvent extends Event {
  82266. readonly frame: XRFrame;
  82267. readonly inputSource: XRInputSource;
  82268. }
  82269. type XRInputSourceArray = XRInputSource[];
  82270. interface XRSession {
  82271. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  82272. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  82273. /**
  82274. * Returns a list of this session's XRInputSources, each representing an input device
  82275. * used to control the camera and/or scene.
  82276. */
  82277. readonly inputSources: Array<XRInputSource>;
  82278. /**
  82279. * object which contains options affecting how the imagery is rendered.
  82280. * This includes things such as the near and far clipping planes
  82281. */
  82282. readonly renderState: XRRenderState;
  82283. readonly visibilityState: XRVisibilityState;
  82284. /**
  82285. * Removes a callback from the animation frame painting callback from
  82286. * XRSession's set of animation frame rendering callbacks, given the
  82287. * identifying handle returned by a previous call to requestAnimationFrame().
  82288. */
  82289. cancelAnimationFrame: (handle: number) => void;
  82290. /**
  82291. * Ends the WebXR session. Returns a promise which resolves when the
  82292. * session has been shut down.
  82293. */
  82294. end(): Promise<void>;
  82295. /**
  82296. * Schedules the specified method to be called the next time the user agent
  82297. * is working on rendering an animation frame for the WebXR device. Returns an
  82298. * integer value which can be used to identify the request for the purposes of
  82299. * canceling the callback using cancelAnimationFrame(). This method is comparable
  82300. * to the Window.requestAnimationFrame() method.
  82301. */
  82302. requestAnimationFrame: XRFrameRequestCallback;
  82303. /**
  82304. * Requests that a new XRReferenceSpace of the specified type be created.
  82305. * Returns a promise which resolves with the XRReferenceSpace or
  82306. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  82307. * the requested space type isn't supported by the device.
  82308. */
  82309. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  82310. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  82311. onend: XREventHandler;
  82312. oninputsourceschange: XREventHandler;
  82313. onselect: XREventHandler;
  82314. onselectstart: XREventHandler;
  82315. onselectend: XREventHandler;
  82316. onsqueeze: XREventHandler;
  82317. onsqueezestart: XREventHandler;
  82318. onsqueezeend: XREventHandler;
  82319. onvisibilitychange: XREventHandler;
  82320. // hit test
  82321. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  82322. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  82323. // legacy AR hit test
  82324. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  82325. // legacy plane detection
  82326. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  82327. // image tracking
  82328. getTrackedImageScores?(): XRImageTrackingScore[];
  82329. }
  82330. interface XRViewerPose extends XRPose {
  82331. readonly views: Array<XRView>;
  82332. }
  82333. declare class XRRigidTransform {
  82334. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  82335. position: DOMPointReadOnly;
  82336. orientation: DOMPointReadOnly;
  82337. matrix: Float32Array;
  82338. inverse: XRRigidTransform;
  82339. }
  82340. interface XRView {
  82341. readonly eye: XREye;
  82342. readonly projectionMatrix: Float32Array;
  82343. readonly transform: XRRigidTransform;
  82344. readonly recommendedViewportScale?: number;
  82345. requestViewportScale(scale: number): void;
  82346. }
  82347. interface XRInputSourceChangeEvent extends Event {
  82348. session: XRSession;
  82349. removed: Array<XRInputSource>;
  82350. added: Array<XRInputSource>;
  82351. }
  82352. // Experimental/Draft features
  82353. declare class XRRay {
  82354. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  82355. origin: DOMPointReadOnly;
  82356. direction: DOMPointReadOnly;
  82357. matrix: Float32Array;
  82358. }
  82359. declare enum XRHitTestTrackableType {
  82360. "point",
  82361. "plane",
  82362. "mesh",
  82363. }
  82364. interface XRHitResult {
  82365. hitMatrix: Float32Array;
  82366. }
  82367. interface XRTransientInputHitTestResult {
  82368. readonly inputSource: XRInputSource;
  82369. readonly results: Array<XRHitTestResult>;
  82370. }
  82371. interface XRHitTestResult {
  82372. getPose(baseSpace: XRSpace): XRPose | undefined;
  82373. // When anchor system is enabled
  82374. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  82375. }
  82376. interface XRHitTestSource {
  82377. cancel(): void;
  82378. }
  82379. interface XRTransientInputHitTestSource {
  82380. cancel(): void;
  82381. }
  82382. interface XRHitTestOptionsInit {
  82383. space: XRSpace;
  82384. entityTypes?: Array<XRHitTestTrackableType>;
  82385. offsetRay?: XRRay;
  82386. }
  82387. interface XRTransientInputHitTestOptionsInit {
  82388. profile: string;
  82389. entityTypes?: Array<XRHitTestTrackableType>;
  82390. offsetRay?: XRRay;
  82391. }
  82392. interface XRAnchor {
  82393. anchorSpace: XRSpace;
  82394. delete(): void;
  82395. }
  82396. interface XRPlane {
  82397. orientation: "Horizontal" | "Vertical";
  82398. planeSpace: XRSpace;
  82399. polygon: Array<DOMPointReadOnly>;
  82400. lastChangedTime: number;
  82401. }
  82402. interface XRJointSpace extends XRSpace {}
  82403. interface XRJointPose extends XRPose {
  82404. radius: number | undefined;
  82405. }
  82406. interface XRHand extends Iterable<XRJointSpace> {
  82407. readonly length: number;
  82408. [index: number]: XRJointSpace;
  82409. readonly WRIST: number;
  82410. readonly THUMB_METACARPAL: number;
  82411. readonly THUMB_PHALANX_PROXIMAL: number;
  82412. readonly THUMB_PHALANX_DISTAL: number;
  82413. readonly THUMB_PHALANX_TIP: number;
  82414. readonly INDEX_METACARPAL: number;
  82415. readonly INDEX_PHALANX_PROXIMAL: number;
  82416. readonly INDEX_PHALANX_INTERMEDIATE: number;
  82417. readonly INDEX_PHALANX_DISTAL: number;
  82418. readonly INDEX_PHALANX_TIP: number;
  82419. readonly MIDDLE_METACARPAL: number;
  82420. readonly MIDDLE_PHALANX_PROXIMAL: number;
  82421. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  82422. readonly MIDDLE_PHALANX_DISTAL: number;
  82423. readonly MIDDLE_PHALANX_TIP: number;
  82424. readonly RING_METACARPAL: number;
  82425. readonly RING_PHALANX_PROXIMAL: number;
  82426. readonly RING_PHALANX_INTERMEDIATE: number;
  82427. readonly RING_PHALANX_DISTAL: number;
  82428. readonly RING_PHALANX_TIP: number;
  82429. readonly LITTLE_METACARPAL: number;
  82430. readonly LITTLE_PHALANX_PROXIMAL: number;
  82431. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  82432. readonly LITTLE_PHALANX_DISTAL: number;
  82433. readonly LITTLE_PHALANX_TIP: number;
  82434. }
  82435. type XRImageTrackingState = "tracked" | "emulated";
  82436. type XRImageTrackingScore = "untrackable" | "trackable";
  82437. interface XRTrackedImageInit {
  82438. image: ImageBitmap;
  82439. widthInMeters: number;
  82440. }
  82441. interface XRImageTrackingResult {
  82442. readonly imageSpace: XRSpace;
  82443. readonly index: number;
  82444. readonly trackingState: XRImageTrackingState;
  82445. readonly measuredWidthInMeters: number;
  82446. }
  82447. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  82448. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  82449. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  82450. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  82451. interface XRSceneObject {
  82452. type: XRSceneObjectType;
  82453. }
  82454. interface XRFieldOfView {
  82455. angleLeft: number;
  82456. angleRight: number;
  82457. angleUp: number;
  82458. angleDown: number;
  82459. }
  82460. interface XRFrustum {
  82461. position: DOMPointReadOnly;
  82462. orientation: DOMPointReadOnly;
  82463. fieldOfView: XRFieldOfView;
  82464. farDistance: number;
  82465. }
  82466. interface XRPlane {
  82467. parentSceneObject?: XRSceneObject;
  82468. }
  82469. interface XRMesh {
  82470. meshSpace: XRSpace;
  82471. positions: Float32Array;
  82472. indices: Uint32Array;
  82473. normals?: Float32Array;
  82474. lastChangedTime: number;
  82475. parentSceneObject?: XRSceneObject;
  82476. }
  82477. interface XRFrustumDetectionBoundary {
  82478. type: "frustum";
  82479. frustum: XRFrustum;
  82480. }
  82481. interface XRSphereDetectionBoundary {
  82482. type: "sphere";
  82483. radius: number;
  82484. }
  82485. interface XRBoxDetectionBoundary {
  82486. type: "box";
  82487. extent: DOMPointReadOnly;
  82488. }
  82489. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  82490. interface XRGeometryDetectorOptions {
  82491. detectionBoundary?: XRDetectionBoundary;
  82492. updateInterval?: number;
  82493. }
  82494. interface XRSession {
  82495. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  82496. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82497. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  82498. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  82499. }
  82500. interface XRFrame {
  82501. featurePointCloud?: Array<number>;
  82502. }
  82503. type XRMeshSet = Set<XRMesh>;
  82504. interface XRWorldInformation {
  82505. detectedMeshes?: XRMeshSet;
  82506. }
  82507. /**
  82508. * @ignore
  82509. */
  82510. declare module BABYLON.GLTF2.Exporter {
  82511. }
  82512. /**
  82513. * @ignore
  82514. */
  82515. declare module BABYLON.GLTF1 {
  82516. }
  82517. declare module BABYLON.GUI {
  82518. /**
  82519. * Interface used to define a control that can receive focus
  82520. */
  82521. export interface IFocusableControl {
  82522. /**
  82523. * Function called when the control receives the focus
  82524. */
  82525. onFocus(): void;
  82526. /**
  82527. * Function called when the control loses the focus
  82528. */
  82529. onBlur(): void;
  82530. /**
  82531. * Function called to let the control handle keyboard events
  82532. * @param evt defines the current keyboard event
  82533. */
  82534. processKeyboard(evt: KeyboardEvent): void;
  82535. /**
  82536. * Function called to get the list of controls that should not steal the focus from this control
  82537. * @returns an array of controls
  82538. */
  82539. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  82540. /**
  82541. * Function to focus the control programmatically
  82542. */
  82543. focus(): void;
  82544. /**
  82545. * Function to unfocus the control programmatically
  82546. */
  82547. blur(): void;
  82548. }
  82549. }
  82550. declare module BABYLON.GUI {
  82551. /**
  82552. * Class used to specific a value and its associated unit
  82553. */
  82554. export class ValueAndUnit {
  82555. /** defines the unit to store */
  82556. unit: number;
  82557. /** defines a boolean indicating if the value can be negative */
  82558. negativeValueAllowed: boolean;
  82559. private _value;
  82560. private _originalUnit;
  82561. /**
  82562. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  82563. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82564. */
  82565. ignoreAdaptiveScaling: boolean;
  82566. /**
  82567. * Creates a new ValueAndUnit
  82568. * @param value defines the value to store
  82569. * @param unit defines the unit to store
  82570. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  82571. */
  82572. constructor(value: number,
  82573. /** defines the unit to store */
  82574. unit?: number,
  82575. /** defines a boolean indicating if the value can be negative */
  82576. negativeValueAllowed?: boolean);
  82577. /** Gets a boolean indicating if the value is a percentage */
  82578. get isPercentage(): boolean;
  82579. /** Gets a boolean indicating if the value is store as pixel */
  82580. get isPixel(): boolean;
  82581. /** Gets direct internal value */
  82582. get internalValue(): number;
  82583. /**
  82584. * Gets value as pixel
  82585. * @param host defines the root host
  82586. * @param refValue defines the reference value for percentages
  82587. * @returns the value as pixel
  82588. */
  82589. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  82590. /**
  82591. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  82592. * @param value defines the value to store
  82593. * @param unit defines the unit to store
  82594. * @returns the current ValueAndUnit
  82595. */
  82596. updateInPlace(value: number, unit?: number): ValueAndUnit;
  82597. /**
  82598. * Gets the value accordingly to its unit
  82599. * @param host defines the root host
  82600. * @returns the value
  82601. */
  82602. getValue(host: AdvancedDynamicTexture): number;
  82603. /**
  82604. * Gets a string representation of the value
  82605. * @param host defines the root host
  82606. * @param decimals defines an optional number of decimals to display
  82607. * @returns a string
  82608. */
  82609. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  82610. /**
  82611. * Store a value parsed from a string
  82612. * @param source defines the source string
  82613. * @returns true if the value was successfully parsed
  82614. */
  82615. fromString(source: string | number): boolean;
  82616. private static _Regex;
  82617. private static _UNITMODE_PERCENTAGE;
  82618. private static _UNITMODE_PIXEL;
  82619. /** UNITMODE_PERCENTAGE */
  82620. static get UNITMODE_PERCENTAGE(): number;
  82621. /** UNITMODE_PIXEL */
  82622. static get UNITMODE_PIXEL(): number;
  82623. }
  82624. }
  82625. declare module BABYLON.GUI {
  82626. /**
  82627. * Define a style used by control to automatically setup properties based on a template.
  82628. * Only support font related properties so far
  82629. */
  82630. export class Style implements BABYLON.IDisposable {
  82631. private _fontFamily;
  82632. private _fontStyle;
  82633. private _fontWeight;
  82634. /** @hidden */
  82635. _host: AdvancedDynamicTexture;
  82636. /** @hidden */
  82637. _fontSize: ValueAndUnit;
  82638. /**
  82639. * BABYLON.Observable raised when the style values are changed
  82640. */
  82641. onChangedObservable: BABYLON.Observable<Style>;
  82642. /**
  82643. * Creates a new style object
  82644. * @param host defines the AdvancedDynamicTexture which hosts this style
  82645. */
  82646. constructor(host: AdvancedDynamicTexture);
  82647. /**
  82648. * Gets or sets the font size
  82649. */
  82650. get fontSize(): string | number;
  82651. set fontSize(value: string | number);
  82652. /**
  82653. * Gets or sets the font family
  82654. */
  82655. get fontFamily(): string;
  82656. set fontFamily(value: string);
  82657. /**
  82658. * Gets or sets the font style
  82659. */
  82660. get fontStyle(): string;
  82661. set fontStyle(value: string);
  82662. /** Gets or sets font weight */
  82663. get fontWeight(): string;
  82664. set fontWeight(value: string);
  82665. /** Dispose all associated resources */
  82666. dispose(): void;
  82667. }
  82668. }
  82669. declare module BABYLON.GUI {
  82670. /**
  82671. * Class used to transport BABYLON.Vector2 information for pointer events
  82672. */
  82673. export class Vector2WithInfo extends BABYLON.Vector2 {
  82674. /** defines the current mouse button index */
  82675. buttonIndex: number;
  82676. /**
  82677. * Creates a new Vector2WithInfo
  82678. * @param source defines the vector2 data to transport
  82679. * @param buttonIndex defines the current mouse button index
  82680. */
  82681. constructor(source: BABYLON.Vector2,
  82682. /** defines the current mouse button index */
  82683. buttonIndex?: number);
  82684. }
  82685. /** Class used to provide 2D matrix features */
  82686. export class Matrix2D {
  82687. /** Gets the internal array of 6 floats used to store matrix data */
  82688. m: Float32Array;
  82689. /**
  82690. * Creates a new matrix
  82691. * @param m00 defines value for (0, 0)
  82692. * @param m01 defines value for (0, 1)
  82693. * @param m10 defines value for (1, 0)
  82694. * @param m11 defines value for (1, 1)
  82695. * @param m20 defines value for (2, 0)
  82696. * @param m21 defines value for (2, 1)
  82697. */
  82698. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82699. /**
  82700. * Fills the matrix from direct values
  82701. * @param m00 defines value for (0, 0)
  82702. * @param m01 defines value for (0, 1)
  82703. * @param m10 defines value for (1, 0)
  82704. * @param m11 defines value for (1, 1)
  82705. * @param m20 defines value for (2, 0)
  82706. * @param m21 defines value for (2, 1)
  82707. * @returns the current modified matrix
  82708. */
  82709. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82710. /**
  82711. * Gets matrix determinant
  82712. * @returns the determinant
  82713. */
  82714. determinant(): number;
  82715. /**
  82716. * Inverses the matrix and stores it in a target matrix
  82717. * @param result defines the target matrix
  82718. * @returns the current matrix
  82719. */
  82720. invertToRef(result: Matrix2D): Matrix2D;
  82721. /**
  82722. * Multiplies the current matrix with another one
  82723. * @param other defines the second operand
  82724. * @param result defines the target matrix
  82725. * @returns the current matrix
  82726. */
  82727. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82728. /**
  82729. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82730. * @param x defines the x coordinate to transform
  82731. * @param y defines the x coordinate to transform
  82732. * @param result defines the target vector2
  82733. * @returns the current matrix
  82734. */
  82735. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82736. /**
  82737. * Creates an identity matrix
  82738. * @returns a new matrix
  82739. */
  82740. static Identity(): Matrix2D;
  82741. /**
  82742. * Creates a translation matrix and stores it in a target matrix
  82743. * @param x defines the x coordinate of the translation
  82744. * @param y defines the y coordinate of the translation
  82745. * @param result defines the target matrix
  82746. */
  82747. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82748. /**
  82749. * Creates a scaling matrix and stores it in a target matrix
  82750. * @param x defines the x coordinate of the scaling
  82751. * @param y defines the y coordinate of the scaling
  82752. * @param result defines the target matrix
  82753. */
  82754. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82755. /**
  82756. * Creates a rotation matrix and stores it in a target matrix
  82757. * @param angle defines the rotation angle
  82758. * @param result defines the target matrix
  82759. */
  82760. static RotationToRef(angle: number, result: Matrix2D): void;
  82761. private static _TempPreTranslationMatrix;
  82762. private static _TempPostTranslationMatrix;
  82763. private static _TempRotationMatrix;
  82764. private static _TempScalingMatrix;
  82765. private static _TempCompose0;
  82766. private static _TempCompose1;
  82767. private static _TempCompose2;
  82768. /**
  82769. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82770. * @param tx defines the x coordinate of the translation
  82771. * @param ty defines the y coordinate of the translation
  82772. * @param angle defines the rotation angle
  82773. * @param scaleX defines the x coordinate of the scaling
  82774. * @param scaleY defines the y coordinate of the scaling
  82775. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82776. * @param result defines the target matrix
  82777. */
  82778. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82779. }
  82780. }
  82781. declare module BABYLON.GUI {
  82782. /**
  82783. * Class used to store 2D control sizes
  82784. */
  82785. export class Measure {
  82786. /** defines left coordinate */
  82787. left: number;
  82788. /** defines top coordinate */
  82789. top: number;
  82790. /** defines width dimension */
  82791. width: number;
  82792. /** defines height dimension */
  82793. height: number;
  82794. /**
  82795. * Creates a new measure
  82796. * @param left defines left coordinate
  82797. * @param top defines top coordinate
  82798. * @param width defines width dimension
  82799. * @param height defines height dimension
  82800. */
  82801. constructor(
  82802. /** defines left coordinate */
  82803. left: number,
  82804. /** defines top coordinate */
  82805. top: number,
  82806. /** defines width dimension */
  82807. width: number,
  82808. /** defines height dimension */
  82809. height: number);
  82810. /**
  82811. * Copy from another measure
  82812. * @param other defines the other measure to copy from
  82813. */
  82814. copyFrom(other: Measure): void;
  82815. /**
  82816. * Copy from a group of 4 floats
  82817. * @param left defines left coordinate
  82818. * @param top defines top coordinate
  82819. * @param width defines width dimension
  82820. * @param height defines height dimension
  82821. */
  82822. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82823. /**
  82824. * Computes the axis aligned bounding box measure for two given measures
  82825. * @param a Input measure
  82826. * @param b Input measure
  82827. * @param result the resulting bounding measure
  82828. */
  82829. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82830. /**
  82831. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82832. * @param transform the matrix to transform the measure before computing the AABB
  82833. * @param addX number to add to left
  82834. * @param addY number to add to top
  82835. * @param addWidth number to add to width
  82836. * @param addHeight number to add to height
  82837. * @param result the resulting AABB
  82838. */
  82839. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82840. /**
  82841. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82842. * @param transform the matrix to transform the measure before computing the AABB
  82843. * @param result the resulting AABB
  82844. */
  82845. transformToRef(transform: Matrix2D, result: Measure): void;
  82846. /**
  82847. * Check equality between this measure and another one
  82848. * @param other defines the other measures
  82849. * @returns true if both measures are equals
  82850. */
  82851. isEqualsTo(other: Measure): boolean;
  82852. /**
  82853. * Creates an empty measure
  82854. * @returns a new measure
  82855. */
  82856. static Empty(): Measure;
  82857. }
  82858. }
  82859. declare module BABYLON.GUI {
  82860. /**
  82861. * Class used to create texture to support 2D GUI elements
  82862. * @see https://doc.babylonjs.com/how_to/gui
  82863. */
  82864. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82865. /** Define the Uurl to load snippets */
  82866. static SnippetUrl: string;
  82867. /** Snippet ID if the content was created from the snippet server */
  82868. snippetId: string;
  82869. private _isDirty;
  82870. private _renderObserver;
  82871. private _resizeObserver;
  82872. private _preKeyboardObserver;
  82873. private _pointerMoveObserver;
  82874. private _pointerObserver;
  82875. private _canvasPointerOutObserver;
  82876. private _canvasBlurObserver;
  82877. private _background;
  82878. /** @hidden */
  82879. _rootContainer: Container;
  82880. /** @hidden */
  82881. _lastPickedControl: Control;
  82882. /** @hidden */
  82883. _lastControlOver: {
  82884. [pointerId: number]: Control;
  82885. };
  82886. /** @hidden */
  82887. _lastControlDown: {
  82888. [pointerId: number]: Control;
  82889. };
  82890. /** @hidden */
  82891. _capturingControl: {
  82892. [pointerId: number]: Control;
  82893. };
  82894. /** @hidden */
  82895. _shouldBlockPointer: boolean;
  82896. /** @hidden */
  82897. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82898. /** @hidden */
  82899. _linkedControls: Control[];
  82900. private _isFullscreen;
  82901. private _fullscreenViewport;
  82902. private _idealWidth;
  82903. private _idealHeight;
  82904. private _useSmallestIdeal;
  82905. private _renderAtIdealSize;
  82906. private _focusedControl;
  82907. private _blockNextFocusCheck;
  82908. private _renderScale;
  82909. private _rootElement;
  82910. private _cursorChanged;
  82911. private _defaultMousePointerId;
  82912. /** @hidden */
  82913. _numLayoutCalls: number;
  82914. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82915. get numLayoutCalls(): number;
  82916. /** @hidden */
  82917. _numRenderCalls: number;
  82918. /** Gets the number of render calls made the last time the ADT has been rendered */
  82919. get numRenderCalls(): number;
  82920. /**
  82921. * Define type to string to ensure compatibility across browsers
  82922. * Safari doesn't support DataTransfer constructor
  82923. */
  82924. private _clipboardData;
  82925. /**
  82926. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82927. */
  82928. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82929. /**
  82930. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82931. */
  82932. onControlPickedObservable: BABYLON.Observable<Control>;
  82933. /**
  82934. * BABYLON.Observable event triggered before layout is evaluated
  82935. */
  82936. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82937. /**
  82938. * BABYLON.Observable event triggered after the layout was evaluated
  82939. */
  82940. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82941. /**
  82942. * BABYLON.Observable event triggered before the texture is rendered
  82943. */
  82944. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82945. /**
  82946. * BABYLON.Observable event triggered after the texture was rendered
  82947. */
  82948. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82949. /**
  82950. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82951. */
  82952. premulAlpha: boolean;
  82953. /**
  82954. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82955. */
  82956. applyYInversionOnUpdate: boolean;
  82957. /**
  82958. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82959. * Useful when you want more antialiasing
  82960. */
  82961. get renderScale(): number;
  82962. set renderScale(value: number);
  82963. /** Gets or sets the background color */
  82964. get background(): string;
  82965. set background(value: string);
  82966. /**
  82967. * Gets or sets the ideal width used to design controls.
  82968. * The GUI will then rescale everything accordingly
  82969. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82970. */
  82971. get idealWidth(): number;
  82972. set idealWidth(value: number);
  82973. /**
  82974. * Gets or sets the ideal height used to design controls.
  82975. * The GUI will then rescale everything accordingly
  82976. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82977. */
  82978. get idealHeight(): number;
  82979. set idealHeight(value: number);
  82980. /**
  82981. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82982. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82983. */
  82984. get useSmallestIdeal(): boolean;
  82985. set useSmallestIdeal(value: boolean);
  82986. /**
  82987. * Gets or sets a boolean indicating if adaptive scaling must be used
  82988. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82989. */
  82990. get renderAtIdealSize(): boolean;
  82991. set renderAtIdealSize(value: boolean);
  82992. /**
  82993. * Gets the ratio used when in "ideal mode"
  82994. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82995. * */
  82996. get idealRatio(): number;
  82997. /**
  82998. * Gets the underlying layer used to render the texture when in fullscreen mode
  82999. */
  83000. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  83001. /**
  83002. * Gets the root container control
  83003. */
  83004. get rootContainer(): Container;
  83005. /**
  83006. * Returns an array containing the root container.
  83007. * This is mostly used to let the Inspector introspects the ADT
  83008. * @returns an array containing the rootContainer
  83009. */
  83010. getChildren(): Array<Container>;
  83011. /**
  83012. * Will return all controls that are inside this texture
  83013. * @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
  83014. * @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
  83015. * @return all child controls
  83016. */
  83017. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83018. /**
  83019. * Gets or sets the current focused control
  83020. */
  83021. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  83022. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  83023. /**
  83024. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  83025. */
  83026. get isForeground(): boolean;
  83027. set isForeground(value: boolean);
  83028. /**
  83029. * Gets or set information about clipboardData
  83030. */
  83031. get clipboardData(): string;
  83032. set clipboardData(value: string);
  83033. /**
  83034. * Creates a new AdvancedDynamicTexture
  83035. * @param name defines the name of the texture
  83036. * @param width defines the width of the texture
  83037. * @param height defines the height of the texture
  83038. * @param scene defines the hosting scene
  83039. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  83040. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83041. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83042. */
  83043. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  83044. /**
  83045. * Get the current class name of the texture useful for serialization or dynamic coding.
  83046. * @returns "AdvancedDynamicTexture"
  83047. */
  83048. getClassName(): string;
  83049. /**
  83050. * Function used to execute a function on all controls
  83051. * @param func defines the function to execute
  83052. * @param container defines the container where controls belong. If null the root container will be used
  83053. */
  83054. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  83055. private _useInvalidateRectOptimization;
  83056. /**
  83057. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  83058. */
  83059. get useInvalidateRectOptimization(): boolean;
  83060. set useInvalidateRectOptimization(value: boolean);
  83061. private _invalidatedRectangle;
  83062. /**
  83063. * Invalidates a rectangle area on the gui texture
  83064. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  83065. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  83066. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  83067. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  83068. */
  83069. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  83070. /**
  83071. * Marks the texture as dirty forcing a complete update
  83072. */
  83073. markAsDirty(): void;
  83074. /**
  83075. * Helper function used to create a new style
  83076. * @returns a new style
  83077. * @see https://doc.babylonjs.com/how_to/gui#styles
  83078. */
  83079. createStyle(): Style;
  83080. /**
  83081. * Adds a new control to the root container
  83082. * @param control defines the control to add
  83083. * @returns the current texture
  83084. */
  83085. addControl(control: Control): AdvancedDynamicTexture;
  83086. /**
  83087. * Removes a control from the root container
  83088. * @param control defines the control to remove
  83089. * @returns the current texture
  83090. */
  83091. removeControl(control: Control): AdvancedDynamicTexture;
  83092. /**
  83093. * Release all resources
  83094. */
  83095. dispose(): void;
  83096. private _onResize;
  83097. /** @hidden */
  83098. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  83099. /**
  83100. * Get screen coordinates for a vector3
  83101. * @param position defines the position to project
  83102. * @param worldMatrix defines the world matrix to use
  83103. * @returns the projected position
  83104. */
  83105. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  83106. /**
  83107. * Get screen coordinates for a vector3
  83108. * @param position defines the position to project
  83109. * @param worldMatrix defines the world matrix to use
  83110. * @returns the projected position with Z
  83111. */
  83112. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  83113. private _checkUpdate;
  83114. private _clearMeasure;
  83115. private _render;
  83116. /** @hidden */
  83117. _changeCursor(cursor: string): void;
  83118. /** @hidden */
  83119. _registerLastControlDown(control: Control, pointerId: number): void;
  83120. private _doPicking;
  83121. /** @hidden */
  83122. _cleanControlAfterRemovalFromList(list: {
  83123. [pointerId: number]: Control;
  83124. }, control: Control): void;
  83125. /** @hidden */
  83126. _cleanControlAfterRemoval(control: Control): void;
  83127. /** Attach to all scene events required to support pointer events */
  83128. attach(): void;
  83129. /** @hidden */
  83130. private onClipboardCopy;
  83131. /** @hidden */
  83132. private onClipboardCut;
  83133. /** @hidden */
  83134. private onClipboardPaste;
  83135. /**
  83136. * Register the clipboard Events onto the canvas
  83137. */
  83138. registerClipboardEvents(): void;
  83139. /**
  83140. * Unregister the clipboard Events from the canvas
  83141. */
  83142. unRegisterClipboardEvents(): void;
  83143. /**
  83144. * Connect the texture to a hosting mesh to enable interactions
  83145. * @param mesh defines the mesh to attach to
  83146. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  83147. */
  83148. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  83149. /**
  83150. * Move the focus to a specific control
  83151. * @param control defines the control which will receive the focus
  83152. */
  83153. moveFocusToControl(control: IFocusableControl): void;
  83154. private _manageFocus;
  83155. private _attachToOnPointerOut;
  83156. private _attachToOnBlur;
  83157. /**
  83158. * Serializes the entire GUI system
  83159. * @returns an object with the JSON serialized data
  83160. */
  83161. serializeContent(): any;
  83162. /**
  83163. * Recreate the content of the ADT from a JSON object
  83164. * @param serializedObject define the JSON serialized object to restore from
  83165. */
  83166. parseContent(serializedObject: any): void;
  83167. /**
  83168. * Recreate the content of the ADT from a snippet saved by the GUI editor
  83169. * @param snippetId defines the snippet to load
  83170. * @returns a promise that will resolve on success
  83171. */
  83172. parseFromSnippetAsync(snippetId: string): Promise<void>;
  83173. /**
  83174. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  83175. * @param mesh defines the mesh which will receive the texture
  83176. * @param width defines the texture width (1024 by default)
  83177. * @param height defines the texture height (1024 by default)
  83178. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83179. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  83180. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83181. * @returns a new AdvancedDynamicTexture
  83182. */
  83183. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83184. /**
  83185. * 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
  83186. * @param mesh defines the mesh which will receive the texture
  83187. * @param width defines the texture width (1024 by default)
  83188. * @param height defines the texture height (1024 by default)
  83189. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  83190. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  83191. * @returns a new AdvancedDynamicTexture
  83192. */
  83193. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  83194. /**
  83195. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  83196. * In this mode the texture will rely on a layer for its rendering.
  83197. * This allows it to be treated like any other layer.
  83198. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  83199. * LayerMask is set through advancedTexture.layer.layerMask
  83200. * @param name defines name for the texture
  83201. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  83202. * @param scene defines the hsoting scene
  83203. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  83204. * @returns a new AdvancedDynamicTexture
  83205. */
  83206. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  83207. }
  83208. }
  83209. declare module BABYLON.GUI {
  83210. /**
  83211. * Root class used for all 2D controls
  83212. * @see https://doc.babylonjs.com/how_to/gui#controls
  83213. */
  83214. export class Control {
  83215. /** defines the name of the control */
  83216. name?: string | undefined;
  83217. /**
  83218. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  83219. */
  83220. static AllowAlphaInheritance: boolean;
  83221. private _alpha;
  83222. private _alphaSet;
  83223. private _zIndex;
  83224. /** @hidden */
  83225. _host: AdvancedDynamicTexture;
  83226. /** Gets or sets the control parent */
  83227. parent: BABYLON.Nullable<Container>;
  83228. /** @hidden */
  83229. _currentMeasure: Measure;
  83230. private _fontFamily;
  83231. private _fontStyle;
  83232. private _fontWeight;
  83233. private _fontSize;
  83234. private _font;
  83235. /** @hidden */
  83236. _width: ValueAndUnit;
  83237. /** @hidden */
  83238. _height: ValueAndUnit;
  83239. /** @hidden */
  83240. protected _fontOffset: {
  83241. ascent: number;
  83242. height: number;
  83243. descent: number;
  83244. };
  83245. private _color;
  83246. private _style;
  83247. private _styleObserver;
  83248. /** @hidden */
  83249. protected _horizontalAlignment: number;
  83250. /** @hidden */
  83251. protected _verticalAlignment: number;
  83252. /** @hidden */
  83253. protected _isDirty: boolean;
  83254. /** @hidden */
  83255. protected _wasDirty: boolean;
  83256. /** @hidden */
  83257. _tempParentMeasure: Measure;
  83258. /** @hidden */
  83259. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  83260. /** @hidden */
  83261. protected _cachedParentMeasure: Measure;
  83262. private _paddingLeft;
  83263. private _paddingRight;
  83264. private _paddingTop;
  83265. private _paddingBottom;
  83266. /** @hidden */
  83267. _left: ValueAndUnit;
  83268. /** @hidden */
  83269. _top: ValueAndUnit;
  83270. private _scaleX;
  83271. private _scaleY;
  83272. private _rotation;
  83273. private _transformCenterX;
  83274. private _transformCenterY;
  83275. /** @hidden */
  83276. _transformMatrix: Matrix2D;
  83277. /** @hidden */
  83278. protected _invertTransformMatrix: Matrix2D;
  83279. /** @hidden */
  83280. protected _transformedPosition: BABYLON.Vector2;
  83281. private _isMatrixDirty;
  83282. private _cachedOffsetX;
  83283. private _cachedOffsetY;
  83284. private _isVisible;
  83285. private _isHighlighted;
  83286. /** @hidden */
  83287. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  83288. private _fontSet;
  83289. private _dummyVector2;
  83290. private _downCount;
  83291. private _enterCount;
  83292. private _doNotRender;
  83293. private _downPointerIds;
  83294. protected _isEnabled: boolean;
  83295. protected _disabledColor: string;
  83296. protected _disabledColorItem: string;
  83297. /** @hidden */
  83298. protected _rebuildLayout: boolean;
  83299. /** @hidden */
  83300. _customData: any;
  83301. /** @hidden */
  83302. _isClipped: boolean;
  83303. /** @hidden */
  83304. _automaticSize: boolean;
  83305. /** @hidden */
  83306. _tag: any;
  83307. /**
  83308. * 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
  83309. */
  83310. uniqueId: number;
  83311. /**
  83312. * Gets or sets an object used to store user defined information for the node
  83313. */
  83314. metadata: any;
  83315. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  83316. isHitTestVisible: boolean;
  83317. /** Gets or sets a boolean indicating if the control can block pointer events */
  83318. isPointerBlocker: boolean;
  83319. /** Gets or sets a boolean indicating if the control can be focusable */
  83320. isFocusInvisible: boolean;
  83321. /**
  83322. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  83323. * 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
  83324. */
  83325. clipChildren: boolean;
  83326. /**
  83327. * Gets or sets a boolean indicating that control content must be clipped
  83328. * 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
  83329. */
  83330. clipContent: boolean;
  83331. /**
  83332. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  83333. */
  83334. useBitmapCache: boolean;
  83335. private _cacheData;
  83336. private _shadowOffsetX;
  83337. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  83338. get shadowOffsetX(): number;
  83339. set shadowOffsetX(value: number);
  83340. private _shadowOffsetY;
  83341. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  83342. get shadowOffsetY(): number;
  83343. set shadowOffsetY(value: number);
  83344. private _shadowBlur;
  83345. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  83346. get shadowBlur(): number;
  83347. set shadowBlur(value: number);
  83348. private _shadowColor;
  83349. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  83350. get shadowColor(): string;
  83351. set shadowColor(value: string);
  83352. /** Gets or sets the cursor to use when the control is hovered */
  83353. hoverCursor: string;
  83354. /** @hidden */
  83355. protected _linkOffsetX: ValueAndUnit;
  83356. /** @hidden */
  83357. protected _linkOffsetY: ValueAndUnit;
  83358. /** Gets the control type name */
  83359. get typeName(): string;
  83360. /**
  83361. * Get the current class name of the control.
  83362. * @returns current class name
  83363. */
  83364. getClassName(): string;
  83365. /**
  83366. * An event triggered when pointer wheel is scrolled
  83367. */
  83368. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  83369. /**
  83370. * An event triggered when the pointer move over the control.
  83371. */
  83372. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  83373. /**
  83374. * An event triggered when the pointer move out of the control.
  83375. */
  83376. onPointerOutObservable: BABYLON.Observable<Control>;
  83377. /**
  83378. * An event triggered when the pointer taps the control
  83379. */
  83380. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  83381. /**
  83382. * An event triggered when pointer up
  83383. */
  83384. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  83385. /**
  83386. * An event triggered when a control is clicked on
  83387. */
  83388. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  83389. /**
  83390. * An event triggered when pointer enters the control
  83391. */
  83392. onPointerEnterObservable: BABYLON.Observable<Control>;
  83393. /**
  83394. * An event triggered when the control is marked as dirty
  83395. */
  83396. onDirtyObservable: BABYLON.Observable<Control>;
  83397. /**
  83398. * An event triggered before drawing the control
  83399. */
  83400. onBeforeDrawObservable: BABYLON.Observable<Control>;
  83401. /**
  83402. * An event triggered after the control was drawn
  83403. */
  83404. onAfterDrawObservable: BABYLON.Observable<Control>;
  83405. /**
  83406. * An event triggered when the control has been disposed
  83407. */
  83408. onDisposeObservable: BABYLON.Observable<Control>;
  83409. /**
  83410. * Get the hosting AdvancedDynamicTexture
  83411. */
  83412. get host(): AdvancedDynamicTexture;
  83413. /** Gets or set information about font offsets (used to render and align text) */
  83414. get fontOffset(): {
  83415. ascent: number;
  83416. height: number;
  83417. descent: number;
  83418. };
  83419. set fontOffset(offset: {
  83420. ascent: number;
  83421. height: number;
  83422. descent: number;
  83423. });
  83424. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  83425. get alpha(): number;
  83426. set alpha(value: number);
  83427. /**
  83428. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  83429. */
  83430. get isHighlighted(): boolean;
  83431. set isHighlighted(value: boolean);
  83432. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  83433. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83434. */
  83435. get scaleX(): number;
  83436. set scaleX(value: number);
  83437. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  83438. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83439. */
  83440. get scaleY(): number;
  83441. set scaleY(value: number);
  83442. /** Gets or sets the rotation angle (0 by default)
  83443. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83444. */
  83445. get rotation(): number;
  83446. set rotation(value: number);
  83447. /** Gets or sets the transformation center on Y axis (0 by default)
  83448. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83449. */
  83450. get transformCenterY(): number;
  83451. set transformCenterY(value: number);
  83452. /** Gets or sets the transformation center on X axis (0 by default)
  83453. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  83454. */
  83455. get transformCenterX(): number;
  83456. set transformCenterX(value: number);
  83457. /**
  83458. * Gets or sets the horizontal alignment
  83459. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83460. */
  83461. get horizontalAlignment(): number;
  83462. set horizontalAlignment(value: number);
  83463. /**
  83464. * Gets or sets the vertical alignment
  83465. * @see https://doc.babylonjs.com/how_to/gui#alignments
  83466. */
  83467. get verticalAlignment(): number;
  83468. set verticalAlignment(value: number);
  83469. /**
  83470. * Gets or sets a fixed ratio for this control.
  83471. * When different from 0, the ratio is used to compute the "second" dimension.
  83472. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  83473. * second dimension is computed as first dimension * fixedRatio
  83474. */
  83475. fixedRatio: number;
  83476. private _fixedRatioMasterIsWidth;
  83477. /**
  83478. * Gets or sets control width
  83479. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83480. */
  83481. get width(): string | number;
  83482. set width(value: string | number);
  83483. /**
  83484. * Gets or sets the control width in pixel
  83485. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83486. */
  83487. get widthInPixels(): number;
  83488. set widthInPixels(value: number);
  83489. /**
  83490. * Gets or sets control height
  83491. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83492. */
  83493. get height(): string | number;
  83494. set height(value: string | number);
  83495. /**
  83496. * Gets or sets control height in pixel
  83497. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83498. */
  83499. get heightInPixels(): number;
  83500. set heightInPixels(value: number);
  83501. /** Gets or set font family */
  83502. get fontFamily(): string;
  83503. set fontFamily(value: string);
  83504. /** Gets or sets font style */
  83505. get fontStyle(): string;
  83506. set fontStyle(value: string);
  83507. /** Gets or sets font weight */
  83508. get fontWeight(): string;
  83509. set fontWeight(value: string);
  83510. /**
  83511. * Gets or sets style
  83512. * @see https://doc.babylonjs.com/how_to/gui#styles
  83513. */
  83514. get style(): BABYLON.Nullable<Style>;
  83515. set style(value: BABYLON.Nullable<Style>);
  83516. /** @hidden */
  83517. get _isFontSizeInPercentage(): boolean;
  83518. /** Gets or sets font size in pixels */
  83519. get fontSizeInPixels(): number;
  83520. set fontSizeInPixels(value: number);
  83521. /** Gets or sets font size */
  83522. get fontSize(): string | number;
  83523. set fontSize(value: string | number);
  83524. /** Gets or sets foreground color */
  83525. get color(): string;
  83526. set color(value: string);
  83527. /** Gets or sets z index which is used to reorder controls on the z axis */
  83528. get zIndex(): number;
  83529. set zIndex(value: number);
  83530. /** Gets or sets a boolean indicating if the control can be rendered */
  83531. get notRenderable(): boolean;
  83532. set notRenderable(value: boolean);
  83533. /** Gets or sets a boolean indicating if the control is visible */
  83534. get isVisible(): boolean;
  83535. set isVisible(value: boolean);
  83536. /** Gets a boolean indicating that the control needs to update its rendering */
  83537. get isDirty(): boolean;
  83538. /**
  83539. * Gets the current linked mesh (or null if none)
  83540. */
  83541. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  83542. /**
  83543. * Gets or sets a value indicating the padding to use on the left of the control
  83544. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83545. */
  83546. get paddingLeft(): string | number;
  83547. set paddingLeft(value: string | number);
  83548. /**
  83549. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  83550. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83551. */
  83552. get paddingLeftInPixels(): number;
  83553. set paddingLeftInPixels(value: number);
  83554. /**
  83555. * Gets or sets a value indicating the padding to use on the right of the control
  83556. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83557. */
  83558. get paddingRight(): string | number;
  83559. set paddingRight(value: string | number);
  83560. /**
  83561. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  83562. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83563. */
  83564. get paddingRightInPixels(): number;
  83565. set paddingRightInPixels(value: number);
  83566. /**
  83567. * Gets or sets a value indicating the padding to use on the top of the control
  83568. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83569. */
  83570. get paddingTop(): string | number;
  83571. set paddingTop(value: string | number);
  83572. /**
  83573. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  83574. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83575. */
  83576. get paddingTopInPixels(): number;
  83577. set paddingTopInPixels(value: number);
  83578. /**
  83579. * Gets or sets a value indicating the padding to use on the bottom of the control
  83580. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83581. */
  83582. get paddingBottom(): string | number;
  83583. set paddingBottom(value: string | number);
  83584. /**
  83585. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  83586. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83587. */
  83588. get paddingBottomInPixels(): number;
  83589. set paddingBottomInPixels(value: number);
  83590. /**
  83591. * Gets or sets a value indicating the left coordinate of the control
  83592. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83593. */
  83594. get left(): string | number;
  83595. set left(value: string | number);
  83596. /**
  83597. * Gets or sets a value indicating the left coordinate in pixels of the control
  83598. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83599. */
  83600. get leftInPixels(): number;
  83601. set leftInPixels(value: number);
  83602. /**
  83603. * Gets or sets a value indicating the top coordinate of the control
  83604. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83605. */
  83606. get top(): string | number;
  83607. set top(value: string | number);
  83608. /**
  83609. * Gets or sets a value indicating the top coordinate in pixels of the control
  83610. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83611. */
  83612. get topInPixels(): number;
  83613. set topInPixels(value: number);
  83614. /**
  83615. * Gets or sets a value indicating the offset on X axis to the linked mesh
  83616. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83617. */
  83618. get linkOffsetX(): string | number;
  83619. set linkOffsetX(value: string | number);
  83620. /**
  83621. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  83622. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83623. */
  83624. get linkOffsetXInPixels(): number;
  83625. set linkOffsetXInPixels(value: number);
  83626. /**
  83627. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  83628. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83629. */
  83630. get linkOffsetY(): string | number;
  83631. set linkOffsetY(value: string | number);
  83632. /**
  83633. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  83634. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83635. */
  83636. get linkOffsetYInPixels(): number;
  83637. set linkOffsetYInPixels(value: number);
  83638. /** Gets the center coordinate on X axis */
  83639. get centerX(): number;
  83640. /** Gets the center coordinate on Y axis */
  83641. get centerY(): number;
  83642. /** Gets or sets if control is Enabled */
  83643. get isEnabled(): boolean;
  83644. set isEnabled(value: boolean);
  83645. /** Gets or sets background color of control if it's disabled */
  83646. get disabledColor(): string;
  83647. set disabledColor(value: string);
  83648. /** Gets or sets front color of control if it's disabled */
  83649. get disabledColorItem(): string;
  83650. set disabledColorItem(value: string);
  83651. /**
  83652. * Creates a new control
  83653. * @param name defines the name of the control
  83654. */
  83655. constructor(
  83656. /** defines the name of the control */
  83657. name?: string | undefined);
  83658. /** @hidden */
  83659. protected _getTypeName(): string;
  83660. /**
  83661. * Gets the first ascendant in the hierarchy of the given type
  83662. * @param className defines the required type
  83663. * @returns the ascendant or null if not found
  83664. */
  83665. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  83666. /** @hidden */
  83667. _resetFontCache(): void;
  83668. /**
  83669. * Determines if a container is an ascendant of the current control
  83670. * @param container defines the container to look for
  83671. * @returns true if the container is one of the ascendant of the control
  83672. */
  83673. isAscendant(container: Control): boolean;
  83674. /**
  83675. * Gets coordinates in local control space
  83676. * @param globalCoordinates defines the coordinates to transform
  83677. * @returns the new coordinates in local space
  83678. */
  83679. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83680. /**
  83681. * Gets coordinates in local control space
  83682. * @param globalCoordinates defines the coordinates to transform
  83683. * @param result defines the target vector2 where to store the result
  83684. * @returns the current control
  83685. */
  83686. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83687. /**
  83688. * Gets coordinates in parent local control space
  83689. * @param globalCoordinates defines the coordinates to transform
  83690. * @returns the new coordinates in parent local space
  83691. */
  83692. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83693. /**
  83694. * Move the current control to a vector3 position projected onto the screen.
  83695. * @param position defines the target position
  83696. * @param scene defines the hosting scene
  83697. */
  83698. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83699. /**
  83700. * Will store all controls that have this control as ascendant in a given array
  83701. * @param results defines the array where to store the descendants
  83702. * @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
  83703. * @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
  83704. */
  83705. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83706. /**
  83707. * Will return all controls that have this control as ascendant
  83708. * @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
  83709. * @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
  83710. * @return all child controls
  83711. */
  83712. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83713. /**
  83714. * Link current control with a target mesh
  83715. * @param mesh defines the mesh to link with
  83716. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83717. */
  83718. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83719. /**
  83720. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83721. * @param { string | number} paddingTop - The value of the top padding.
  83722. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83723. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83724. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83725. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83726. */
  83727. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83728. /**
  83729. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83730. * @param { number} paddingTop - The value in pixels of the top padding.
  83731. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83732. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83733. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83734. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83735. */
  83736. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83737. /** @hidden */
  83738. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83739. /** @hidden */
  83740. _offsetLeft(offset: number): void;
  83741. /** @hidden */
  83742. _offsetTop(offset: number): void;
  83743. /** @hidden */
  83744. _markMatrixAsDirty(): void;
  83745. /** @hidden */
  83746. _flagDescendantsAsMatrixDirty(): void;
  83747. /** @hidden */
  83748. _intersectsRect(rect: Measure): boolean;
  83749. /** @hidden */
  83750. protected invalidateRect(): void;
  83751. /** @hidden */
  83752. _markAsDirty(force?: boolean): void;
  83753. /** @hidden */
  83754. _markAllAsDirty(): void;
  83755. /** @hidden */
  83756. _link(host: AdvancedDynamicTexture): void;
  83757. /** @hidden */
  83758. protected _transform(context?: CanvasRenderingContext2D): void;
  83759. /** @hidden */
  83760. _renderHighlight(context: CanvasRenderingContext2D): void;
  83761. /** @hidden */
  83762. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83763. /** @hidden */
  83764. protected _applyStates(context: CanvasRenderingContext2D): void;
  83765. /** @hidden */
  83766. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83767. /** @hidden */
  83768. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83769. protected _evaluateClippingState(parentMeasure: Measure): void;
  83770. /** @hidden */
  83771. _measure(): void;
  83772. /** @hidden */
  83773. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83774. /** @hidden */
  83775. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83776. /** @hidden */
  83777. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83778. /** @hidden */
  83779. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83780. private static _ClipMeasure;
  83781. private _tmpMeasureA;
  83782. private _clip;
  83783. /** @hidden */
  83784. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83785. /** @hidden */
  83786. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83787. /**
  83788. * Tests if a given coordinates belong to the current control
  83789. * @param x defines x coordinate to test
  83790. * @param y defines y coordinate to test
  83791. * @returns true if the coordinates are inside the control
  83792. */
  83793. contains(x: number, y: number): boolean;
  83794. /** @hidden */
  83795. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83796. /** @hidden */
  83797. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83798. /** @hidden */
  83799. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83800. /** @hidden */
  83801. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83802. /** @hidden */
  83803. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83804. /** @hidden */
  83805. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83806. /** @hidden */
  83807. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83808. /** @hidden */
  83809. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83810. /** @hidden */
  83811. _onCanvasBlur(): void;
  83812. /** @hidden */
  83813. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83814. private _prepareFont;
  83815. /**
  83816. * Serializes the current control
  83817. * @param serializationObject defined the JSON serialized object
  83818. */
  83819. serialize(serializationObject: any): void;
  83820. /** @hidden */
  83821. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83822. /** Releases associated resources */
  83823. dispose(): void;
  83824. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83825. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83826. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83827. private static _VERTICAL_ALIGNMENT_TOP;
  83828. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83829. private static _VERTICAL_ALIGNMENT_CENTER;
  83830. /** HORIZONTAL_ALIGNMENT_LEFT */
  83831. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83832. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83833. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83834. /** HORIZONTAL_ALIGNMENT_CENTER */
  83835. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83836. /** VERTICAL_ALIGNMENT_TOP */
  83837. static get VERTICAL_ALIGNMENT_TOP(): number;
  83838. /** VERTICAL_ALIGNMENT_BOTTOM */
  83839. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83840. /** VERTICAL_ALIGNMENT_CENTER */
  83841. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83842. private static _FontHeightSizes;
  83843. /** @hidden */
  83844. static _GetFontOffset(font: string): {
  83845. ascent: number;
  83846. height: number;
  83847. descent: number;
  83848. };
  83849. /**
  83850. * Creates a Control from parsed data
  83851. * @param serializedObject defines parsed data
  83852. * @param host defines the hosting AdvancedDynamicTexture
  83853. * @returns a new Control
  83854. */
  83855. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83856. /**
  83857. * Creates a stack panel that can be used to render headers
  83858. * @param control defines the control to associate with the header
  83859. * @param text defines the text of the header
  83860. * @param size defines the size of the header
  83861. * @param options defines options used to configure the header
  83862. * @returns a new StackPanel
  83863. * @ignore
  83864. * @hidden
  83865. */
  83866. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83867. isHorizontal: boolean;
  83868. controlFirst: boolean;
  83869. }) => any;
  83870. /** @hidden */
  83871. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83872. }
  83873. }
  83874. declare module BABYLON.GUI {
  83875. /**
  83876. * Root class for 2D containers
  83877. * @see https://doc.babylonjs.com/how_to/gui#containers
  83878. */
  83879. export class Container extends Control {
  83880. name?: string | undefined;
  83881. /** @hidden */
  83882. _children: Control[];
  83883. /** @hidden */
  83884. protected _measureForChildren: Measure;
  83885. /** @hidden */
  83886. protected _background: string;
  83887. /** @hidden */
  83888. protected _adaptWidthToChildren: boolean;
  83889. /** @hidden */
  83890. protected _adaptHeightToChildren: boolean;
  83891. /**
  83892. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83893. */
  83894. logLayoutCycleErrors: boolean;
  83895. /**
  83896. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83897. */
  83898. maxLayoutCycle: number;
  83899. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83900. get adaptHeightToChildren(): boolean;
  83901. set adaptHeightToChildren(value: boolean);
  83902. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83903. get adaptWidthToChildren(): boolean;
  83904. set adaptWidthToChildren(value: boolean);
  83905. /** Gets or sets background color */
  83906. get background(): string;
  83907. set background(value: string);
  83908. /** Gets the list of children */
  83909. get children(): Control[];
  83910. /**
  83911. * Creates a new Container
  83912. * @param name defines the name of the container
  83913. */
  83914. constructor(name?: string | undefined);
  83915. protected _getTypeName(): string;
  83916. _flagDescendantsAsMatrixDirty(): void;
  83917. /**
  83918. * Gets a child using its name
  83919. * @param name defines the child name to look for
  83920. * @returns the child control if found
  83921. */
  83922. getChildByName(name: string): BABYLON.Nullable<Control>;
  83923. /**
  83924. * Gets a child using its type and its name
  83925. * @param name defines the child name to look for
  83926. * @param type defines the child type to look for
  83927. * @returns the child control if found
  83928. */
  83929. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83930. /**
  83931. * Search for a specific control in children
  83932. * @param control defines the control to look for
  83933. * @returns true if the control is in child list
  83934. */
  83935. containsControl(control: Control): boolean;
  83936. /**
  83937. * Adds a new control to the current container
  83938. * @param control defines the control to add
  83939. * @returns the current container
  83940. */
  83941. addControl(control: BABYLON.Nullable<Control>): Container;
  83942. /**
  83943. * Removes all controls from the current container
  83944. * @returns the current container
  83945. */
  83946. clearControls(): Container;
  83947. /**
  83948. * Removes a control from the current container
  83949. * @param control defines the control to remove
  83950. * @returns the current container
  83951. */
  83952. removeControl(control: Control): Container;
  83953. /** @hidden */
  83954. _reOrderControl(control: Control): void;
  83955. /** @hidden */
  83956. _offsetLeft(offset: number): void;
  83957. /** @hidden */
  83958. _offsetTop(offset: number): void;
  83959. /** @hidden */
  83960. _markAllAsDirty(): void;
  83961. /** @hidden */
  83962. protected _localDraw(context: CanvasRenderingContext2D): void;
  83963. /** @hidden */
  83964. _link(host: AdvancedDynamicTexture): void;
  83965. /** @hidden */
  83966. protected _beforeLayout(): void;
  83967. /** @hidden */
  83968. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83969. /** @hidden */
  83970. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83971. protected _postMeasure(): void;
  83972. /** @hidden */
  83973. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83974. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83975. /** @hidden */
  83976. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83977. /** @hidden */
  83978. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83979. /**
  83980. * Serializes the current control
  83981. * @param serializationObject defined the JSON serialized object
  83982. */
  83983. serialize(serializationObject: any): void;
  83984. /** Releases associated resources */
  83985. dispose(): void;
  83986. /** @hidden */
  83987. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83988. }
  83989. }
  83990. declare module BABYLON.GUI {
  83991. /** Class used to create rectangle container */
  83992. export class Rectangle extends Container {
  83993. name?: string | undefined;
  83994. private _thickness;
  83995. private _cornerRadius;
  83996. /** Gets or sets border thickness */
  83997. get thickness(): number;
  83998. set thickness(value: number);
  83999. /** Gets or sets the corner radius angle */
  84000. get cornerRadius(): number;
  84001. set cornerRadius(value: number);
  84002. /**
  84003. * Creates a new Rectangle
  84004. * @param name defines the control name
  84005. */
  84006. constructor(name?: string | undefined);
  84007. protected _getTypeName(): string;
  84008. protected _localDraw(context: CanvasRenderingContext2D): void;
  84009. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84010. private _drawRoundedRect;
  84011. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84012. }
  84013. }
  84014. declare module BABYLON.GUI {
  84015. /**
  84016. * Enum that determines the text-wrapping mode to use.
  84017. */
  84018. export enum TextWrapping {
  84019. /**
  84020. * Clip the text when it's larger than Control.width; this is the default mode.
  84021. */
  84022. Clip = 0,
  84023. /**
  84024. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  84025. */
  84026. WordWrap = 1,
  84027. /**
  84028. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  84029. */
  84030. Ellipsis = 2
  84031. }
  84032. /**
  84033. * Class used to create text block control
  84034. */
  84035. export class TextBlock extends Control {
  84036. /**
  84037. * Defines the name of the control
  84038. */
  84039. name?: string | undefined;
  84040. private _text;
  84041. private _textWrapping;
  84042. private _textHorizontalAlignment;
  84043. private _textVerticalAlignment;
  84044. private _lines;
  84045. private _resizeToFit;
  84046. private _lineSpacing;
  84047. private _outlineWidth;
  84048. private _outlineColor;
  84049. private _underline;
  84050. private _lineThrough;
  84051. /**
  84052. * An event triggered after the text is changed
  84053. */
  84054. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  84055. /**
  84056. * An event triggered after the text was broken up into lines
  84057. */
  84058. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  84059. /**
  84060. * Function used to split a string into words. By default, a string is split at each space character found
  84061. */
  84062. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  84063. /**
  84064. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  84065. */
  84066. get lines(): any[];
  84067. /**
  84068. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84069. */
  84070. get resizeToFit(): boolean;
  84071. /**
  84072. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  84073. */
  84074. set resizeToFit(value: boolean);
  84075. /**
  84076. * Gets or sets a boolean indicating if text must be wrapped
  84077. */
  84078. get textWrapping(): TextWrapping | boolean;
  84079. /**
  84080. * Gets or sets a boolean indicating if text must be wrapped
  84081. */
  84082. set textWrapping(value: TextWrapping | boolean);
  84083. /**
  84084. * Gets or sets text to display
  84085. */
  84086. get text(): string;
  84087. /**
  84088. * Gets or sets text to display
  84089. */
  84090. set text(value: string);
  84091. /**
  84092. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84093. */
  84094. get textHorizontalAlignment(): number;
  84095. /**
  84096. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  84097. */
  84098. set textHorizontalAlignment(value: number);
  84099. /**
  84100. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84101. */
  84102. get textVerticalAlignment(): number;
  84103. /**
  84104. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  84105. */
  84106. set textVerticalAlignment(value: number);
  84107. /**
  84108. * Gets or sets line spacing value
  84109. */
  84110. set lineSpacing(value: string | number);
  84111. /**
  84112. * Gets or sets line spacing value
  84113. */
  84114. get lineSpacing(): string | number;
  84115. /**
  84116. * Gets or sets outlineWidth of the text to display
  84117. */
  84118. get outlineWidth(): number;
  84119. /**
  84120. * Gets or sets outlineWidth of the text to display
  84121. */
  84122. set outlineWidth(value: number);
  84123. /**
  84124. * Gets or sets a boolean indicating that text must have underline
  84125. */
  84126. get underline(): boolean;
  84127. /**
  84128. * Gets or sets a boolean indicating that text must have underline
  84129. */
  84130. set underline(value: boolean);
  84131. /**
  84132. * Gets or sets an boolean indicating that text must be crossed out
  84133. */
  84134. get lineThrough(): boolean;
  84135. /**
  84136. * Gets or sets an boolean indicating that text must be crossed out
  84137. */
  84138. set lineThrough(value: boolean);
  84139. /**
  84140. * Gets or sets outlineColor of the text to display
  84141. */
  84142. get outlineColor(): string;
  84143. /**
  84144. * Gets or sets outlineColor of the text to display
  84145. */
  84146. set outlineColor(value: string);
  84147. /**
  84148. * Creates a new TextBlock object
  84149. * @param name defines the name of the control
  84150. * @param text defines the text to display (emptry string by default)
  84151. */
  84152. constructor(
  84153. /**
  84154. * Defines the name of the control
  84155. */
  84156. name?: string | undefined, text?: string);
  84157. protected _getTypeName(): string;
  84158. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84159. private _drawText;
  84160. /** @hidden */
  84161. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84162. protected _applyStates(context: CanvasRenderingContext2D): void;
  84163. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  84164. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  84165. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  84166. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  84167. protected _renderLines(context: CanvasRenderingContext2D): void;
  84168. /**
  84169. * Given a width constraint applied on the text block, find the expected height
  84170. * @returns expected height
  84171. */
  84172. computeExpectedHeight(): number;
  84173. dispose(): void;
  84174. }
  84175. }
  84176. declare module BABYLON.GUI {
  84177. /**
  84178. * Class used to create 2D images
  84179. */
  84180. export class Image extends Control {
  84181. name?: string | undefined;
  84182. private _workingCanvas;
  84183. private _domImage;
  84184. private _imageWidth;
  84185. private _imageHeight;
  84186. private _loaded;
  84187. private _stretch;
  84188. private _source;
  84189. private _autoScale;
  84190. private _sourceLeft;
  84191. private _sourceTop;
  84192. private _sourceWidth;
  84193. private _sourceHeight;
  84194. private _svgAttributesComputationCompleted;
  84195. private _isSVG;
  84196. private _cellWidth;
  84197. private _cellHeight;
  84198. private _cellId;
  84199. private _populateNinePatchSlicesFromImage;
  84200. private _sliceLeft;
  84201. private _sliceRight;
  84202. private _sliceTop;
  84203. private _sliceBottom;
  84204. private _detectPointerOnOpaqueOnly;
  84205. private _imageDataCache;
  84206. /**
  84207. * BABYLON.Observable notified when the content is loaded
  84208. */
  84209. onImageLoadedObservable: BABYLON.Observable<Image>;
  84210. /**
  84211. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  84212. */
  84213. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  84214. /**
  84215. * Gets a boolean indicating that the content is loaded
  84216. */
  84217. get isLoaded(): boolean;
  84218. /**
  84219. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  84220. */
  84221. get populateNinePatchSlicesFromImage(): boolean;
  84222. set populateNinePatchSlicesFromImage(value: boolean);
  84223. /**
  84224. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  84225. * Beware using this as this will comsume more memory as the image has to be stored twice
  84226. */
  84227. get detectPointerOnOpaqueOnly(): boolean;
  84228. set detectPointerOnOpaqueOnly(value: boolean);
  84229. /**
  84230. * Gets or sets the left value for slicing (9-patch)
  84231. */
  84232. get sliceLeft(): number;
  84233. set sliceLeft(value: number);
  84234. /**
  84235. * Gets or sets the right value for slicing (9-patch)
  84236. */
  84237. get sliceRight(): number;
  84238. set sliceRight(value: number);
  84239. /**
  84240. * Gets or sets the top value for slicing (9-patch)
  84241. */
  84242. get sliceTop(): number;
  84243. set sliceTop(value: number);
  84244. /**
  84245. * Gets or sets the bottom value for slicing (9-patch)
  84246. */
  84247. get sliceBottom(): number;
  84248. set sliceBottom(value: number);
  84249. /**
  84250. * Gets or sets the left coordinate in the source image
  84251. */
  84252. get sourceLeft(): number;
  84253. set sourceLeft(value: number);
  84254. /**
  84255. * Gets or sets the top coordinate in the source image
  84256. */
  84257. get sourceTop(): number;
  84258. set sourceTop(value: number);
  84259. /**
  84260. * Gets or sets the width to capture in the source image
  84261. */
  84262. get sourceWidth(): number;
  84263. set sourceWidth(value: number);
  84264. /**
  84265. * Gets or sets the height to capture in the source image
  84266. */
  84267. get sourceHeight(): number;
  84268. set sourceHeight(value: number);
  84269. /** Indicates if the format of the image is SVG */
  84270. get isSVG(): boolean;
  84271. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  84272. get svgAttributesComputationCompleted(): boolean;
  84273. /**
  84274. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  84275. * @see https://doc.babylonjs.com/how_to/gui#image
  84276. */
  84277. get autoScale(): boolean;
  84278. set autoScale(value: boolean);
  84279. /** Gets or sets the streching mode used by the image */
  84280. get stretch(): number;
  84281. set stretch(value: number);
  84282. /** @hidden */
  84283. _rotate90(n: number, preserveProperties?: boolean): Image;
  84284. private _handleRotationForSVGImage;
  84285. private _rotate90SourceProperties;
  84286. /**
  84287. * Gets or sets the internal DOM image used to render the control
  84288. */
  84289. set domImage(value: HTMLImageElement);
  84290. get domImage(): HTMLImageElement;
  84291. private _onImageLoaded;
  84292. private _extractNinePatchSliceDataFromImage;
  84293. /**
  84294. * Gets the image source url
  84295. */
  84296. get source(): BABYLON.Nullable<string>;
  84297. /**
  84298. * Gets or sets image source url
  84299. */
  84300. set source(value: BABYLON.Nullable<string>);
  84301. /**
  84302. * Checks for svg document with icon id present
  84303. */
  84304. private _svgCheck;
  84305. /**
  84306. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  84307. * given external svg file and icon id
  84308. */
  84309. private _getSVGAttribs;
  84310. /**
  84311. * Gets or sets the cell width to use when animation sheet is enabled
  84312. * @see https://doc.babylonjs.com/how_to/gui#image
  84313. */
  84314. get cellWidth(): number;
  84315. set cellWidth(value: number);
  84316. /**
  84317. * Gets or sets the cell height to use when animation sheet is enabled
  84318. * @see https://doc.babylonjs.com/how_to/gui#image
  84319. */
  84320. get cellHeight(): number;
  84321. set cellHeight(value: number);
  84322. /**
  84323. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  84324. * @see https://doc.babylonjs.com/how_to/gui#image
  84325. */
  84326. get cellId(): number;
  84327. set cellId(value: number);
  84328. /**
  84329. * Creates a new Image
  84330. * @param name defines the control name
  84331. * @param url defines the image url
  84332. */
  84333. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  84334. /**
  84335. * Tests if a given coordinates belong to the current control
  84336. * @param x defines x coordinate to test
  84337. * @param y defines y coordinate to test
  84338. * @returns true if the coordinates are inside the control
  84339. */
  84340. contains(x: number, y: number): boolean;
  84341. protected _getTypeName(): string;
  84342. /** Force the control to synchronize with its content */
  84343. synchronizeSizeWithContent(): void;
  84344. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84345. private _prepareWorkingCanvasForOpaqueDetection;
  84346. private _drawImage;
  84347. _draw(context: CanvasRenderingContext2D): void;
  84348. private _renderCornerPatch;
  84349. private _renderNinePatch;
  84350. dispose(): void;
  84351. /** STRETCH_NONE */
  84352. static readonly STRETCH_NONE: number;
  84353. /** STRETCH_FILL */
  84354. static readonly STRETCH_FILL: number;
  84355. /** STRETCH_UNIFORM */
  84356. static readonly STRETCH_UNIFORM: number;
  84357. /** STRETCH_EXTEND */
  84358. static readonly STRETCH_EXTEND: number;
  84359. /** NINE_PATCH */
  84360. static readonly STRETCH_NINE_PATCH: number;
  84361. }
  84362. }
  84363. declare module BABYLON.GUI {
  84364. /**
  84365. * Class used to create 2D buttons
  84366. */
  84367. export class Button extends Rectangle {
  84368. name?: string | undefined;
  84369. /**
  84370. * Function called to generate a pointer enter animation
  84371. */
  84372. pointerEnterAnimation: () => void;
  84373. /**
  84374. * Function called to generate a pointer out animation
  84375. */
  84376. pointerOutAnimation: () => void;
  84377. /**
  84378. * Function called to generate a pointer down animation
  84379. */
  84380. pointerDownAnimation: () => void;
  84381. /**
  84382. * Function called to generate a pointer up animation
  84383. */
  84384. pointerUpAnimation: () => void;
  84385. /**
  84386. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  84387. */
  84388. delegatePickingToChildren: boolean;
  84389. private _image;
  84390. /**
  84391. * Returns the image part of the button (if any)
  84392. */
  84393. get image(): BABYLON.Nullable<Image>;
  84394. private _textBlock;
  84395. /**
  84396. * Returns the image part of the button (if any)
  84397. */
  84398. get textBlock(): BABYLON.Nullable<TextBlock>;
  84399. /**
  84400. * Creates a new Button
  84401. * @param name defines the name of the button
  84402. */
  84403. constructor(name?: string | undefined);
  84404. protected _getTypeName(): string;
  84405. /** @hidden */
  84406. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  84407. /** @hidden */
  84408. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  84409. /** @hidden */
  84410. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  84411. /** @hidden */
  84412. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84413. /** @hidden */
  84414. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84415. /**
  84416. * Creates a new button made with an image and a text
  84417. * @param name defines the name of the button
  84418. * @param text defines the text of the button
  84419. * @param imageUrl defines the url of the image
  84420. * @returns a new Button
  84421. */
  84422. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  84423. /**
  84424. * Creates a new button made with an image
  84425. * @param name defines the name of the button
  84426. * @param imageUrl defines the url of the image
  84427. * @returns a new Button
  84428. */
  84429. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  84430. /**
  84431. * Creates a new button made with a text
  84432. * @param name defines the name of the button
  84433. * @param text defines the text of the button
  84434. * @returns a new Button
  84435. */
  84436. static CreateSimpleButton(name: string, text: string): Button;
  84437. /**
  84438. * Creates a new button made with an image and a centered text
  84439. * @param name defines the name of the button
  84440. * @param text defines the text of the button
  84441. * @param imageUrl defines the url of the image
  84442. * @returns a new Button
  84443. */
  84444. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  84445. }
  84446. }
  84447. declare module BABYLON.GUI {
  84448. /**
  84449. * Class used to create a 2D stack panel container
  84450. */
  84451. export class StackPanel extends Container {
  84452. name?: string | undefined;
  84453. private _isVertical;
  84454. private _manualWidth;
  84455. private _manualHeight;
  84456. private _doNotTrackManualChanges;
  84457. /**
  84458. * Gets or sets a boolean indicating that layou warnings should be ignored
  84459. */
  84460. ignoreLayoutWarnings: boolean;
  84461. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  84462. get isVertical(): boolean;
  84463. set isVertical(value: boolean);
  84464. /**
  84465. * Gets or sets panel width.
  84466. * This value should not be set when in horizontal mode as it will be computed automatically
  84467. */
  84468. set width(value: string | number);
  84469. get width(): string | number;
  84470. /**
  84471. * Gets or sets panel height.
  84472. * This value should not be set when in vertical mode as it will be computed automatically
  84473. */
  84474. set height(value: string | number);
  84475. get height(): string | number;
  84476. /**
  84477. * Creates a new StackPanel
  84478. * @param name defines control name
  84479. */
  84480. constructor(name?: string | undefined);
  84481. protected _getTypeName(): string;
  84482. /** @hidden */
  84483. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84484. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84485. protected _postMeasure(): void;
  84486. /**
  84487. * Serializes the current control
  84488. * @param serializationObject defined the JSON serialized object
  84489. */
  84490. serialize(serializationObject: any): void;
  84491. /** @hidden */
  84492. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  84493. }
  84494. }
  84495. declare module BABYLON.GUI {
  84496. /**
  84497. * Class used to represent a 2D checkbox
  84498. */
  84499. export class Checkbox extends Control {
  84500. name?: string | undefined;
  84501. private _isChecked;
  84502. private _background;
  84503. private _checkSizeRatio;
  84504. private _thickness;
  84505. /** Gets or sets border thickness */
  84506. get thickness(): number;
  84507. set thickness(value: number);
  84508. /**
  84509. * BABYLON.Observable raised when isChecked property changes
  84510. */
  84511. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84512. /** Gets or sets a value indicating the ratio between overall size and check size */
  84513. get checkSizeRatio(): number;
  84514. set checkSizeRatio(value: number);
  84515. /** Gets or sets background color */
  84516. get background(): string;
  84517. set background(value: string);
  84518. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84519. get isChecked(): boolean;
  84520. set isChecked(value: boolean);
  84521. /**
  84522. * Creates a new CheckBox
  84523. * @param name defines the control name
  84524. */
  84525. constructor(name?: string | undefined);
  84526. protected _getTypeName(): string;
  84527. /** @hidden */
  84528. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84529. /** @hidden */
  84530. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84531. /**
  84532. * Utility function to easily create a checkbox with a header
  84533. * @param title defines the label to use for the header
  84534. * @param onValueChanged defines the callback to call when value changes
  84535. * @returns a StackPanel containing the checkbox and a textBlock
  84536. */
  84537. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  84538. }
  84539. }
  84540. declare module BABYLON.GUI {
  84541. /**
  84542. * Class used to store key control properties
  84543. */
  84544. export class KeyPropertySet {
  84545. /** Width */
  84546. width?: string;
  84547. /** Height */
  84548. height?: string;
  84549. /** Left padding */
  84550. paddingLeft?: string;
  84551. /** Right padding */
  84552. paddingRight?: string;
  84553. /** Top padding */
  84554. paddingTop?: string;
  84555. /** Bottom padding */
  84556. paddingBottom?: string;
  84557. /** Foreground color */
  84558. color?: string;
  84559. /** Background color */
  84560. background?: string;
  84561. }
  84562. /**
  84563. * Class used to create virtual keyboard
  84564. */
  84565. export class VirtualKeyboard extends StackPanel {
  84566. /** BABYLON.Observable raised when a key is pressed */
  84567. onKeyPressObservable: BABYLON.Observable<string>;
  84568. /** Gets or sets default key button width */
  84569. defaultButtonWidth: string;
  84570. /** Gets or sets default key button height */
  84571. defaultButtonHeight: string;
  84572. /** Gets or sets default key button left padding */
  84573. defaultButtonPaddingLeft: string;
  84574. /** Gets or sets default key button right padding */
  84575. defaultButtonPaddingRight: string;
  84576. /** Gets or sets default key button top padding */
  84577. defaultButtonPaddingTop: string;
  84578. /** Gets or sets default key button bottom padding */
  84579. defaultButtonPaddingBottom: string;
  84580. /** Gets or sets default key button foreground color */
  84581. defaultButtonColor: string;
  84582. /** Gets or sets default key button background color */
  84583. defaultButtonBackground: string;
  84584. /** Gets or sets shift button foreground color */
  84585. shiftButtonColor: string;
  84586. /** Gets or sets shift button thickness*/
  84587. selectedShiftThickness: number;
  84588. /** Gets shift key state */
  84589. shiftState: number;
  84590. protected _getTypeName(): string;
  84591. private _createKey;
  84592. /**
  84593. * Adds a new row of keys
  84594. * @param keys defines the list of keys to add
  84595. * @param propertySets defines the associated property sets
  84596. */
  84597. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  84598. /**
  84599. * Set the shift key to a specific state
  84600. * @param shiftState defines the new shift state
  84601. */
  84602. applyShiftState(shiftState: number): void;
  84603. private _currentlyConnectedInputText;
  84604. private _connectedInputTexts;
  84605. private _onKeyPressObserver;
  84606. /** Gets the input text control currently attached to the keyboard */
  84607. get connectedInputText(): BABYLON.Nullable<InputText>;
  84608. /**
  84609. * Connects the keyboard with an input text control
  84610. *
  84611. * @param input defines the target control
  84612. */
  84613. connect(input: InputText): void;
  84614. /**
  84615. * Disconnects the keyboard from connected InputText controls
  84616. *
  84617. * @param input optionally defines a target control, otherwise all are disconnected
  84618. */
  84619. disconnect(input?: InputText): void;
  84620. private _removeConnectedInputObservables;
  84621. /**
  84622. * Release all resources
  84623. */
  84624. dispose(): void;
  84625. /**
  84626. * Creates a new keyboard using a default layout
  84627. *
  84628. * @param name defines control name
  84629. * @returns a new VirtualKeyboard
  84630. */
  84631. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  84632. }
  84633. }
  84634. declare module BABYLON.GUI {
  84635. /** @hidden */
  84636. export class TextWrapper {
  84637. private _text;
  84638. private _characters;
  84639. get text(): string;
  84640. set text(txt: string);
  84641. get length(): number;
  84642. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  84643. charAt(idx: number): string;
  84644. substr(from: number, length?: number): string;
  84645. substring(from: number, to?: number): string;
  84646. isWord(index: number): boolean;
  84647. }
  84648. }
  84649. declare module BABYLON.GUI {
  84650. /**
  84651. * Class used to create input text control
  84652. */
  84653. export class InputText extends Control implements IFocusableControl {
  84654. name?: string | undefined;
  84655. private _textWrapper;
  84656. private _placeholderText;
  84657. private _background;
  84658. private _focusedBackground;
  84659. private _focusedColor;
  84660. private _placeholderColor;
  84661. private _thickness;
  84662. private _margin;
  84663. private _autoStretchWidth;
  84664. private _maxWidth;
  84665. private _isFocused;
  84666. private _blinkTimeout;
  84667. private _blinkIsEven;
  84668. private _cursorOffset;
  84669. private _scrollLeft;
  84670. private _textWidth;
  84671. private _clickedCoordinate;
  84672. private _deadKey;
  84673. private _addKey;
  84674. private _currentKey;
  84675. private _isTextHighlightOn;
  84676. private _textHighlightColor;
  84677. private _highligherOpacity;
  84678. private _highlightedText;
  84679. private _startHighlightIndex;
  84680. private _endHighlightIndex;
  84681. private _cursorIndex;
  84682. private _onFocusSelectAll;
  84683. private _isPointerDown;
  84684. private _onClipboardObserver;
  84685. private _onPointerDblTapObserver;
  84686. /** @hidden */
  84687. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84688. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84689. promptMessage: string;
  84690. /** Force disable prompt on mobile device */
  84691. disableMobilePrompt: boolean;
  84692. /** BABYLON.Observable raised when the text changes */
  84693. onTextChangedObservable: BABYLON.Observable<InputText>;
  84694. /** BABYLON.Observable raised just before an entered character is to be added */
  84695. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84696. /** BABYLON.Observable raised when the control gets the focus */
  84697. onFocusObservable: BABYLON.Observable<InputText>;
  84698. /** BABYLON.Observable raised when the control loses the focus */
  84699. onBlurObservable: BABYLON.Observable<InputText>;
  84700. /**Observable raised when the text is highlighted */
  84701. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84702. /**Observable raised when copy event is triggered */
  84703. onTextCopyObservable: BABYLON.Observable<InputText>;
  84704. /** BABYLON.Observable raised when cut event is triggered */
  84705. onTextCutObservable: BABYLON.Observable<InputText>;
  84706. /** BABYLON.Observable raised when paste event is triggered */
  84707. onTextPasteObservable: BABYLON.Observable<InputText>;
  84708. /** BABYLON.Observable raised when a key event was processed */
  84709. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84710. /** Gets or sets the maximum width allowed by the control */
  84711. get maxWidth(): string | number;
  84712. /** Gets the maximum width allowed by the control in pixels */
  84713. get maxWidthInPixels(): number;
  84714. set maxWidth(value: string | number);
  84715. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84716. get highligherOpacity(): number;
  84717. set highligherOpacity(value: number);
  84718. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84719. get onFocusSelectAll(): boolean;
  84720. set onFocusSelectAll(value: boolean);
  84721. /** Gets or sets the text hightlight color */
  84722. get textHighlightColor(): string;
  84723. set textHighlightColor(value: string);
  84724. /** Gets or sets control margin */
  84725. get margin(): string;
  84726. /** Gets control margin in pixels */
  84727. get marginInPixels(): number;
  84728. set margin(value: string);
  84729. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84730. get autoStretchWidth(): boolean;
  84731. set autoStretchWidth(value: boolean);
  84732. /** Gets or sets border thickness */
  84733. get thickness(): number;
  84734. set thickness(value: number);
  84735. /** Gets or sets the background color when focused */
  84736. get focusedBackground(): string;
  84737. set focusedBackground(value: string);
  84738. /** Gets or sets the background color when focused */
  84739. get focusedColor(): string;
  84740. set focusedColor(value: string);
  84741. /** Gets or sets the background color */
  84742. get background(): string;
  84743. set background(value: string);
  84744. /** Gets or sets the placeholder color */
  84745. get placeholderColor(): string;
  84746. set placeholderColor(value: string);
  84747. /** Gets or sets the text displayed when the control is empty */
  84748. get placeholderText(): string;
  84749. set placeholderText(value: string);
  84750. /** Gets or sets the dead key flag */
  84751. get deadKey(): boolean;
  84752. set deadKey(flag: boolean);
  84753. /** Gets or sets the highlight text */
  84754. get highlightedText(): string;
  84755. set highlightedText(text: string);
  84756. /** Gets or sets if the current key should be added */
  84757. get addKey(): boolean;
  84758. set addKey(flag: boolean);
  84759. /** Gets or sets the value of the current key being entered */
  84760. get currentKey(): string;
  84761. set currentKey(key: string);
  84762. /** Gets or sets the text displayed in the control */
  84763. get text(): string;
  84764. set text(value: string);
  84765. private _textHasChanged;
  84766. /** Gets or sets control width */
  84767. get width(): string | number;
  84768. set width(value: string | number);
  84769. /**
  84770. * Creates a new InputText
  84771. * @param name defines the control name
  84772. * @param text defines the text of the control
  84773. */
  84774. constructor(name?: string | undefined, text?: string);
  84775. /** @hidden */
  84776. onBlur(): void;
  84777. /** @hidden */
  84778. onFocus(): void;
  84779. /**
  84780. * Function to focus an inputText programmatically
  84781. */
  84782. focus(): void;
  84783. /**
  84784. * Function to unfocus an inputText programmatically
  84785. */
  84786. blur(): void;
  84787. protected _getTypeName(): string;
  84788. /**
  84789. * Function called to get the list of controls that should not steal the focus from this control
  84790. * @returns an array of controls
  84791. */
  84792. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84793. /** @hidden */
  84794. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84795. /** @hidden */
  84796. private _updateValueFromCursorIndex;
  84797. /** @hidden */
  84798. private _processDblClick;
  84799. /** @hidden */
  84800. private _selectAllText;
  84801. /**
  84802. * Handles the keyboard event
  84803. * @param evt Defines the KeyboardEvent
  84804. */
  84805. processKeyboard(evt: KeyboardEvent): void;
  84806. /** @hidden */
  84807. private _onCopyText;
  84808. /** @hidden */
  84809. private _onCutText;
  84810. /** @hidden */
  84811. private _onPasteText;
  84812. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84813. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84814. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84815. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84816. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84817. dispose(): void;
  84818. }
  84819. }
  84820. declare module BABYLON.GUI {
  84821. /**
  84822. * Class used to create a 2D grid container
  84823. */
  84824. export class Grid extends Container {
  84825. name?: string | undefined;
  84826. private _rowDefinitions;
  84827. private _columnDefinitions;
  84828. private _cells;
  84829. private _childControls;
  84830. /**
  84831. * Gets the number of columns
  84832. */
  84833. get columnCount(): number;
  84834. /**
  84835. * Gets the number of rows
  84836. */
  84837. get rowCount(): number;
  84838. /** Gets the list of children */
  84839. get children(): Control[];
  84840. /** Gets the list of cells (e.g. the containers) */
  84841. get cells(): {
  84842. [key: string]: Container;
  84843. };
  84844. /**
  84845. * Gets the definition of a specific row
  84846. * @param index defines the index of the row
  84847. * @returns the row definition
  84848. */
  84849. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84850. /**
  84851. * Gets the definition of a specific column
  84852. * @param index defines the index of the column
  84853. * @returns the column definition
  84854. */
  84855. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84856. /**
  84857. * Adds a new row to the grid
  84858. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84859. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84860. * @returns the current grid
  84861. */
  84862. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84863. /**
  84864. * Adds a new column to the grid
  84865. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84866. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84867. * @returns the current grid
  84868. */
  84869. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84870. /**
  84871. * Update a row definition
  84872. * @param index defines the index of the row to update
  84873. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84874. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84875. * @returns the current grid
  84876. */
  84877. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84878. /**
  84879. * Update a column definition
  84880. * @param index defines the index of the column to update
  84881. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84882. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84883. * @returns the current grid
  84884. */
  84885. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84886. /**
  84887. * Gets the list of children stored in a specific cell
  84888. * @param row defines the row to check
  84889. * @param column defines the column to check
  84890. * @returns the list of controls
  84891. */
  84892. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84893. /**
  84894. * Gets a string representing the child cell info (row x column)
  84895. * @param child defines the control to get info from
  84896. * @returns a string containing the child cell info (row x column)
  84897. */
  84898. getChildCellInfo(child: Control): string;
  84899. private _removeCell;
  84900. private _offsetCell;
  84901. /**
  84902. * Remove a column definition at specified index
  84903. * @param index defines the index of the column to remove
  84904. * @returns the current grid
  84905. */
  84906. removeColumnDefinition(index: number): Grid;
  84907. /**
  84908. * Remove a row definition at specified index
  84909. * @param index defines the index of the row to remove
  84910. * @returns the current grid
  84911. */
  84912. removeRowDefinition(index: number): Grid;
  84913. /**
  84914. * Adds a new control to the current grid
  84915. * @param control defines the control to add
  84916. * @param row defines the row where to add the control (0 by default)
  84917. * @param column defines the column where to add the control (0 by default)
  84918. * @returns the current grid
  84919. */
  84920. addControl(control: Control, row?: number, column?: number): Grid;
  84921. /**
  84922. * Removes a control from the current container
  84923. * @param control defines the control to remove
  84924. * @returns the current container
  84925. */
  84926. removeControl(control: Control): Container;
  84927. /**
  84928. * Creates a new Grid
  84929. * @param name defines control name
  84930. */
  84931. constructor(name?: string | undefined);
  84932. protected _getTypeName(): string;
  84933. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84934. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84935. _flagDescendantsAsMatrixDirty(): void;
  84936. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84937. /** Releases associated resources */
  84938. dispose(): void;
  84939. }
  84940. }
  84941. declare module BABYLON.GUI {
  84942. /** Class used to create color pickers */
  84943. export class ColorPicker extends Control {
  84944. name?: string | undefined;
  84945. private static _Epsilon;
  84946. private _colorWheelCanvas;
  84947. private _value;
  84948. private _tmpColor;
  84949. private _pointerStartedOnSquare;
  84950. private _pointerStartedOnWheel;
  84951. private _squareLeft;
  84952. private _squareTop;
  84953. private _squareSize;
  84954. private _h;
  84955. private _s;
  84956. private _v;
  84957. private _lastPointerDownID;
  84958. /**
  84959. * BABYLON.Observable raised when the value changes
  84960. */
  84961. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84962. /** Gets or sets the color of the color picker */
  84963. get value(): BABYLON.Color3;
  84964. set value(value: BABYLON.Color3);
  84965. /**
  84966. * Gets or sets control width
  84967. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84968. */
  84969. get width(): string | number;
  84970. set width(value: string | number);
  84971. /**
  84972. * Gets or sets control height
  84973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84974. */
  84975. get height(): string | number;
  84976. /** Gets or sets control height */
  84977. set height(value: string | number);
  84978. /** Gets or sets control size */
  84979. get size(): string | number;
  84980. set size(value: string | number);
  84981. /**
  84982. * Creates a new ColorPicker
  84983. * @param name defines the control name
  84984. */
  84985. constructor(name?: string | undefined);
  84986. protected _getTypeName(): string;
  84987. /** @hidden */
  84988. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84989. private _updateSquareProps;
  84990. private _drawGradientSquare;
  84991. private _drawCircle;
  84992. private _createColorWheelCanvas;
  84993. /** @hidden */
  84994. _draw(context: CanvasRenderingContext2D): void;
  84995. private _pointerIsDown;
  84996. private _updateValueFromPointer;
  84997. private _isPointOnSquare;
  84998. private _isPointOnWheel;
  84999. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85000. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85001. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85002. _onCanvasBlur(): void;
  85003. /**
  85004. * This function expands the color picker by creating a color picker dialog with manual
  85005. * color value input and the ability to save colors into an array to be used later in
  85006. * subsequent launches of the dialogue.
  85007. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  85008. * @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.
  85009. * @returns picked color as a hex string and the saved colors array as hex strings.
  85010. */
  85011. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  85012. pickerWidth?: string;
  85013. pickerHeight?: string;
  85014. headerHeight?: string;
  85015. lastColor?: string;
  85016. swatchLimit?: number;
  85017. numSwatchesPerLine?: number;
  85018. savedColors?: Array<string>;
  85019. }): Promise<{
  85020. savedColors?: string[];
  85021. pickedColor: string;
  85022. }>;
  85023. }
  85024. }
  85025. declare module BABYLON.GUI {
  85026. /** Class used to create 2D ellipse containers */
  85027. export class Ellipse extends Container {
  85028. name?: string | undefined;
  85029. private _thickness;
  85030. /** Gets or sets border thickness */
  85031. get thickness(): number;
  85032. set thickness(value: number);
  85033. /**
  85034. * Creates a new Ellipse
  85035. * @param name defines the control name
  85036. */
  85037. constructor(name?: string | undefined);
  85038. protected _getTypeName(): string;
  85039. protected _localDraw(context: CanvasRenderingContext2D): void;
  85040. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85041. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  85042. }
  85043. }
  85044. declare module BABYLON.GUI {
  85045. /**
  85046. * Class used to create a focusable button that can easily handle keyboard events
  85047. */
  85048. export class FocusableButton extends Button implements IFocusableControl {
  85049. name?: string | undefined;
  85050. /** Highlight color when button is focused */
  85051. focusedColor: BABYLON.Nullable<string>;
  85052. private _isFocused;
  85053. private _unfocusedColor;
  85054. /** BABYLON.Observable raised when the control gets the focus */
  85055. onFocusObservable: BABYLON.Observable<Button>;
  85056. /** BABYLON.Observable raised when the control loses the focus */
  85057. onBlurObservable: BABYLON.Observable<Button>;
  85058. /** BABYLON.Observable raised when a key event was processed */
  85059. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  85060. constructor(name?: string | undefined);
  85061. /** @hidden */
  85062. onBlur(): void;
  85063. /** @hidden */
  85064. onFocus(): void;
  85065. /**
  85066. * Function called to get the list of controls that should not steal the focus from this control
  85067. * @returns an array of controls
  85068. */
  85069. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  85070. /**
  85071. * Function to focus a button programmatically
  85072. */
  85073. focus(): void;
  85074. /**
  85075. * Function to unfocus a button programmatically
  85076. */
  85077. blur(): void;
  85078. /**
  85079. * Handles the keyboard event
  85080. * @param evt Defines the KeyboardEvent
  85081. */
  85082. processKeyboard(evt: KeyboardEvent): void;
  85083. /** @hidden */
  85084. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85085. /** @hidden */
  85086. displose(): void;
  85087. }
  85088. }
  85089. declare module BABYLON.GUI {
  85090. /**
  85091. * Class used to create a password control
  85092. */
  85093. export class InputPassword extends InputText {
  85094. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  85095. }
  85096. }
  85097. declare module BABYLON.GUI {
  85098. /** Class used to render 2D lines */
  85099. export class Line extends Control {
  85100. name?: string | undefined;
  85101. private _lineWidth;
  85102. private _x1;
  85103. private _y1;
  85104. private _x2;
  85105. private _y2;
  85106. private _dash;
  85107. private _connectedControl;
  85108. private _connectedControlDirtyObserver;
  85109. /** Gets or sets the dash pattern */
  85110. get dash(): Array<number>;
  85111. set dash(value: Array<number>);
  85112. /** Gets or sets the control connected with the line end */
  85113. get connectedControl(): Control;
  85114. set connectedControl(value: Control);
  85115. /** Gets or sets start coordinates on X axis */
  85116. get x1(): string | number;
  85117. set x1(value: string | number);
  85118. /** Gets or sets start coordinates on Y axis */
  85119. get y1(): string | number;
  85120. set y1(value: string | number);
  85121. /** Gets or sets end coordinates on X axis */
  85122. get x2(): string | number;
  85123. set x2(value: string | number);
  85124. /** Gets or sets end coordinates on Y axis */
  85125. get y2(): string | number;
  85126. set y2(value: string | number);
  85127. /** Gets or sets line width */
  85128. get lineWidth(): number;
  85129. set lineWidth(value: number);
  85130. /** Gets or sets horizontal alignment */
  85131. set horizontalAlignment(value: number);
  85132. /** Gets or sets vertical alignment */
  85133. set verticalAlignment(value: number);
  85134. private get _effectiveX2();
  85135. private get _effectiveY2();
  85136. /**
  85137. * Creates a new Line
  85138. * @param name defines the control name
  85139. */
  85140. constructor(name?: string | undefined);
  85141. protected _getTypeName(): string;
  85142. _draw(context: CanvasRenderingContext2D): void;
  85143. _measure(): void;
  85144. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85145. /**
  85146. * Move one end of the line given 3D cartesian coordinates.
  85147. * @param position Targeted world position
  85148. * @param scene BABYLON.Scene
  85149. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85150. */
  85151. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  85152. /**
  85153. * Move one end of the line to a position in screen absolute space.
  85154. * @param projectedPosition Position in screen absolute space (X, Y)
  85155. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  85156. */
  85157. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  85158. }
  85159. }
  85160. declare module BABYLON.GUI {
  85161. /**
  85162. * Class used to store a point for a MultiLine object.
  85163. * The point can be pure 2D coordinates, a mesh or a control
  85164. */
  85165. export class MultiLinePoint {
  85166. private _multiLine;
  85167. private _x;
  85168. private _y;
  85169. private _control;
  85170. private _mesh;
  85171. private _controlObserver;
  85172. private _meshObserver;
  85173. /** @hidden */
  85174. _point: BABYLON.Vector3;
  85175. /**
  85176. * Creates a new MultiLinePoint
  85177. * @param multiLine defines the source MultiLine object
  85178. */
  85179. constructor(multiLine: MultiLine);
  85180. /** Gets or sets x coordinate */
  85181. get x(): string | number;
  85182. set x(value: string | number);
  85183. /** Gets or sets y coordinate */
  85184. get y(): string | number;
  85185. set y(value: string | number);
  85186. /** Gets or sets the control associated with this point */
  85187. get control(): BABYLON.Nullable<Control>;
  85188. set control(value: BABYLON.Nullable<Control>);
  85189. /** Gets or sets the mesh associated with this point */
  85190. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85191. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  85192. /** Resets links */
  85193. resetLinks(): void;
  85194. /**
  85195. * Gets a translation vector with Z component
  85196. * @returns the translation vector
  85197. */
  85198. translate(): BABYLON.Vector3;
  85199. private _translatePoint;
  85200. /** Release associated resources */
  85201. dispose(): void;
  85202. }
  85203. }
  85204. declare module BABYLON.GUI {
  85205. /**
  85206. * Class used to create multi line control
  85207. */
  85208. export class MultiLine extends Control {
  85209. name?: string | undefined;
  85210. private _lineWidth;
  85211. private _dash;
  85212. private _points;
  85213. private _minX;
  85214. private _minY;
  85215. private _maxX;
  85216. private _maxY;
  85217. /**
  85218. * Creates a new MultiLine
  85219. * @param name defines the control name
  85220. */
  85221. constructor(name?: string | undefined);
  85222. /** Gets or sets dash pattern */
  85223. get dash(): Array<number>;
  85224. set dash(value: Array<number>);
  85225. /**
  85226. * Gets point stored at specified index
  85227. * @param index defines the index to look for
  85228. * @returns the requested point if found
  85229. */
  85230. getAt(index: number): MultiLinePoint;
  85231. /** Function called when a point is updated */
  85232. onPointUpdate: () => void;
  85233. /**
  85234. * Adds new points to the point collection
  85235. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  85236. * @returns the list of created MultiLinePoint
  85237. */
  85238. add(...items: (AbstractMesh | Control | {
  85239. x: string | number;
  85240. y: string | number;
  85241. })[]): MultiLinePoint[];
  85242. /**
  85243. * Adds a new point to the point collection
  85244. * @param item defines the item (mesh, control or 2d coordiantes) to add
  85245. * @returns the created MultiLinePoint
  85246. */
  85247. push(item?: (AbstractMesh | Control | {
  85248. x: string | number;
  85249. y: string | number;
  85250. })): MultiLinePoint;
  85251. /**
  85252. * Remove a specific value or point from the active point collection
  85253. * @param value defines the value or point to remove
  85254. */
  85255. remove(value: number | MultiLinePoint): void;
  85256. /**
  85257. * Resets this object to initial state (no point)
  85258. */
  85259. reset(): void;
  85260. /**
  85261. * Resets all links
  85262. */
  85263. resetLinks(): void;
  85264. /** Gets or sets line width */
  85265. get lineWidth(): number;
  85266. set lineWidth(value: number);
  85267. set horizontalAlignment(value: number);
  85268. set verticalAlignment(value: number);
  85269. protected _getTypeName(): string;
  85270. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85271. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85272. _measure(): void;
  85273. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85274. dispose(): void;
  85275. }
  85276. }
  85277. declare module BABYLON.GUI {
  85278. /**
  85279. * Class used to create radio button controls
  85280. */
  85281. export class RadioButton extends Control {
  85282. name?: string | undefined;
  85283. private _isChecked;
  85284. private _background;
  85285. private _checkSizeRatio;
  85286. private _thickness;
  85287. /** Gets or sets border thickness */
  85288. get thickness(): number;
  85289. set thickness(value: number);
  85290. /** Gets or sets group name */
  85291. group: string;
  85292. /** BABYLON.Observable raised when isChecked is changed */
  85293. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  85294. /** Gets or sets a value indicating the ratio between overall size and check size */
  85295. get checkSizeRatio(): number;
  85296. set checkSizeRatio(value: number);
  85297. /** Gets or sets background color */
  85298. get background(): string;
  85299. set background(value: string);
  85300. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  85301. get isChecked(): boolean;
  85302. set isChecked(value: boolean);
  85303. /**
  85304. * Creates a new RadioButton
  85305. * @param name defines the control name
  85306. */
  85307. constructor(name?: string | undefined);
  85308. protected _getTypeName(): string;
  85309. _draw(context: CanvasRenderingContext2D): void;
  85310. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85311. /**
  85312. * Utility function to easily create a radio button with a header
  85313. * @param title defines the label to use for the header
  85314. * @param group defines the group to use for the radio button
  85315. * @param isChecked defines the initial state of the radio button
  85316. * @param onValueChanged defines the callback to call when value changes
  85317. * @returns a StackPanel containing the radio button and a textBlock
  85318. */
  85319. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  85320. }
  85321. }
  85322. declare module BABYLON.GUI {
  85323. /**
  85324. * Class used to create slider controls
  85325. */
  85326. export class BaseSlider extends Control {
  85327. name?: string | undefined;
  85328. protected _thumbWidth: ValueAndUnit;
  85329. private _minimum;
  85330. private _maximum;
  85331. private _value;
  85332. private _isVertical;
  85333. protected _barOffset: ValueAndUnit;
  85334. private _isThumbClamped;
  85335. protected _displayThumb: boolean;
  85336. private _step;
  85337. private _lastPointerDownID;
  85338. protected _effectiveBarOffset: number;
  85339. protected _renderLeft: number;
  85340. protected _renderTop: number;
  85341. protected _renderWidth: number;
  85342. protected _renderHeight: number;
  85343. protected _backgroundBoxLength: number;
  85344. protected _backgroundBoxThickness: number;
  85345. protected _effectiveThumbThickness: number;
  85346. /** BABYLON.Observable raised when the sldier value changes */
  85347. onValueChangedObservable: BABYLON.Observable<number>;
  85348. /** Gets or sets a boolean indicating if the thumb must be rendered */
  85349. get displayThumb(): boolean;
  85350. set displayThumb(value: boolean);
  85351. /** Gets or sets a step to apply to values (0 by default) */
  85352. get step(): number;
  85353. set step(value: number);
  85354. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  85355. get barOffset(): string | number;
  85356. /** Gets main bar offset in pixels*/
  85357. get barOffsetInPixels(): number;
  85358. set barOffset(value: string | number);
  85359. /** Gets or sets thumb width */
  85360. get thumbWidth(): string | number;
  85361. /** Gets thumb width in pixels */
  85362. get thumbWidthInPixels(): number;
  85363. set thumbWidth(value: string | number);
  85364. /** Gets or sets minimum value */
  85365. get minimum(): number;
  85366. set minimum(value: number);
  85367. /** Gets or sets maximum value */
  85368. get maximum(): number;
  85369. set maximum(value: number);
  85370. /** Gets or sets current value */
  85371. get value(): number;
  85372. set value(value: number);
  85373. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  85374. get isVertical(): boolean;
  85375. set isVertical(value: boolean);
  85376. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  85377. get isThumbClamped(): boolean;
  85378. set isThumbClamped(value: boolean);
  85379. /**
  85380. * Creates a new BaseSlider
  85381. * @param name defines the control name
  85382. */
  85383. constructor(name?: string | undefined);
  85384. protected _getTypeName(): string;
  85385. protected _getThumbPosition(): number;
  85386. protected _getThumbThickness(type: string): number;
  85387. protected _prepareRenderingData(type: string): void;
  85388. private _pointerIsDown;
  85389. /** @hidden */
  85390. protected _updateValueFromPointer(x: number, y: number): void;
  85391. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85392. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  85393. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85394. _onCanvasBlur(): void;
  85395. }
  85396. }
  85397. declare module BABYLON.GUI {
  85398. /**
  85399. * Class used to create slider controls
  85400. */
  85401. export class Slider extends BaseSlider {
  85402. name?: string | undefined;
  85403. private _background;
  85404. private _borderColor;
  85405. private _thumbColor;
  85406. private _isThumbCircle;
  85407. protected _displayValueBar: boolean;
  85408. /** Gets or sets a boolean indicating if the value bar must be rendered */
  85409. get displayValueBar(): boolean;
  85410. set displayValueBar(value: boolean);
  85411. /** Gets or sets border color */
  85412. get borderColor(): string;
  85413. set borderColor(value: string);
  85414. /** Gets or sets background color */
  85415. get background(): string;
  85416. set background(value: string);
  85417. /** Gets or sets thumb's color */
  85418. get thumbColor(): string;
  85419. set thumbColor(value: string);
  85420. /** Gets or sets a boolean indicating if the thumb should be round or square */
  85421. get isThumbCircle(): boolean;
  85422. set isThumbCircle(value: boolean);
  85423. /**
  85424. * Creates a new Slider
  85425. * @param name defines the control name
  85426. */
  85427. constructor(name?: string | undefined);
  85428. protected _getTypeName(): string;
  85429. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85430. }
  85431. }
  85432. declare module BABYLON.GUI {
  85433. /** Class used to create a RadioGroup
  85434. * which contains groups of radio buttons
  85435. */
  85436. export class SelectorGroup {
  85437. /** name of SelectorGroup */
  85438. name: string;
  85439. private _groupPanel;
  85440. private _selectors;
  85441. private _groupHeader;
  85442. /**
  85443. * Creates a new SelectorGroup
  85444. * @param name of group, used as a group heading
  85445. */
  85446. constructor(
  85447. /** name of SelectorGroup */
  85448. name: string);
  85449. /** Gets the groupPanel of the SelectorGroup */
  85450. get groupPanel(): StackPanel;
  85451. /** Gets the selectors array */
  85452. get selectors(): StackPanel[];
  85453. /** Gets and sets the group header */
  85454. get header(): string;
  85455. set header(label: string);
  85456. /** @hidden */
  85457. private _addGroupHeader;
  85458. /** @hidden*/
  85459. _getSelector(selectorNb: number): StackPanel | undefined;
  85460. /** Removes the selector at the given position
  85461. * @param selectorNb the position of the selector within the group
  85462. */
  85463. removeSelector(selectorNb: number): void;
  85464. }
  85465. /** Class used to create a CheckboxGroup
  85466. * which contains groups of checkbox buttons
  85467. */
  85468. export class CheckboxGroup extends SelectorGroup {
  85469. /** Adds a checkbox as a control
  85470. * @param text is the label for the selector
  85471. * @param func is the function called when the Selector is checked
  85472. * @param checked is true when Selector is checked
  85473. */
  85474. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  85475. /** @hidden */
  85476. _setSelectorLabel(selectorNb: number, label: string): void;
  85477. /** @hidden */
  85478. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85479. /** @hidden */
  85480. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85481. /** @hidden */
  85482. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85483. }
  85484. /** Class used to create a RadioGroup
  85485. * which contains groups of radio buttons
  85486. */
  85487. export class RadioGroup extends SelectorGroup {
  85488. private _selectNb;
  85489. /** Adds a radio button as a control
  85490. * @param label is the label for the selector
  85491. * @param func is the function called when the Selector is checked
  85492. * @param checked is true when Selector is checked
  85493. */
  85494. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  85495. /** @hidden */
  85496. _setSelectorLabel(selectorNb: number, label: string): void;
  85497. /** @hidden */
  85498. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85499. /** @hidden */
  85500. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85501. /** @hidden */
  85502. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85503. }
  85504. /** Class used to create a SliderGroup
  85505. * which contains groups of slider buttons
  85506. */
  85507. export class SliderGroup extends SelectorGroup {
  85508. /**
  85509. * Adds a slider to the SelectorGroup
  85510. * @param label is the label for the SliderBar
  85511. * @param func is the function called when the Slider moves
  85512. * @param unit is a string describing the units used, eg degrees or metres
  85513. * @param min is the minimum value for the Slider
  85514. * @param max is the maximum value for the Slider
  85515. * @param value is the start value for the Slider between min and max
  85516. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  85517. */
  85518. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  85519. /** @hidden */
  85520. _setSelectorLabel(selectorNb: number, label: string): void;
  85521. /** @hidden */
  85522. _setSelectorLabelColor(selectorNb: number, color: string): void;
  85523. /** @hidden */
  85524. _setSelectorButtonColor(selectorNb: number, color: string): void;
  85525. /** @hidden */
  85526. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  85527. }
  85528. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  85529. * @see https://doc.babylonjs.com/how_to/selector
  85530. */
  85531. export class SelectionPanel extends Rectangle {
  85532. /** name of SelectionPanel */
  85533. name: string;
  85534. /** an array of SelectionGroups */
  85535. groups: SelectorGroup[];
  85536. private _panel;
  85537. private _buttonColor;
  85538. private _buttonBackground;
  85539. private _headerColor;
  85540. private _barColor;
  85541. private _barHeight;
  85542. private _spacerHeight;
  85543. private _labelColor;
  85544. private _groups;
  85545. private _bars;
  85546. /**
  85547. * Creates a new SelectionPanel
  85548. * @param name of SelectionPanel
  85549. * @param groups is an array of SelectionGroups
  85550. */
  85551. constructor(
  85552. /** name of SelectionPanel */
  85553. name: string,
  85554. /** an array of SelectionGroups */
  85555. groups?: SelectorGroup[]);
  85556. protected _getTypeName(): string;
  85557. /** Gets the (stack) panel of the SelectionPanel */
  85558. get panel(): StackPanel;
  85559. /** Gets or sets the headerColor */
  85560. get headerColor(): string;
  85561. set headerColor(color: string);
  85562. private _setHeaderColor;
  85563. /** Gets or sets the button color */
  85564. get buttonColor(): string;
  85565. set buttonColor(color: string);
  85566. private _setbuttonColor;
  85567. /** Gets or sets the label color */
  85568. get labelColor(): string;
  85569. set labelColor(color: string);
  85570. private _setLabelColor;
  85571. /** Gets or sets the button background */
  85572. get buttonBackground(): string;
  85573. set buttonBackground(color: string);
  85574. private _setButtonBackground;
  85575. /** Gets or sets the color of separator bar */
  85576. get barColor(): string;
  85577. set barColor(color: string);
  85578. private _setBarColor;
  85579. /** Gets or sets the height of separator bar */
  85580. get barHeight(): string;
  85581. set barHeight(value: string);
  85582. private _setBarHeight;
  85583. /** Gets or sets the height of spacers*/
  85584. get spacerHeight(): string;
  85585. set spacerHeight(value: string);
  85586. private _setSpacerHeight;
  85587. /** Adds a bar between groups */
  85588. private _addSpacer;
  85589. /** Add a group to the selection panel
  85590. * @param group is the selector group to add
  85591. */
  85592. addGroup(group: SelectorGroup): void;
  85593. /** Remove the group from the given position
  85594. * @param groupNb is the position of the group in the list
  85595. */
  85596. removeGroup(groupNb: number): void;
  85597. /** Change a group header label
  85598. * @param label is the new group header label
  85599. * @param groupNb is the number of the group to relabel
  85600. * */
  85601. setHeaderName(label: string, groupNb: number): void;
  85602. /** Change selector label to the one given
  85603. * @param label is the new selector label
  85604. * @param groupNb is the number of the groupcontaining the selector
  85605. * @param selectorNb is the number of the selector within a group to relabel
  85606. * */
  85607. relabel(label: string, groupNb: number, selectorNb: number): void;
  85608. /** For a given group position remove the selector at the given position
  85609. * @param groupNb is the number of the group to remove the selector from
  85610. * @param selectorNb is the number of the selector within the group
  85611. */
  85612. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  85613. /** For a given group position of correct type add a checkbox button
  85614. * @param groupNb is the number of the group to remove the selector from
  85615. * @param label is the label for the selector
  85616. * @param func is the function called when the Selector is checked
  85617. * @param checked is true when Selector is checked
  85618. */
  85619. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85620. /** For a given group position of correct type add a radio button
  85621. * @param groupNb is the number of the group to remove the selector from
  85622. * @param label is the label for the selector
  85623. * @param func is the function called when the Selector is checked
  85624. * @param checked is true when Selector is checked
  85625. */
  85626. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  85627. /**
  85628. * For a given slider group add a slider
  85629. * @param groupNb is the number of the group to add the slider to
  85630. * @param label is the label for the Slider
  85631. * @param func is the function called when the Slider moves
  85632. * @param unit is a string describing the units used, eg degrees or metres
  85633. * @param min is the minimum value for the Slider
  85634. * @param max is the maximum value for the Slider
  85635. * @param value is the start value for the Slider between min and max
  85636. * @param onVal is the function used to format the value displayed, eg radians to degrees
  85637. */
  85638. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  85639. }
  85640. }
  85641. declare module BABYLON.GUI {
  85642. /**
  85643. * Class used to hold a the container for ScrollViewer
  85644. * @hidden
  85645. */
  85646. export class _ScrollViewerWindow extends Container {
  85647. parentClientWidth: number;
  85648. parentClientHeight: number;
  85649. private _freezeControls;
  85650. private _parentMeasure;
  85651. private _oldLeft;
  85652. private _oldTop;
  85653. get freezeControls(): boolean;
  85654. set freezeControls(value: boolean);
  85655. private _bucketWidth;
  85656. private _bucketHeight;
  85657. private _buckets;
  85658. private _bucketLen;
  85659. get bucketWidth(): number;
  85660. get bucketHeight(): number;
  85661. setBucketSizes(width: number, height: number): void;
  85662. private _useBuckets;
  85663. private _makeBuckets;
  85664. private _dispatchInBuckets;
  85665. private _updateMeasures;
  85666. private _updateChildrenMeasures;
  85667. private _restoreMeasures;
  85668. /**
  85669. * Creates a new ScrollViewerWindow
  85670. * @param name of ScrollViewerWindow
  85671. */
  85672. constructor(name?: string);
  85673. protected _getTypeName(): string;
  85674. /** @hidden */
  85675. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85676. /** @hidden */
  85677. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85678. private _scrollChildren;
  85679. private _scrollChildrenWithBuckets;
  85680. /** @hidden */
  85681. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85682. protected _postMeasure(): void;
  85683. }
  85684. }
  85685. declare module BABYLON.GUI {
  85686. /**
  85687. * Class used to create slider controls
  85688. */
  85689. export class ScrollBar extends BaseSlider {
  85690. name?: string | undefined;
  85691. private _background;
  85692. private _borderColor;
  85693. private _tempMeasure;
  85694. /** Gets or sets border color */
  85695. get borderColor(): string;
  85696. set borderColor(value: string);
  85697. /** Gets or sets background color */
  85698. get background(): string;
  85699. set background(value: string);
  85700. /**
  85701. * Creates a new Slider
  85702. * @param name defines the control name
  85703. */
  85704. constructor(name?: string | undefined);
  85705. protected _getTypeName(): string;
  85706. protected _getThumbThickness(): number;
  85707. _draw(context: CanvasRenderingContext2D): void;
  85708. private _first;
  85709. private _originX;
  85710. private _originY;
  85711. /** @hidden */
  85712. protected _updateValueFromPointer(x: number, y: number): void;
  85713. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85714. }
  85715. }
  85716. declare module BABYLON.GUI {
  85717. /**
  85718. * Class used to create slider controls
  85719. */
  85720. export class ImageScrollBar extends BaseSlider {
  85721. name?: string | undefined;
  85722. private _backgroundBaseImage;
  85723. private _backgroundImage;
  85724. private _thumbImage;
  85725. private _thumbBaseImage;
  85726. private _thumbLength;
  85727. private _thumbHeight;
  85728. private _barImageHeight;
  85729. private _tempMeasure;
  85730. /** Number of 90° rotation to apply on the images when in vertical mode */
  85731. num90RotationInVerticalMode: number;
  85732. /**
  85733. * Gets or sets the image used to render the background for horizontal bar
  85734. */
  85735. get backgroundImage(): Image;
  85736. set backgroundImage(value: Image);
  85737. /**
  85738. * Gets or sets the image used to render the thumb
  85739. */
  85740. get thumbImage(): Image;
  85741. set thumbImage(value: Image);
  85742. /**
  85743. * Gets or sets the length of the thumb
  85744. */
  85745. get thumbLength(): number;
  85746. set thumbLength(value: number);
  85747. /**
  85748. * Gets or sets the height of the thumb
  85749. */
  85750. get thumbHeight(): number;
  85751. set thumbHeight(value: number);
  85752. /**
  85753. * Gets or sets the height of the bar image
  85754. */
  85755. get barImageHeight(): number;
  85756. set barImageHeight(value: number);
  85757. /**
  85758. * Creates a new ImageScrollBar
  85759. * @param name defines the control name
  85760. */
  85761. constructor(name?: string | undefined);
  85762. protected _getTypeName(): string;
  85763. protected _getThumbThickness(): number;
  85764. _draw(context: CanvasRenderingContext2D): void;
  85765. private _first;
  85766. private _originX;
  85767. private _originY;
  85768. /** @hidden */
  85769. protected _updateValueFromPointer(x: number, y: number): void;
  85770. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85771. }
  85772. }
  85773. declare module BABYLON.GUI {
  85774. /**
  85775. * Class used to hold a viewer window and sliders in a grid
  85776. */
  85777. export class ScrollViewer extends Rectangle {
  85778. private _grid;
  85779. private _horizontalBarSpace;
  85780. private _verticalBarSpace;
  85781. private _dragSpace;
  85782. private _horizontalBar;
  85783. private _verticalBar;
  85784. private _barColor;
  85785. private _barBackground;
  85786. private _barImage;
  85787. private _horizontalBarImage;
  85788. private _verticalBarImage;
  85789. private _barBackgroundImage;
  85790. private _horizontalBarBackgroundImage;
  85791. private _verticalBarBackgroundImage;
  85792. private _barSize;
  85793. private _window;
  85794. private _pointerIsOver;
  85795. private _wheelPrecision;
  85796. private _onWheelObserver;
  85797. private _clientWidth;
  85798. private _clientHeight;
  85799. private _useImageBar;
  85800. private _thumbLength;
  85801. private _thumbHeight;
  85802. private _barImageHeight;
  85803. private _horizontalBarImageHeight;
  85804. private _verticalBarImageHeight;
  85805. private _oldWindowContentsWidth;
  85806. private _oldWindowContentsHeight;
  85807. /**
  85808. * Gets the horizontal scrollbar
  85809. */
  85810. get horizontalBar(): ScrollBar | ImageScrollBar;
  85811. /**
  85812. * Gets the vertical scrollbar
  85813. */
  85814. get verticalBar(): ScrollBar | ImageScrollBar;
  85815. /**
  85816. * Adds a new control to the current container
  85817. * @param control defines the control to add
  85818. * @returns the current container
  85819. */
  85820. addControl(control: BABYLON.Nullable<Control>): Container;
  85821. /**
  85822. * Removes a control from the current container
  85823. * @param control defines the control to remove
  85824. * @returns the current container
  85825. */
  85826. removeControl(control: Control): Container;
  85827. /** Gets the list of children */
  85828. get children(): Control[];
  85829. _flagDescendantsAsMatrixDirty(): void;
  85830. /**
  85831. * Freezes or unfreezes the controls in the window.
  85832. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85833. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85834. */
  85835. get freezeControls(): boolean;
  85836. set freezeControls(value: boolean);
  85837. /** Gets the bucket width */
  85838. get bucketWidth(): number;
  85839. /** Gets the bucket height */
  85840. get bucketHeight(): number;
  85841. /**
  85842. * Sets the bucket sizes.
  85843. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85844. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85845. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85846. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85847. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85848. * used), that's why it is not enabled by default.
  85849. * @param width width of the bucket
  85850. * @param height height of the bucket
  85851. */
  85852. setBucketSizes(width: number, height: number): void;
  85853. private _forceHorizontalBar;
  85854. private _forceVerticalBar;
  85855. /**
  85856. * Forces the horizontal scroll bar to be displayed
  85857. */
  85858. get forceHorizontalBar(): boolean;
  85859. set forceHorizontalBar(value: boolean);
  85860. /**
  85861. * Forces the vertical scroll bar to be displayed
  85862. */
  85863. get forceVerticalBar(): boolean;
  85864. set forceVerticalBar(value: boolean);
  85865. /**
  85866. * Creates a new ScrollViewer
  85867. * @param name of ScrollViewer
  85868. */
  85869. constructor(name?: string, isImageBased?: boolean);
  85870. /** Reset the scroll viewer window to initial size */
  85871. resetWindow(): void;
  85872. protected _getTypeName(): string;
  85873. private _buildClientSizes;
  85874. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85875. protected _postMeasure(): void;
  85876. /**
  85877. * Gets or sets the mouse wheel precision
  85878. * from 0 to 1 with a default value of 0.05
  85879. * */
  85880. get wheelPrecision(): number;
  85881. set wheelPrecision(value: number);
  85882. /** Gets or sets the scroll bar container background color */
  85883. get scrollBackground(): string;
  85884. set scrollBackground(color: string);
  85885. /** Gets or sets the bar color */
  85886. get barColor(): string;
  85887. set barColor(color: string);
  85888. /** Gets or sets the bar image */
  85889. get thumbImage(): Image;
  85890. set thumbImage(value: Image);
  85891. /** Gets or sets the horizontal bar image */
  85892. get horizontalThumbImage(): Image;
  85893. set horizontalThumbImage(value: Image);
  85894. /** Gets or sets the vertical bar image */
  85895. get verticalThumbImage(): Image;
  85896. set verticalThumbImage(value: Image);
  85897. /** Gets or sets the size of the bar */
  85898. get barSize(): number;
  85899. set barSize(value: number);
  85900. /** Gets or sets the length of the thumb */
  85901. get thumbLength(): number;
  85902. set thumbLength(value: number);
  85903. /** Gets or sets the height of the thumb */
  85904. get thumbHeight(): number;
  85905. set thumbHeight(value: number);
  85906. /** Gets or sets the height of the bar image */
  85907. get barImageHeight(): number;
  85908. set barImageHeight(value: number);
  85909. /** Gets or sets the height of the horizontal bar image */
  85910. get horizontalBarImageHeight(): number;
  85911. set horizontalBarImageHeight(value: number);
  85912. /** Gets or sets the height of the vertical bar image */
  85913. get verticalBarImageHeight(): number;
  85914. set verticalBarImageHeight(value: number);
  85915. /** Gets or sets the bar background */
  85916. get barBackground(): string;
  85917. set barBackground(color: string);
  85918. /** Gets or sets the bar background image */
  85919. get barImage(): Image;
  85920. set barImage(value: Image);
  85921. /** Gets or sets the horizontal bar background image */
  85922. get horizontalBarImage(): Image;
  85923. set horizontalBarImage(value: Image);
  85924. /** Gets or sets the vertical bar background image */
  85925. get verticalBarImage(): Image;
  85926. set verticalBarImage(value: Image);
  85927. private _setWindowPosition;
  85928. /** @hidden */
  85929. private _updateScroller;
  85930. _link(host: AdvancedDynamicTexture): void;
  85931. /** @hidden */
  85932. private _addBar;
  85933. /** @hidden */
  85934. private _attachWheel;
  85935. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85936. /** Releases associated resources */
  85937. dispose(): void;
  85938. }
  85939. }
  85940. declare module BABYLON.GUI {
  85941. /**
  85942. * Class used to create toggle buttons
  85943. */
  85944. export class ToggleButton extends Rectangle {
  85945. name?: string | undefined;
  85946. /**
  85947. * Function called to generate the toActive animation
  85948. */
  85949. toActiveAnimation: () => void;
  85950. /**
  85951. * Function called to generate the toInactive animation
  85952. */
  85953. toInactiveAnimation: () => void;
  85954. /**
  85955. * Function called to generate a pointer enter animation when the toggle button is active.
  85956. */
  85957. pointerEnterActiveAnimation: () => void;
  85958. /**
  85959. * Function called to generate a pointer out animation when the toggle button is active.
  85960. */
  85961. pointerOutActiveAnimation: () => void;
  85962. /**
  85963. * Function called to generate a pointer down animation when the toggle button is active.
  85964. */
  85965. pointerDownActiveAnimation: () => void;
  85966. /**
  85967. * Function called to generate a pointer up animation when the toggle button is active.
  85968. */
  85969. pointerUpActiveAnimation: () => void;
  85970. /**
  85971. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85972. */
  85973. pointerEnterInactiveAnimation: () => void;
  85974. /**
  85975. * Function called to generate a pointer out animation when the toggle button is inactive.
  85976. */
  85977. pointerOutInactiveAnimation: () => void;
  85978. /**
  85979. * Function called to generate a pointer down animation when the toggle button is inactive.
  85980. */
  85981. pointerDownInactiveAnimation: () => void;
  85982. /**
  85983. * Function called to generate a pointer up animation when the toggle button is inactive.
  85984. */
  85985. pointerUpInactiveAnimation: () => void;
  85986. /** BABYLON.Observable raised when isActive is changed */
  85987. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85988. /**
  85989. * 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
  85990. */
  85991. delegatePickingToChildren: boolean;
  85992. private _image;
  85993. /**
  85994. * Returns the ToggleButton's image control if it exists
  85995. */
  85996. get image(): BABYLON.Nullable<Image>;
  85997. private _textBlock;
  85998. /**
  85999. * Returns the ToggleButton's child TextBlock control if it exists
  86000. */
  86001. get textBlock(): BABYLON.Nullable<TextBlock>;
  86002. private _group;
  86003. /** Gets or sets group name this toggle button belongs to */
  86004. get group(): string;
  86005. set group(value: string);
  86006. private _isActive;
  86007. /** Gets or sets a boolean indicating if the toogle button is active or not */
  86008. get isActive(): boolean;
  86009. set isActive(value: boolean);
  86010. /**
  86011. * Creates a new ToggleButton
  86012. * @param name defines the control name
  86013. * @param group defines the toggle group this toggle belongs to
  86014. */
  86015. constructor(name?: string | undefined, group?: string);
  86016. protected _getTypeName(): string;
  86017. /** @hidden */
  86018. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  86019. /** @hidden */
  86020. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  86021. /** @hidden */
  86022. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  86023. /** @hidden */
  86024. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  86025. /** @hidden */
  86026. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  86027. }
  86028. }
  86029. declare module BABYLON.GUI {
  86030. /** Class used to render a grid */
  86031. export class DisplayGrid extends Control {
  86032. name?: string | undefined;
  86033. private _cellWidth;
  86034. private _cellHeight;
  86035. private _minorLineTickness;
  86036. private _minorLineColor;
  86037. private _majorLineTickness;
  86038. private _majorLineColor;
  86039. private _majorLineFrequency;
  86040. private _background;
  86041. private _displayMajorLines;
  86042. private _displayMinorLines;
  86043. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  86044. get displayMinorLines(): boolean;
  86045. set displayMinorLines(value: boolean);
  86046. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  86047. get displayMajorLines(): boolean;
  86048. set displayMajorLines(value: boolean);
  86049. /** Gets or sets background color (Black by default) */
  86050. get background(): string;
  86051. set background(value: string);
  86052. /** Gets or sets the width of each cell (20 by default) */
  86053. get cellWidth(): number;
  86054. set cellWidth(value: number);
  86055. /** Gets or sets the height of each cell (20 by default) */
  86056. get cellHeight(): number;
  86057. set cellHeight(value: number);
  86058. /** Gets or sets the tickness of minor lines (1 by default) */
  86059. get minorLineTickness(): number;
  86060. set minorLineTickness(value: number);
  86061. /** Gets or sets the color of minor lines (DarkGray by default) */
  86062. get minorLineColor(): string;
  86063. set minorLineColor(value: string);
  86064. /** Gets or sets the tickness of major lines (2 by default) */
  86065. get majorLineTickness(): number;
  86066. set majorLineTickness(value: number);
  86067. /** Gets or sets the color of major lines (White by default) */
  86068. get majorLineColor(): string;
  86069. set majorLineColor(value: string);
  86070. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  86071. get majorLineFrequency(): number;
  86072. set majorLineFrequency(value: number);
  86073. /**
  86074. * Creates a new GridDisplayRectangle
  86075. * @param name defines the control name
  86076. */
  86077. constructor(name?: string | undefined);
  86078. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86079. protected _getTypeName(): string;
  86080. }
  86081. }
  86082. declare module BABYLON.GUI {
  86083. /**
  86084. * Class used to create slider controls based on images
  86085. */
  86086. export class ImageBasedSlider extends BaseSlider {
  86087. name?: string | undefined;
  86088. private _backgroundImage;
  86089. private _thumbImage;
  86090. private _valueBarImage;
  86091. private _tempMeasure;
  86092. get displayThumb(): boolean;
  86093. set displayThumb(value: boolean);
  86094. /**
  86095. * Gets or sets the image used to render the background
  86096. */
  86097. get backgroundImage(): Image;
  86098. set backgroundImage(value: Image);
  86099. /**
  86100. * Gets or sets the image used to render the value bar
  86101. */
  86102. get valueBarImage(): Image;
  86103. set valueBarImage(value: Image);
  86104. /**
  86105. * Gets or sets the image used to render the thumb
  86106. */
  86107. get thumbImage(): Image;
  86108. set thumbImage(value: Image);
  86109. /**
  86110. * Creates a new ImageBasedSlider
  86111. * @param name defines the control name
  86112. */
  86113. constructor(name?: string | undefined);
  86114. protected _getTypeName(): string;
  86115. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  86116. }
  86117. }
  86118. declare module BABYLON.GUI {
  86119. /**
  86120. * Forcing an export so that this code will execute
  86121. * @hidden
  86122. */
  86123. const name = "Statics";
  86124. }
  86125. declare module BABYLON.GUI {
  86126. /**
  86127. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  86128. */
  86129. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  86130. /**
  86131. * Define the instrumented AdvancedDynamicTexture.
  86132. */
  86133. texture: AdvancedDynamicTexture;
  86134. private _captureRenderTime;
  86135. private _renderTime;
  86136. private _captureLayoutTime;
  86137. private _layoutTime;
  86138. private _onBeginRenderObserver;
  86139. private _onEndRenderObserver;
  86140. private _onBeginLayoutObserver;
  86141. private _onEndLayoutObserver;
  86142. /**
  86143. * Gets the perf counter used to capture render time
  86144. */
  86145. get renderTimeCounter(): BABYLON.PerfCounter;
  86146. /**
  86147. * Gets the perf counter used to capture layout time
  86148. */
  86149. get layoutTimeCounter(): BABYLON.PerfCounter;
  86150. /**
  86151. * Enable or disable the render time capture
  86152. */
  86153. get captureRenderTime(): boolean;
  86154. set captureRenderTime(value: boolean);
  86155. /**
  86156. * Enable or disable the layout time capture
  86157. */
  86158. get captureLayoutTime(): boolean;
  86159. set captureLayoutTime(value: boolean);
  86160. /**
  86161. * Instantiates a new advanced dynamic texture instrumentation.
  86162. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  86163. * @param texture Defines the AdvancedDynamicTexture to instrument
  86164. */
  86165. constructor(
  86166. /**
  86167. * Define the instrumented AdvancedDynamicTexture.
  86168. */
  86169. texture: AdvancedDynamicTexture);
  86170. /**
  86171. * Dispose and release associated resources.
  86172. */
  86173. dispose(): void;
  86174. }
  86175. }
  86176. declare module BABYLON.GUI {
  86177. /**
  86178. * Class used to load GUI via XML.
  86179. */
  86180. export class XmlLoader {
  86181. private _nodes;
  86182. private _nodeTypes;
  86183. private _isLoaded;
  86184. private _objectAttributes;
  86185. private _parentClass;
  86186. /**
  86187. * Create a new xml loader
  86188. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  86189. */
  86190. constructor(parentClass?: null);
  86191. private _getChainElement;
  86192. private _getClassAttribute;
  86193. private _createGuiElement;
  86194. private _parseGrid;
  86195. private _parseElement;
  86196. private _prepareSourceElement;
  86197. private _parseElementsFromSource;
  86198. private _parseXml;
  86199. /**
  86200. * Gets if the loading has finished.
  86201. * @returns whether the loading has finished or not
  86202. */
  86203. isLoaded(): boolean;
  86204. /**
  86205. * Gets a loaded node / control by id.
  86206. * @param id the Controls id set in the xml
  86207. * @returns element of type Control
  86208. */
  86209. getNodeById(id: string): any;
  86210. /**
  86211. * Gets all loaded nodes / controls
  86212. * @returns Array of controls
  86213. */
  86214. getNodes(): any;
  86215. /**
  86216. * Initiates the xml layout loading
  86217. * @param xmlFile defines the xml layout to load
  86218. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  86219. * @param callback defines the callback called on layout load.
  86220. */
  86221. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  86222. }
  86223. }
  86224. declare module BABYLON.GUI {
  86225. /**
  86226. * Class used to create containers for controls
  86227. */
  86228. export class Container3D extends Control3D {
  86229. private _blockLayout;
  86230. /**
  86231. * Gets the list of child controls
  86232. */
  86233. protected _children: Control3D[];
  86234. /**
  86235. * Gets the list of child controls
  86236. */
  86237. get children(): Array<Control3D>;
  86238. /**
  86239. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  86240. * This is helpful to optimize layout operation when adding multiple children in a row
  86241. */
  86242. get blockLayout(): boolean;
  86243. set blockLayout(value: boolean);
  86244. /**
  86245. * Creates a new container
  86246. * @param name defines the container name
  86247. */
  86248. constructor(name?: string);
  86249. /**
  86250. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  86251. * @returns the current container
  86252. */
  86253. updateLayout(): Container3D;
  86254. /**
  86255. * Gets a boolean indicating if the given control is in the children of this control
  86256. * @param control defines the control to check
  86257. * @returns true if the control is in the child list
  86258. */
  86259. containsControl(control: Control3D): boolean;
  86260. /**
  86261. * Adds a control to the children of this control
  86262. * @param control defines the control to add
  86263. * @returns the current container
  86264. */
  86265. addControl(control: Control3D): Container3D;
  86266. /**
  86267. * This function will be called everytime a new control is added
  86268. */
  86269. protected _arrangeChildren(): void;
  86270. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86271. /**
  86272. * Removes a control from the children of this control
  86273. * @param control defines the control to remove
  86274. * @returns the current container
  86275. */
  86276. removeControl(control: Control3D): Container3D;
  86277. protected _getTypeName(): string;
  86278. /**
  86279. * Releases all associated resources
  86280. */
  86281. dispose(): void;
  86282. /** Control rotation will remain unchanged */
  86283. static readonly UNSET_ORIENTATION: number;
  86284. /** Control will rotate to make it look at sphere central axis */
  86285. static readonly FACEORIGIN_ORIENTATION: number;
  86286. /** Control will rotate to make it look back at sphere central axis */
  86287. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  86288. /** Control will rotate to look at z axis (0, 0, 1) */
  86289. static readonly FACEFORWARD_ORIENTATION: number;
  86290. /** Control will rotate to look at negative z axis (0, 0, -1) */
  86291. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  86292. }
  86293. }
  86294. declare module BABYLON.GUI {
  86295. /**
  86296. * Class used to manage 3D user interface
  86297. * @see https://doc.babylonjs.com/how_to/gui3d
  86298. */
  86299. export class GUI3DManager implements BABYLON.IDisposable {
  86300. private _scene;
  86301. private _sceneDisposeObserver;
  86302. private _utilityLayer;
  86303. private _rootContainer;
  86304. private _pointerObserver;
  86305. private _pointerOutObserver;
  86306. /** @hidden */
  86307. _lastPickedControl: Control3D;
  86308. /** @hidden */
  86309. _lastControlOver: {
  86310. [pointerId: number]: Control3D;
  86311. };
  86312. /** @hidden */
  86313. _lastControlDown: {
  86314. [pointerId: number]: Control3D;
  86315. };
  86316. /**
  86317. * BABYLON.Observable raised when the point picked by the pointer events changed
  86318. */
  86319. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  86320. /** @hidden */
  86321. _sharedMaterials: {
  86322. [key: string]: BABYLON.Material;
  86323. };
  86324. /** Gets the hosting scene */
  86325. get scene(): BABYLON.Scene;
  86326. /** Gets associated utility layer */
  86327. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  86328. /**
  86329. * Creates a new GUI3DManager
  86330. * @param scene
  86331. */
  86332. constructor(scene?: BABYLON.Scene);
  86333. private _handlePointerOut;
  86334. private _doPicking;
  86335. /**
  86336. * Gets the root container
  86337. */
  86338. get rootContainer(): Container3D;
  86339. /**
  86340. * Gets a boolean indicating if the given control is in the root child list
  86341. * @param control defines the control to check
  86342. * @returns true if the control is in the root child list
  86343. */
  86344. containsControl(control: Control3D): boolean;
  86345. /**
  86346. * Adds a control to the root child list
  86347. * @param control defines the control to add
  86348. * @returns the current manager
  86349. */
  86350. addControl(control: Control3D): GUI3DManager;
  86351. /**
  86352. * Removes a control from the root child list
  86353. * @param control defines the control to remove
  86354. * @returns the current container
  86355. */
  86356. removeControl(control: Control3D): GUI3DManager;
  86357. /**
  86358. * Releases all associated resources
  86359. */
  86360. dispose(): void;
  86361. }
  86362. }
  86363. declare module BABYLON.GUI {
  86364. /**
  86365. * Class used to transport BABYLON.Vector3 information for pointer events
  86366. */
  86367. export class Vector3WithInfo extends BABYLON.Vector3 {
  86368. /** defines the current mouse button index */
  86369. buttonIndex: number;
  86370. /**
  86371. * Creates a new Vector3WithInfo
  86372. * @param source defines the vector3 data to transport
  86373. * @param buttonIndex defines the current mouse button index
  86374. */
  86375. constructor(source: BABYLON.Vector3,
  86376. /** defines the current mouse button index */
  86377. buttonIndex?: number);
  86378. }
  86379. }
  86380. declare module BABYLON.GUI {
  86381. /**
  86382. * Class used as base class for controls
  86383. */
  86384. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  86385. /** Defines the control name */
  86386. name?: string | undefined;
  86387. /** @hidden */
  86388. _host: GUI3DManager;
  86389. private _node;
  86390. private _downCount;
  86391. private _enterCount;
  86392. private _downPointerIds;
  86393. private _isVisible;
  86394. /** Gets or sets the control position in world space */
  86395. get position(): BABYLON.Vector3;
  86396. set position(value: BABYLON.Vector3);
  86397. /** Gets or sets the control scaling in world space */
  86398. get scaling(): BABYLON.Vector3;
  86399. set scaling(value: BABYLON.Vector3);
  86400. /** Callback used to start pointer enter animation */
  86401. pointerEnterAnimation: () => void;
  86402. /** Callback used to start pointer out animation */
  86403. pointerOutAnimation: () => void;
  86404. /** Callback used to start pointer down animation */
  86405. pointerDownAnimation: () => void;
  86406. /** Callback used to start pointer up animation */
  86407. pointerUpAnimation: () => void;
  86408. /**
  86409. * An event triggered when the pointer move over the control
  86410. */
  86411. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  86412. /**
  86413. * An event triggered when the pointer move out of the control
  86414. */
  86415. onPointerOutObservable: BABYLON.Observable<Control3D>;
  86416. /**
  86417. * An event triggered when the pointer taps the control
  86418. */
  86419. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  86420. /**
  86421. * An event triggered when pointer is up
  86422. */
  86423. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  86424. /**
  86425. * An event triggered when a control is clicked on (with a mouse)
  86426. */
  86427. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  86428. /**
  86429. * An event triggered when pointer enters the control
  86430. */
  86431. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  86432. /**
  86433. * Gets or sets the parent container
  86434. */
  86435. parent: BABYLON.Nullable<Container3D>;
  86436. private _behaviors;
  86437. /**
  86438. * Gets the list of attached behaviors
  86439. * @see https://doc.babylonjs.com/features/behaviour
  86440. */
  86441. get behaviors(): BABYLON.Behavior<Control3D>[];
  86442. /**
  86443. * Attach a behavior to the control
  86444. * @see https://doc.babylonjs.com/features/behaviour
  86445. * @param behavior defines the behavior to attach
  86446. * @returns the current control
  86447. */
  86448. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86449. /**
  86450. * Remove an attached behavior
  86451. * @see https://doc.babylonjs.com/features/behaviour
  86452. * @param behavior defines the behavior to attach
  86453. * @returns the current control
  86454. */
  86455. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  86456. /**
  86457. * Gets an attached behavior by name
  86458. * @param name defines the name of the behavior to look for
  86459. * @see https://doc.babylonjs.com/features/behaviour
  86460. * @returns null if behavior was not found else the requested behavior
  86461. */
  86462. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  86463. /** Gets or sets a boolean indicating if the control is visible */
  86464. get isVisible(): boolean;
  86465. set isVisible(value: boolean);
  86466. /**
  86467. * Creates a new control
  86468. * @param name defines the control name
  86469. */
  86470. constructor(
  86471. /** Defines the control name */
  86472. name?: string | undefined);
  86473. /**
  86474. * Gets a string representing the class name
  86475. */
  86476. get typeName(): string;
  86477. /**
  86478. * Get the current class name of the control.
  86479. * @returns current class name
  86480. */
  86481. getClassName(): string;
  86482. protected _getTypeName(): string;
  86483. /**
  86484. * Gets the transform node used by this control
  86485. */
  86486. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  86487. /**
  86488. * Gets the mesh used to render this control
  86489. */
  86490. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  86491. /**
  86492. * Link the control as child of the given node
  86493. * @param node defines the node to link to. Use null to unlink the control
  86494. * @returns the current control
  86495. */
  86496. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  86497. /** @hidden **/
  86498. _prepareNode(scene: BABYLON.Scene): void;
  86499. protected _injectGUI3DMetadata(node: BABYLON.TransformNode): any;
  86500. /**
  86501. * Node creation.
  86502. * Can be overriden by children
  86503. * @param scene defines the scene where the node must be attached
  86504. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  86505. */
  86506. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  86507. /**
  86508. * Affect a material to the given mesh
  86509. * @param mesh defines the mesh which will represent the control
  86510. */
  86511. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86512. /** @hidden */
  86513. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  86514. /** @hidden */
  86515. _onPointerEnter(target: Control3D): boolean;
  86516. /** @hidden */
  86517. _onPointerOut(target: Control3D): void;
  86518. /** @hidden */
  86519. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86520. /** @hidden */
  86521. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  86522. /** @hidden */
  86523. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  86524. /** @hidden */
  86525. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  86526. /** @hidden */
  86527. _disposeNode(): void;
  86528. /**
  86529. * Releases all associated resources
  86530. */
  86531. dispose(): void;
  86532. }
  86533. }
  86534. declare module BABYLON.GUI {
  86535. /**
  86536. * Class used as a root to all buttons
  86537. */
  86538. export class AbstractButton3D extends Control3D {
  86539. /**
  86540. * Creates a new button
  86541. * @param name defines the control name
  86542. */
  86543. constructor(name?: string);
  86544. protected _getTypeName(): string;
  86545. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86546. }
  86547. }
  86548. declare module BABYLON.GUI {
  86549. /**
  86550. * Class used to create a button in 3D
  86551. */
  86552. export class Button3D extends AbstractButton3D {
  86553. /** @hidden */
  86554. protected _currentMaterial: BABYLON.Material;
  86555. private _facadeTexture;
  86556. private _content;
  86557. private _contentResolution;
  86558. private _contentScaleRatio;
  86559. /**
  86560. * Gets or sets the texture resolution used to render content (512 by default)
  86561. */
  86562. get contentResolution(): BABYLON.int;
  86563. set contentResolution(value: BABYLON.int);
  86564. /**
  86565. * Gets or sets the texture scale ratio used to render content (2 by default)
  86566. */
  86567. get contentScaleRatio(): number;
  86568. set contentScaleRatio(value: number);
  86569. protected _disposeFacadeTexture(): void;
  86570. protected _resetContent(): void;
  86571. /**
  86572. * Creates a new button
  86573. * @param name defines the control name
  86574. */
  86575. constructor(name?: string);
  86576. /**
  86577. * Gets or sets the GUI 2D content used to display the button's facade
  86578. */
  86579. get content(): Control;
  86580. set content(value: Control);
  86581. /**
  86582. * Apply the facade texture (created from the content property).
  86583. * This function can be overloaded by child classes
  86584. * @param facadeTexture defines the AdvancedDynamicTexture to use
  86585. */
  86586. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86587. protected _getTypeName(): string;
  86588. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86589. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86590. /**
  86591. * Releases all associated resources
  86592. */
  86593. dispose(): void;
  86594. }
  86595. }
  86596. declare module BABYLON.GUI {
  86597. /**
  86598. * Abstract class used to create a container panel deployed on the surface of a volume
  86599. */
  86600. export abstract class VolumeBasedPanel extends Container3D {
  86601. private _columns;
  86602. private _rows;
  86603. private _rowThenColum;
  86604. private _orientation;
  86605. protected _cellWidth: number;
  86606. protected _cellHeight: number;
  86607. /**
  86608. * Gets or sets the distance between elements
  86609. */
  86610. margin: number;
  86611. /**
  86612. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  86613. * | Value | Type | Description |
  86614. * | ----- | ----------------------------------- | ----------- |
  86615. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  86616. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  86617. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  86618. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  86619. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  86620. */
  86621. get orientation(): number;
  86622. set orientation(value: number);
  86623. /**
  86624. * Gets or sets the number of columns requested (10 by default).
  86625. * The panel will automatically compute the number of rows based on number of child controls.
  86626. */
  86627. get columns(): BABYLON.int;
  86628. set columns(value: BABYLON.int);
  86629. /**
  86630. * Gets or sets a the number of rows requested.
  86631. * The panel will automatically compute the number of columns based on number of child controls.
  86632. */
  86633. get rows(): BABYLON.int;
  86634. set rows(value: BABYLON.int);
  86635. /**
  86636. * Creates new VolumeBasedPanel
  86637. */
  86638. constructor();
  86639. protected _arrangeChildren(): void;
  86640. /** Child classes must implement this function to provide correct control positioning */
  86641. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86642. /** Child classes can implement this function to provide additional processing */
  86643. protected _finalProcessing(): void;
  86644. }
  86645. }
  86646. declare module BABYLON.GUI {
  86647. /**
  86648. * Class used to create a container panel deployed on the surface of a cylinder
  86649. */
  86650. export class CylinderPanel extends VolumeBasedPanel {
  86651. private _radius;
  86652. /**
  86653. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  86654. */
  86655. get radius(): BABYLON.float;
  86656. set radius(value: BABYLON.float);
  86657. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86658. private _cylindricalMapping;
  86659. }
  86660. }
  86661. declare module BABYLON.GUI {
  86662. /** @hidden */
  86663. export var fluentVertexShader: {
  86664. name: string;
  86665. shader: string;
  86666. };
  86667. }
  86668. declare module BABYLON.GUI {
  86669. /** @hidden */
  86670. export var fluentPixelShader: {
  86671. name: string;
  86672. shader: string;
  86673. };
  86674. }
  86675. declare module BABYLON.GUI {
  86676. /** @hidden */
  86677. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86678. INNERGLOW: boolean;
  86679. BORDER: boolean;
  86680. HOVERLIGHT: boolean;
  86681. TEXTURE: boolean;
  86682. constructor();
  86683. }
  86684. /**
  86685. * Class used to render controls with fluent desgin
  86686. */
  86687. export class FluentMaterial extends BABYLON.PushMaterial {
  86688. /**
  86689. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86690. */
  86691. innerGlowColorIntensity: number;
  86692. /**
  86693. * Gets or sets the inner glow color (white by default)
  86694. */
  86695. innerGlowColor: BABYLON.Color3;
  86696. /**
  86697. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86698. */
  86699. albedoColor: BABYLON.Color3;
  86700. /**
  86701. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86702. */
  86703. renderBorders: boolean;
  86704. /**
  86705. * Gets or sets border width (default is 0.5)
  86706. */
  86707. borderWidth: number;
  86708. /**
  86709. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86710. */
  86711. edgeSmoothingValue: number;
  86712. /**
  86713. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86714. */
  86715. borderMinValue: number;
  86716. /**
  86717. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86718. */
  86719. renderHoverLight: boolean;
  86720. /**
  86721. * Gets or sets the radius used to render the hover light (default is 1.0)
  86722. */
  86723. hoverRadius: number;
  86724. /**
  86725. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86726. */
  86727. hoverColor: BABYLON.Color4;
  86728. /**
  86729. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86730. */
  86731. hoverPosition: BABYLON.Vector3;
  86732. private _albedoTexture;
  86733. /** Gets or sets the texture to use for albedo color */
  86734. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86735. /**
  86736. * Creates a new Fluent material
  86737. * @param name defines the name of the material
  86738. * @param scene defines the hosting scene
  86739. */
  86740. constructor(name: string, scene: BABYLON.Scene);
  86741. needAlphaBlending(): boolean;
  86742. needAlphaTesting(): boolean;
  86743. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86744. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86745. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86746. getActiveTextures(): BABYLON.BaseTexture[];
  86747. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86748. dispose(forceDisposeEffect?: boolean): void;
  86749. clone(name: string): FluentMaterial;
  86750. serialize(): any;
  86751. getClassName(): string;
  86752. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86753. }
  86754. }
  86755. declare module BABYLON.GUI {
  86756. /**
  86757. * Class used to create a holographic button in 3D
  86758. */
  86759. export class HolographicButton extends Button3D {
  86760. private _backPlate;
  86761. private _textPlate;
  86762. private _frontPlate;
  86763. private _text;
  86764. private _imageUrl;
  86765. private _shareMaterials;
  86766. private _frontMaterial;
  86767. private _backMaterial;
  86768. private _plateMaterial;
  86769. private _pickedPointObserver;
  86770. private _tooltipFade;
  86771. private _tooltipTextBlock;
  86772. private _tooltipTexture;
  86773. private _tooltipMesh;
  86774. private _tooltipHoverObserver;
  86775. private _tooltipOutObserver;
  86776. private _disposeTooltip;
  86777. /**
  86778. * Rendering ground id of all the mesh in the button
  86779. */
  86780. set renderingGroupId(id: number);
  86781. get renderingGroupId(): number;
  86782. /**
  86783. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86784. */
  86785. set tooltipText(text: BABYLON.Nullable<string>);
  86786. get tooltipText(): BABYLON.Nullable<string>;
  86787. /**
  86788. * Gets or sets text for the button
  86789. */
  86790. get text(): string;
  86791. set text(value: string);
  86792. /**
  86793. * Gets or sets the image url for the button
  86794. */
  86795. get imageUrl(): string;
  86796. set imageUrl(value: string);
  86797. /**
  86798. * Gets the back material used by this button
  86799. */
  86800. get backMaterial(): FluentMaterial;
  86801. /**
  86802. * Gets the front material used by this button
  86803. */
  86804. get frontMaterial(): FluentMaterial;
  86805. /**
  86806. * Gets the plate material used by this button
  86807. */
  86808. get plateMaterial(): BABYLON.StandardMaterial;
  86809. /**
  86810. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86811. */
  86812. get shareMaterials(): boolean;
  86813. /**
  86814. * Creates a new button
  86815. * @param name defines the control name
  86816. */
  86817. constructor(name?: string, shareMaterials?: boolean);
  86818. protected _getTypeName(): string;
  86819. private _rebuildContent;
  86820. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86821. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86822. private _createBackMaterial;
  86823. private _createFrontMaterial;
  86824. private _createPlateMaterial;
  86825. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86826. /**
  86827. * Releases all associated resources
  86828. */
  86829. dispose(): void;
  86830. }
  86831. }
  86832. declare module BABYLON.GUI {
  86833. /**
  86834. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86835. */
  86836. export class MeshButton3D extends Button3D {
  86837. /** @hidden */
  86838. protected _currentMesh: BABYLON.Mesh;
  86839. /**
  86840. * Creates a new 3D button based on a mesh
  86841. * @param mesh mesh to become a 3D button
  86842. * @param name defines the control name
  86843. */
  86844. constructor(mesh: BABYLON.Mesh, name?: string);
  86845. protected _getTypeName(): string;
  86846. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86847. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86848. }
  86849. }
  86850. declare module BABYLON.GUI {
  86851. /**
  86852. * Class used to create a container panel deployed on the surface of a plane
  86853. */
  86854. export class PlanePanel extends VolumeBasedPanel {
  86855. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86856. }
  86857. }
  86858. declare module BABYLON.GUI {
  86859. /**
  86860. * Class used to create a container panel where items get randomized planar mapping
  86861. */
  86862. export class ScatterPanel extends VolumeBasedPanel {
  86863. private _iteration;
  86864. /**
  86865. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86866. */
  86867. get iteration(): BABYLON.float;
  86868. set iteration(value: BABYLON.float);
  86869. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86870. private _scatterMapping;
  86871. protected _finalProcessing(): void;
  86872. }
  86873. }
  86874. declare module BABYLON.GUI {
  86875. /**
  86876. * Class used to create a container panel deployed on the surface of a sphere
  86877. */
  86878. export class SpherePanel extends VolumeBasedPanel {
  86879. private _radius;
  86880. /**
  86881. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86882. */
  86883. get radius(): BABYLON.float;
  86884. set radius(value: BABYLON.float);
  86885. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86886. private _sphericalMapping;
  86887. }
  86888. }
  86889. declare module BABYLON.GUI {
  86890. /**
  86891. * Class used to create a stack panel in 3D on XY plane
  86892. */
  86893. export class StackPanel3D extends Container3D {
  86894. private _isVertical;
  86895. /**
  86896. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86897. */
  86898. get isVertical(): boolean;
  86899. set isVertical(value: boolean);
  86900. /**
  86901. * Gets or sets the distance between elements
  86902. */
  86903. margin: number;
  86904. /**
  86905. * Creates new StackPanel
  86906. * @param isVertical
  86907. */
  86908. constructor(isVertical?: boolean);
  86909. protected _arrangeChildren(): void;
  86910. }
  86911. }
  86912. declare module BABYLON {
  86913. /**
  86914. * Configuration for glTF validation
  86915. */
  86916. export interface IGLTFValidationConfiguration {
  86917. /**
  86918. * The url of the glTF validator.
  86919. */
  86920. url: string;
  86921. }
  86922. /**
  86923. * glTF validation
  86924. */
  86925. export class GLTFValidation {
  86926. /**
  86927. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86928. */
  86929. static Configuration: IGLTFValidationConfiguration;
  86930. private static _LoadScriptPromise;
  86931. /**
  86932. * Validate a glTF asset using the glTF-Validator.
  86933. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86934. * @param rootUrl The root url for the glTF
  86935. * @param fileName The file name for the glTF
  86936. * @param getExternalResource The callback to get external resources for the glTF validator
  86937. * @returns A promise that resolves with the glTF validation results once complete
  86938. */
  86939. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86940. }
  86941. }
  86942. declare module BABYLON {
  86943. /**
  86944. * Mode that determines the coordinate system to use.
  86945. */
  86946. export enum GLTFLoaderCoordinateSystemMode {
  86947. /**
  86948. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86949. */
  86950. AUTO = 0,
  86951. /**
  86952. * Sets the useRightHandedSystem flag on the scene.
  86953. */
  86954. FORCE_RIGHT_HANDED = 1
  86955. }
  86956. /**
  86957. * Mode that determines what animations will start.
  86958. */
  86959. export enum GLTFLoaderAnimationStartMode {
  86960. /**
  86961. * No animation will start.
  86962. */
  86963. NONE = 0,
  86964. /**
  86965. * The first animation will start.
  86966. */
  86967. FIRST = 1,
  86968. /**
  86969. * All animations will start.
  86970. */
  86971. ALL = 2
  86972. }
  86973. /**
  86974. * Interface that contains the data for the glTF asset.
  86975. */
  86976. export interface IGLTFLoaderData {
  86977. /**
  86978. * The object that represents the glTF JSON.
  86979. */
  86980. json: Object;
  86981. /**
  86982. * The BIN chunk of a binary glTF.
  86983. */
  86984. bin: Nullable<IDataBuffer>;
  86985. }
  86986. /**
  86987. * Interface for extending the loader.
  86988. */
  86989. export interface IGLTFLoaderExtension {
  86990. /**
  86991. * The name of this extension.
  86992. */
  86993. readonly name: string;
  86994. /**
  86995. * Defines whether this extension is enabled.
  86996. */
  86997. enabled: boolean;
  86998. /**
  86999. * Defines the order of this extension.
  87000. * The loader sorts the extensions using these values when loading.
  87001. */
  87002. order?: number;
  87003. }
  87004. /**
  87005. * Loader state.
  87006. */
  87007. export enum GLTFLoaderState {
  87008. /**
  87009. * The asset is loading.
  87010. */
  87011. LOADING = 0,
  87012. /**
  87013. * The asset is ready for rendering.
  87014. */
  87015. READY = 1,
  87016. /**
  87017. * The asset is completely loaded.
  87018. */
  87019. COMPLETE = 2
  87020. }
  87021. /** @hidden */
  87022. export interface IGLTFLoader extends IDisposable {
  87023. readonly state: Nullable<GLTFLoaderState>;
  87024. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  87025. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  87026. }
  87027. /**
  87028. * File loader for loading glTF files into a scene.
  87029. */
  87030. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  87031. /** @hidden */
  87032. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87033. /** @hidden */
  87034. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  87035. /**
  87036. * Raised when the asset has been parsed
  87037. */
  87038. onParsedObservable: Observable<IGLTFLoaderData>;
  87039. private _onParsedObserver;
  87040. /**
  87041. * Raised when the asset has been parsed
  87042. */
  87043. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  87044. /**
  87045. * 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.
  87046. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  87047. * Defaults to true.
  87048. * @hidden
  87049. */
  87050. static IncrementalLoading: boolean;
  87051. /**
  87052. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  87053. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  87054. * @hidden
  87055. */
  87056. static HomogeneousCoordinates: boolean;
  87057. /**
  87058. * The coordinate system mode. Defaults to AUTO.
  87059. */
  87060. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  87061. /**
  87062. * The animation start mode. Defaults to FIRST.
  87063. */
  87064. animationStartMode: GLTFLoaderAnimationStartMode;
  87065. /**
  87066. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  87067. */
  87068. compileMaterials: boolean;
  87069. /**
  87070. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  87071. */
  87072. useClipPlane: boolean;
  87073. /**
  87074. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  87075. */
  87076. compileShadowGenerators: boolean;
  87077. /**
  87078. * Defines if the Alpha blended materials are only applied as coverage.
  87079. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  87080. * If true, no extra effects are applied to transparent pixels.
  87081. */
  87082. transparencyAsCoverage: boolean;
  87083. /**
  87084. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  87085. * Enabling will disable offline support and glTF validator.
  87086. * Defaults to false.
  87087. */
  87088. useRangeRequests: boolean;
  87089. /**
  87090. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  87091. */
  87092. createInstances: boolean;
  87093. /**
  87094. * 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.
  87095. */
  87096. alwaysComputeBoundingBox: boolean;
  87097. /**
  87098. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  87099. */
  87100. loadAllMaterials: boolean;
  87101. /**
  87102. * Function called before loading a url referenced by the asset.
  87103. */
  87104. preprocessUrlAsync: (url: string) => Promise<string>;
  87105. /**
  87106. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87107. * 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, ...)
  87108. */
  87109. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  87110. private _onMeshLoadedObserver;
  87111. /**
  87112. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  87113. * 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, ...)
  87114. */
  87115. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  87116. /**
  87117. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  87118. */
  87119. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  87120. private _onTextureLoadedObserver;
  87121. /**
  87122. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  87123. */
  87124. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  87125. /**
  87126. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  87127. */
  87128. readonly onMaterialLoadedObservable: Observable<Material>;
  87129. private _onMaterialLoadedObserver;
  87130. /**
  87131. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  87132. */
  87133. set onMaterialLoaded(callback: (material: Material) => void);
  87134. /**
  87135. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  87136. */
  87137. readonly onCameraLoadedObservable: Observable<Camera>;
  87138. private _onCameraLoadedObserver;
  87139. /**
  87140. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  87141. */
  87142. set onCameraLoaded(callback: (camera: Camera) => void);
  87143. /**
  87144. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  87145. * For assets with LODs, raised when all of the LODs are complete.
  87146. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87147. */
  87148. readonly onCompleteObservable: Observable<void>;
  87149. private _onCompleteObserver;
  87150. /**
  87151. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  87152. * For assets with LODs, raised when all of the LODs are complete.
  87153. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  87154. */
  87155. set onComplete(callback: () => void);
  87156. /**
  87157. * Observable raised when an error occurs.
  87158. */
  87159. readonly onErrorObservable: Observable<any>;
  87160. private _onErrorObserver;
  87161. /**
  87162. * Callback raised when an error occurs.
  87163. */
  87164. set onError(callback: (reason: any) => void);
  87165. /**
  87166. * Observable raised after the loader is disposed.
  87167. */
  87168. readonly onDisposeObservable: Observable<void>;
  87169. private _onDisposeObserver;
  87170. /**
  87171. * Callback raised after the loader is disposed.
  87172. */
  87173. set onDispose(callback: () => void);
  87174. /**
  87175. * Observable raised after a loader extension is created.
  87176. * Set additional options for a loader extension in this event.
  87177. */
  87178. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  87179. private _onExtensionLoadedObserver;
  87180. /**
  87181. * Callback raised after a loader extension is created.
  87182. */
  87183. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  87184. /**
  87185. * Defines if the loader logging is enabled.
  87186. */
  87187. get loggingEnabled(): boolean;
  87188. set loggingEnabled(value: boolean);
  87189. /**
  87190. * Defines if the loader should capture performance counters.
  87191. */
  87192. get capturePerformanceCounters(): boolean;
  87193. set capturePerformanceCounters(value: boolean);
  87194. /**
  87195. * Defines if the loader should validate the asset.
  87196. */
  87197. validate: boolean;
  87198. /**
  87199. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  87200. */
  87201. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  87202. private _onValidatedObserver;
  87203. /**
  87204. * Callback raised after a loader extension is created.
  87205. */
  87206. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  87207. private _loader;
  87208. private _progressCallback?;
  87209. private _requests;
  87210. private static magicBase64Encoded;
  87211. /**
  87212. * Name of the loader ("gltf")
  87213. */
  87214. name: string;
  87215. /** @hidden */
  87216. extensions: ISceneLoaderPluginExtensions;
  87217. /**
  87218. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  87219. */
  87220. dispose(): void;
  87221. /** @hidden */
  87222. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87223. /** @hidden */
  87224. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  87225. /** @hidden */
  87226. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87227. /** @hidden */
  87228. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87229. /** @hidden */
  87230. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  87231. /** @hidden */
  87232. canDirectLoad(data: string): boolean;
  87233. /** @hidden */
  87234. directLoad(scene: Scene, data: string): Promise<any>;
  87235. /**
  87236. * The callback that allows custom handling of the root url based on the response url.
  87237. * @param rootUrl the original root url
  87238. * @param responseURL the response url if available
  87239. * @returns the new root url
  87240. */
  87241. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  87242. /** @hidden */
  87243. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  87244. /**
  87245. * The loader state or null if the loader is not active.
  87246. */
  87247. get loaderState(): Nullable<GLTFLoaderState>;
  87248. /**
  87249. * Returns a promise that resolves when the asset is completely loaded.
  87250. * @returns a promise that resolves when the asset is completely loaded.
  87251. */
  87252. whenCompleteAsync(): Promise<void>;
  87253. /** @hidden */
  87254. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  87255. /** @hidden */
  87256. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  87257. private _onProgress;
  87258. private _validate;
  87259. private _getLoader;
  87260. private _parseJson;
  87261. private _unpackBinaryAsync;
  87262. private _unpackBinaryV1Async;
  87263. private _unpackBinaryV2Async;
  87264. private static _parseVersion;
  87265. private static _compareVersion;
  87266. private static readonly _logSpaces;
  87267. private _logIndentLevel;
  87268. private _loggingEnabled;
  87269. /** @hidden */
  87270. _log: (message: string) => void;
  87271. /** @hidden */
  87272. _logOpen(message: string): void;
  87273. /** @hidden */
  87274. _logClose(): void;
  87275. private _logEnabled;
  87276. private _logDisabled;
  87277. private _capturePerformanceCounters;
  87278. /** @hidden */
  87279. _startPerformanceCounter: (counterName: string) => void;
  87280. /** @hidden */
  87281. _endPerformanceCounter: (counterName: string) => void;
  87282. private _startPerformanceCounterEnabled;
  87283. private _startPerformanceCounterDisabled;
  87284. private _endPerformanceCounterEnabled;
  87285. private _endPerformanceCounterDisabled;
  87286. }
  87287. }
  87288. declare module BABYLON.GLTF1 {
  87289. /**
  87290. * Enums
  87291. * @hidden
  87292. */
  87293. export enum EComponentType {
  87294. BYTE = 5120,
  87295. UNSIGNED_BYTE = 5121,
  87296. SHORT = 5122,
  87297. UNSIGNED_SHORT = 5123,
  87298. FLOAT = 5126
  87299. }
  87300. /** @hidden */
  87301. export enum EShaderType {
  87302. FRAGMENT = 35632,
  87303. VERTEX = 35633
  87304. }
  87305. /** @hidden */
  87306. export enum EParameterType {
  87307. BYTE = 5120,
  87308. UNSIGNED_BYTE = 5121,
  87309. SHORT = 5122,
  87310. UNSIGNED_SHORT = 5123,
  87311. INT = 5124,
  87312. UNSIGNED_INT = 5125,
  87313. FLOAT = 5126,
  87314. FLOAT_VEC2 = 35664,
  87315. FLOAT_VEC3 = 35665,
  87316. FLOAT_VEC4 = 35666,
  87317. INT_VEC2 = 35667,
  87318. INT_VEC3 = 35668,
  87319. INT_VEC4 = 35669,
  87320. BOOL = 35670,
  87321. BOOL_VEC2 = 35671,
  87322. BOOL_VEC3 = 35672,
  87323. BOOL_VEC4 = 35673,
  87324. FLOAT_MAT2 = 35674,
  87325. FLOAT_MAT3 = 35675,
  87326. FLOAT_MAT4 = 35676,
  87327. SAMPLER_2D = 35678
  87328. }
  87329. /** @hidden */
  87330. export enum ETextureWrapMode {
  87331. CLAMP_TO_EDGE = 33071,
  87332. MIRRORED_REPEAT = 33648,
  87333. REPEAT = 10497
  87334. }
  87335. /** @hidden */
  87336. export enum ETextureFilterType {
  87337. NEAREST = 9728,
  87338. LINEAR = 9728,
  87339. NEAREST_MIPMAP_NEAREST = 9984,
  87340. LINEAR_MIPMAP_NEAREST = 9985,
  87341. NEAREST_MIPMAP_LINEAR = 9986,
  87342. LINEAR_MIPMAP_LINEAR = 9987
  87343. }
  87344. /** @hidden */
  87345. export enum ETextureFormat {
  87346. ALPHA = 6406,
  87347. RGB = 6407,
  87348. RGBA = 6408,
  87349. LUMINANCE = 6409,
  87350. LUMINANCE_ALPHA = 6410
  87351. }
  87352. /** @hidden */
  87353. export enum ECullingType {
  87354. FRONT = 1028,
  87355. BACK = 1029,
  87356. FRONT_AND_BACK = 1032
  87357. }
  87358. /** @hidden */
  87359. export enum EBlendingFunction {
  87360. ZERO = 0,
  87361. ONE = 1,
  87362. SRC_COLOR = 768,
  87363. ONE_MINUS_SRC_COLOR = 769,
  87364. DST_COLOR = 774,
  87365. ONE_MINUS_DST_COLOR = 775,
  87366. SRC_ALPHA = 770,
  87367. ONE_MINUS_SRC_ALPHA = 771,
  87368. DST_ALPHA = 772,
  87369. ONE_MINUS_DST_ALPHA = 773,
  87370. CONSTANT_COLOR = 32769,
  87371. ONE_MINUS_CONSTANT_COLOR = 32770,
  87372. CONSTANT_ALPHA = 32771,
  87373. ONE_MINUS_CONSTANT_ALPHA = 32772,
  87374. SRC_ALPHA_SATURATE = 776
  87375. }
  87376. /** @hidden */
  87377. export interface IGLTFProperty {
  87378. extensions?: {
  87379. [key: string]: any;
  87380. };
  87381. extras?: Object;
  87382. }
  87383. /** @hidden */
  87384. export interface IGLTFChildRootProperty extends IGLTFProperty {
  87385. name?: string;
  87386. }
  87387. /** @hidden */
  87388. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  87389. bufferView: string;
  87390. byteOffset: number;
  87391. byteStride: number;
  87392. count: number;
  87393. type: string;
  87394. componentType: EComponentType;
  87395. max?: number[];
  87396. min?: number[];
  87397. name?: string;
  87398. }
  87399. /** @hidden */
  87400. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  87401. buffer: string;
  87402. byteOffset: number;
  87403. byteLength: number;
  87404. byteStride: number;
  87405. target?: number;
  87406. }
  87407. /** @hidden */
  87408. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  87409. uri: string;
  87410. byteLength?: number;
  87411. type?: string;
  87412. }
  87413. /** @hidden */
  87414. export interface IGLTFShader extends IGLTFChildRootProperty {
  87415. uri: string;
  87416. type: EShaderType;
  87417. }
  87418. /** @hidden */
  87419. export interface IGLTFProgram extends IGLTFChildRootProperty {
  87420. attributes: string[];
  87421. fragmentShader: string;
  87422. vertexShader: string;
  87423. }
  87424. /** @hidden */
  87425. export interface IGLTFTechniqueParameter {
  87426. type: number;
  87427. count?: number;
  87428. semantic?: string;
  87429. node?: string;
  87430. value?: number | boolean | string | Array<any>;
  87431. source?: string;
  87432. babylonValue?: any;
  87433. }
  87434. /** @hidden */
  87435. export interface IGLTFTechniqueCommonProfile {
  87436. lightingModel: string;
  87437. texcoordBindings: Object;
  87438. parameters?: Array<any>;
  87439. }
  87440. /** @hidden */
  87441. export interface IGLTFTechniqueStatesFunctions {
  87442. blendColor?: number[];
  87443. blendEquationSeparate?: number[];
  87444. blendFuncSeparate?: number[];
  87445. colorMask: boolean[];
  87446. cullFace: number[];
  87447. }
  87448. /** @hidden */
  87449. export interface IGLTFTechniqueStates {
  87450. enable: number[];
  87451. functions: IGLTFTechniqueStatesFunctions;
  87452. }
  87453. /** @hidden */
  87454. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  87455. parameters: {
  87456. [key: string]: IGLTFTechniqueParameter;
  87457. };
  87458. program: string;
  87459. attributes: {
  87460. [key: string]: string;
  87461. };
  87462. uniforms: {
  87463. [key: string]: string;
  87464. };
  87465. states: IGLTFTechniqueStates;
  87466. }
  87467. /** @hidden */
  87468. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  87469. technique?: string;
  87470. values: string[];
  87471. }
  87472. /** @hidden */
  87473. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  87474. attributes: {
  87475. [key: string]: string;
  87476. };
  87477. indices: string;
  87478. material: string;
  87479. mode?: number;
  87480. }
  87481. /** @hidden */
  87482. export interface IGLTFMesh extends IGLTFChildRootProperty {
  87483. primitives: IGLTFMeshPrimitive[];
  87484. }
  87485. /** @hidden */
  87486. export interface IGLTFImage extends IGLTFChildRootProperty {
  87487. uri: string;
  87488. }
  87489. /** @hidden */
  87490. export interface IGLTFSampler extends IGLTFChildRootProperty {
  87491. magFilter?: number;
  87492. minFilter?: number;
  87493. wrapS?: number;
  87494. wrapT?: number;
  87495. }
  87496. /** @hidden */
  87497. export interface IGLTFTexture extends IGLTFChildRootProperty {
  87498. sampler: string;
  87499. source: string;
  87500. format?: ETextureFormat;
  87501. internalFormat?: ETextureFormat;
  87502. target?: number;
  87503. type?: number;
  87504. babylonTexture?: Texture;
  87505. }
  87506. /** @hidden */
  87507. export interface IGLTFAmbienLight {
  87508. color?: number[];
  87509. }
  87510. /** @hidden */
  87511. export interface IGLTFDirectionalLight {
  87512. color?: number[];
  87513. }
  87514. /** @hidden */
  87515. export interface IGLTFPointLight {
  87516. color?: number[];
  87517. constantAttenuation?: number;
  87518. linearAttenuation?: number;
  87519. quadraticAttenuation?: number;
  87520. }
  87521. /** @hidden */
  87522. export interface IGLTFSpotLight {
  87523. color?: number[];
  87524. constantAttenuation?: number;
  87525. fallOfAngle?: number;
  87526. fallOffExponent?: number;
  87527. linearAttenuation?: number;
  87528. quadraticAttenuation?: number;
  87529. }
  87530. /** @hidden */
  87531. export interface IGLTFLight extends IGLTFChildRootProperty {
  87532. type: string;
  87533. }
  87534. /** @hidden */
  87535. export interface IGLTFCameraOrthographic {
  87536. xmag: number;
  87537. ymag: number;
  87538. zfar: number;
  87539. znear: number;
  87540. }
  87541. /** @hidden */
  87542. export interface IGLTFCameraPerspective {
  87543. aspectRatio: number;
  87544. yfov: number;
  87545. zfar: number;
  87546. znear: number;
  87547. }
  87548. /** @hidden */
  87549. export interface IGLTFCamera extends IGLTFChildRootProperty {
  87550. type: string;
  87551. }
  87552. /** @hidden */
  87553. export interface IGLTFAnimationChannelTarget {
  87554. id: string;
  87555. path: string;
  87556. }
  87557. /** @hidden */
  87558. export interface IGLTFAnimationChannel {
  87559. sampler: string;
  87560. target: IGLTFAnimationChannelTarget;
  87561. }
  87562. /** @hidden */
  87563. export interface IGLTFAnimationSampler {
  87564. input: string;
  87565. output: string;
  87566. interpolation?: string;
  87567. }
  87568. /** @hidden */
  87569. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  87570. channels?: IGLTFAnimationChannel[];
  87571. parameters?: {
  87572. [key: string]: string;
  87573. };
  87574. samplers?: {
  87575. [key: string]: IGLTFAnimationSampler;
  87576. };
  87577. }
  87578. /** @hidden */
  87579. export interface IGLTFNodeInstanceSkin {
  87580. skeletons: string[];
  87581. skin: string;
  87582. meshes: string[];
  87583. }
  87584. /** @hidden */
  87585. export interface IGLTFSkins extends IGLTFChildRootProperty {
  87586. bindShapeMatrix: number[];
  87587. inverseBindMatrices: string;
  87588. jointNames: string[];
  87589. babylonSkeleton?: Skeleton;
  87590. }
  87591. /** @hidden */
  87592. export interface IGLTFNode extends IGLTFChildRootProperty {
  87593. camera?: string;
  87594. children: string[];
  87595. skin?: string;
  87596. jointName?: string;
  87597. light?: string;
  87598. matrix: number[];
  87599. mesh?: string;
  87600. meshes?: string[];
  87601. rotation?: number[];
  87602. scale?: number[];
  87603. translation?: number[];
  87604. babylonNode?: Node;
  87605. }
  87606. /** @hidden */
  87607. export interface IGLTFScene extends IGLTFChildRootProperty {
  87608. nodes: string[];
  87609. }
  87610. /** @hidden */
  87611. export interface IGLTFRuntime {
  87612. extensions: {
  87613. [key: string]: any;
  87614. };
  87615. accessors: {
  87616. [key: string]: IGLTFAccessor;
  87617. };
  87618. buffers: {
  87619. [key: string]: IGLTFBuffer;
  87620. };
  87621. bufferViews: {
  87622. [key: string]: IGLTFBufferView;
  87623. };
  87624. meshes: {
  87625. [key: string]: IGLTFMesh;
  87626. };
  87627. lights: {
  87628. [key: string]: IGLTFLight;
  87629. };
  87630. cameras: {
  87631. [key: string]: IGLTFCamera;
  87632. };
  87633. nodes: {
  87634. [key: string]: IGLTFNode;
  87635. };
  87636. images: {
  87637. [key: string]: IGLTFImage;
  87638. };
  87639. textures: {
  87640. [key: string]: IGLTFTexture;
  87641. };
  87642. shaders: {
  87643. [key: string]: IGLTFShader;
  87644. };
  87645. programs: {
  87646. [key: string]: IGLTFProgram;
  87647. };
  87648. samplers: {
  87649. [key: string]: IGLTFSampler;
  87650. };
  87651. techniques: {
  87652. [key: string]: IGLTFTechnique;
  87653. };
  87654. materials: {
  87655. [key: string]: IGLTFMaterial;
  87656. };
  87657. animations: {
  87658. [key: string]: IGLTFAnimation;
  87659. };
  87660. skins: {
  87661. [key: string]: IGLTFSkins;
  87662. };
  87663. currentScene?: Object;
  87664. scenes: {
  87665. [key: string]: IGLTFScene;
  87666. };
  87667. extensionsUsed: string[];
  87668. extensionsRequired?: string[];
  87669. buffersCount: number;
  87670. shaderscount: number;
  87671. scene: Scene;
  87672. rootUrl: string;
  87673. loadedBufferCount: number;
  87674. loadedBufferViews: {
  87675. [name: string]: ArrayBufferView;
  87676. };
  87677. loadedShaderCount: number;
  87678. importOnlyMeshes: boolean;
  87679. importMeshesNames?: string[];
  87680. dummyNodes: Node[];
  87681. forAssetContainer: boolean;
  87682. }
  87683. /** @hidden */
  87684. export interface INodeToRoot {
  87685. bone: Bone;
  87686. node: IGLTFNode;
  87687. id: string;
  87688. }
  87689. /** @hidden */
  87690. export interface IJointNode {
  87691. node: IGLTFNode;
  87692. id: string;
  87693. }
  87694. }
  87695. declare module BABYLON.GLTF1 {
  87696. /**
  87697. * Utils functions for GLTF
  87698. * @hidden
  87699. */
  87700. export class GLTFUtils {
  87701. /**
  87702. * Sets the given "parameter" matrix
  87703. * @param scene: the Scene object
  87704. * @param source: the source node where to pick the matrix
  87705. * @param parameter: the GLTF technique parameter
  87706. * @param uniformName: the name of the shader's uniform
  87707. * @param shaderMaterial: the shader material
  87708. */
  87709. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87710. /**
  87711. * Sets the given "parameter" matrix
  87712. * @param shaderMaterial: the shader material
  87713. * @param uniform: the name of the shader's uniform
  87714. * @param value: the value of the uniform
  87715. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87716. */
  87717. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87718. /**
  87719. * Returns the wrap mode of the texture
  87720. * @param mode: the mode value
  87721. */
  87722. static GetWrapMode(mode: number): number;
  87723. /**
  87724. * Returns the byte stride giving an accessor
  87725. * @param accessor: the GLTF accessor objet
  87726. */
  87727. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87728. /**
  87729. * Returns the texture filter mode giving a mode value
  87730. * @param mode: the filter mode value
  87731. */
  87732. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87733. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87734. /**
  87735. * Returns a buffer from its accessor
  87736. * @param gltfRuntime: the GLTF runtime
  87737. * @param accessor: the GLTF accessor
  87738. */
  87739. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87740. /**
  87741. * Decodes a buffer view into a string
  87742. * @param view: the buffer view
  87743. */
  87744. static DecodeBufferToText(view: ArrayBufferView): string;
  87745. /**
  87746. * Returns the default material of gltf. Related to
  87747. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87748. * @param scene: the Babylon.js scene
  87749. */
  87750. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87751. private static _DefaultMaterial;
  87752. }
  87753. }
  87754. declare module BABYLON.GLTF1 {
  87755. /**
  87756. * Implementation of the base glTF spec
  87757. * @hidden
  87758. */
  87759. export class GLTFLoaderBase {
  87760. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87761. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87762. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87763. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87764. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87765. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87766. }
  87767. /**
  87768. * glTF V1 Loader
  87769. * @hidden
  87770. */
  87771. export class GLTFLoader implements IGLTFLoader {
  87772. static Extensions: {
  87773. [name: string]: GLTFLoaderExtension;
  87774. };
  87775. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87776. state: Nullable<GLTFLoaderState>;
  87777. dispose(): void;
  87778. private _importMeshAsync;
  87779. /**
  87780. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87781. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87782. * @param scene the scene the meshes should be added to
  87783. * @param forAssetContainer defines if the entities must be stored in the scene
  87784. * @param data gltf data containing information of the meshes in a loaded file
  87785. * @param rootUrl root url to load from
  87786. * @param onProgress event that fires when loading progress has occured
  87787. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87788. */
  87789. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87790. private _loadAsync;
  87791. /**
  87792. * Imports all objects from a loaded gltf file and adds them to the scene
  87793. * @param scene the scene the objects should be added to
  87794. * @param data gltf data containing information of the meshes in a loaded file
  87795. * @param rootUrl root url to load from
  87796. * @param onProgress event that fires when loading progress has occured
  87797. * @returns a promise which completes when objects have been loaded to the scene
  87798. */
  87799. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87800. private _loadShadersAsync;
  87801. private _loadBuffersAsync;
  87802. private _createNodes;
  87803. }
  87804. /** @hidden */
  87805. export abstract class GLTFLoaderExtension {
  87806. private _name;
  87807. constructor(name: string);
  87808. get name(): string;
  87809. /**
  87810. * Defines an override for loading the runtime
  87811. * Return true to stop further extensions from loading the runtime
  87812. */
  87813. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87814. /**
  87815. * Defines an onverride for creating gltf runtime
  87816. * Return true to stop further extensions from creating the runtime
  87817. */
  87818. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87819. /**
  87820. * Defines an override for loading buffers
  87821. * Return true to stop further extensions from loading this buffer
  87822. */
  87823. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87824. /**
  87825. * Defines an override for loading texture buffers
  87826. * Return true to stop further extensions from loading this texture data
  87827. */
  87828. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87829. /**
  87830. * Defines an override for creating textures
  87831. * Return true to stop further extensions from loading this texture
  87832. */
  87833. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87834. /**
  87835. * Defines an override for loading shader strings
  87836. * Return true to stop further extensions from loading this shader data
  87837. */
  87838. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87839. /**
  87840. * Defines an override for loading materials
  87841. * Return true to stop further extensions from loading this material
  87842. */
  87843. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87844. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87845. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87846. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87847. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87848. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87849. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87850. private static LoadTextureBufferAsync;
  87851. private static CreateTextureAsync;
  87852. private static ApplyExtensions;
  87853. }
  87854. }
  87855. declare module BABYLON.GLTF1 {
  87856. /** @hidden */
  87857. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87858. private _bin;
  87859. constructor();
  87860. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87861. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87862. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87863. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87864. }
  87865. }
  87866. declare module BABYLON.GLTF1 {
  87867. /** @hidden */
  87868. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87869. constructor();
  87870. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87871. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87872. private _loadTexture;
  87873. }
  87874. }
  87875. declare module BABYLON.GLTF2.Loader {
  87876. /**
  87877. * Loader interface with an index field.
  87878. */
  87879. export interface IArrayItem {
  87880. /**
  87881. * The index of this item in the array.
  87882. */
  87883. index: number;
  87884. }
  87885. /**
  87886. * Loader interface with additional members.
  87887. */
  87888. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87889. /** @hidden */
  87890. _data?: Promise<ArrayBufferView>;
  87891. /** @hidden */
  87892. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87893. }
  87894. /**
  87895. * Loader interface with additional members.
  87896. */
  87897. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87898. }
  87899. /** @hidden */
  87900. export interface _IAnimationSamplerData {
  87901. input: Float32Array;
  87902. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87903. output: Float32Array;
  87904. }
  87905. /**
  87906. * Loader interface with additional members.
  87907. */
  87908. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87909. /** @hidden */
  87910. _data?: Promise<_IAnimationSamplerData>;
  87911. }
  87912. /**
  87913. * Loader interface with additional members.
  87914. */
  87915. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87916. channels: IAnimationChannel[];
  87917. samplers: IAnimationSampler[];
  87918. /** @hidden */
  87919. _babylonAnimationGroup?: AnimationGroup;
  87920. }
  87921. /**
  87922. * Loader interface with additional members.
  87923. */
  87924. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87925. /** @hidden */
  87926. _data?: Promise<ArrayBufferView>;
  87927. }
  87928. /**
  87929. * Loader interface with additional members.
  87930. */
  87931. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87932. /** @hidden */
  87933. _data?: Promise<ArrayBufferView>;
  87934. /** @hidden */
  87935. _babylonBuffer?: Promise<Buffer>;
  87936. }
  87937. /**
  87938. * Loader interface with additional members.
  87939. */
  87940. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87941. }
  87942. /**
  87943. * Loader interface with additional members.
  87944. */
  87945. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87946. /** @hidden */
  87947. _data?: Promise<ArrayBufferView>;
  87948. }
  87949. /**
  87950. * Loader interface with additional members.
  87951. */
  87952. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87953. }
  87954. /**
  87955. * Loader interface with additional members.
  87956. */
  87957. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87958. }
  87959. /**
  87960. * Loader interface with additional members.
  87961. */
  87962. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87963. baseColorTexture?: ITextureInfo;
  87964. metallicRoughnessTexture?: ITextureInfo;
  87965. }
  87966. /**
  87967. * Loader interface with additional members.
  87968. */
  87969. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87970. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87971. normalTexture?: IMaterialNormalTextureInfo;
  87972. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87973. emissiveTexture?: ITextureInfo;
  87974. /** @hidden */
  87975. _data?: {
  87976. [babylonDrawMode: number]: {
  87977. babylonMaterial: Material;
  87978. babylonMeshes: AbstractMesh[];
  87979. promise: Promise<void>;
  87980. };
  87981. };
  87982. }
  87983. /**
  87984. * Loader interface with additional members.
  87985. */
  87986. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87987. primitives: IMeshPrimitive[];
  87988. }
  87989. /**
  87990. * Loader interface with additional members.
  87991. */
  87992. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87993. /** @hidden */
  87994. _instanceData?: {
  87995. babylonSourceMesh: Mesh;
  87996. promise: Promise<any>;
  87997. };
  87998. }
  87999. /**
  88000. * Loader interface with additional members.
  88001. */
  88002. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  88003. /**
  88004. * The parent glTF node.
  88005. */
  88006. parent?: INode;
  88007. /** @hidden */
  88008. _babylonTransformNode?: TransformNode;
  88009. /** @hidden */
  88010. _primitiveBabylonMeshes?: AbstractMesh[];
  88011. /** @hidden */
  88012. _babylonBones?: Bone[];
  88013. /** @hidden */
  88014. _numMorphTargets?: number;
  88015. }
  88016. /** @hidden */
  88017. export interface _ISamplerData {
  88018. noMipMaps: boolean;
  88019. samplingMode: number;
  88020. wrapU: number;
  88021. wrapV: number;
  88022. }
  88023. /**
  88024. * Loader interface with additional members.
  88025. */
  88026. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  88027. /** @hidden */
  88028. _data?: _ISamplerData;
  88029. }
  88030. /**
  88031. * Loader interface with additional members.
  88032. */
  88033. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  88034. }
  88035. /**
  88036. * Loader interface with additional members.
  88037. */
  88038. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  88039. /** @hidden */
  88040. _data?: {
  88041. babylonSkeleton: Skeleton;
  88042. promise: Promise<void>;
  88043. };
  88044. }
  88045. /**
  88046. * Loader interface with additional members.
  88047. */
  88048. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  88049. /** @hidden */
  88050. _textureInfo: ITextureInfo;
  88051. }
  88052. /**
  88053. * Loader interface with additional members.
  88054. */
  88055. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  88056. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  88057. nonColorData?: boolean;
  88058. }
  88059. /**
  88060. * Loader interface with additional members.
  88061. */
  88062. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  88063. accessors?: IAccessor[];
  88064. animations?: IAnimation[];
  88065. buffers?: IBuffer[];
  88066. bufferViews?: IBufferView[];
  88067. cameras?: ICamera[];
  88068. images?: IImage[];
  88069. materials?: IMaterial[];
  88070. meshes?: IMesh[];
  88071. nodes?: INode[];
  88072. samplers?: ISampler[];
  88073. scenes?: IScene[];
  88074. skins?: ISkin[];
  88075. textures?: ITexture[];
  88076. }
  88077. }
  88078. declare module BABYLON.GLTF2 {
  88079. /**
  88080. * Interface for a glTF loader extension.
  88081. */
  88082. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  88083. /**
  88084. * Called after the loader state changes to LOADING.
  88085. */
  88086. onLoading?(): void;
  88087. /**
  88088. * Called after the loader state changes to READY.
  88089. */
  88090. onReady?(): void;
  88091. /**
  88092. * Define this method to modify the default behavior when loading scenes.
  88093. * @param context The context when loading the asset
  88094. * @param scene The glTF scene property
  88095. * @returns A promise that resolves when the load is complete or null if not handled
  88096. */
  88097. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  88098. /**
  88099. * Define this method to modify the default behavior when loading nodes.
  88100. * @param context The context when loading the asset
  88101. * @param node The glTF node property
  88102. * @param assign A function called synchronously after parsing the glTF properties
  88103. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  88104. */
  88105. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88106. /**
  88107. * Define this method to modify the default behavior when loading cameras.
  88108. * @param context The context when loading the asset
  88109. * @param camera The glTF camera property
  88110. * @param assign A function called synchronously after parsing the glTF properties
  88111. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  88112. */
  88113. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88114. /**
  88115. * @hidden
  88116. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  88117. * @param context The context when loading the asset
  88118. * @param primitive The glTF mesh primitive property
  88119. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  88120. */
  88121. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88122. /**
  88123. * @hidden
  88124. * Define this method to modify the default behavior when loading data for mesh primitives.
  88125. * @param context The context when loading the asset
  88126. * @param name The mesh name when loading the asset
  88127. * @param node The glTF node when loading the asset
  88128. * @param mesh The glTF mesh when loading the asset
  88129. * @param primitive The glTF mesh primitive property
  88130. * @param assign A function called synchronously after parsing the glTF properties
  88131. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88132. */
  88133. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88134. /**
  88135. * @hidden
  88136. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  88137. * @param context The context when loading the asset
  88138. * @param material The glTF material property
  88139. * @param assign A function called synchronously after parsing the glTF properties
  88140. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  88141. */
  88142. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88143. /**
  88144. * Define this method to modify the default behavior when creating materials.
  88145. * @param context The context when loading the asset
  88146. * @param material The glTF material property
  88147. * @param babylonDrawMode The draw mode for the Babylon material
  88148. * @returns The Babylon material or null if not handled
  88149. */
  88150. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88151. /**
  88152. * Define this method to modify the default behavior when loading material properties.
  88153. * @param context The context when loading the asset
  88154. * @param material The glTF material property
  88155. * @param babylonMaterial The Babylon material
  88156. * @returns A promise that resolves when the load is complete or null if not handled
  88157. */
  88158. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88159. /**
  88160. * Define this method to modify the default behavior when loading texture infos.
  88161. * @param context The context when loading the asset
  88162. * @param textureInfo The glTF texture info property
  88163. * @param assign A function called synchronously after parsing the glTF properties
  88164. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88165. */
  88166. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88167. /**
  88168. * @hidden
  88169. * Define this method to modify the default behavior when loading textures.
  88170. * @param context The context when loading the asset
  88171. * @param texture The glTF texture property
  88172. * @param assign A function called synchronously after parsing the glTF properties
  88173. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  88174. */
  88175. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88176. /**
  88177. * Define this method to modify the default behavior when loading animations.
  88178. * @param context The context when loading the asset
  88179. * @param animation The glTF animation property
  88180. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  88181. */
  88182. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88183. /**
  88184. * @hidden
  88185. * Define this method to modify the default behavior when loading skins.
  88186. * @param context The context when loading the asset
  88187. * @param node The glTF node property
  88188. * @param skin The glTF skin property
  88189. * @returns A promise that resolves when the load is complete or null if not handled
  88190. */
  88191. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  88192. /**
  88193. * @hidden
  88194. * Define this method to modify the default behavior when loading uris.
  88195. * @param context The context when loading the asset
  88196. * @param property The glTF property associated with the uri
  88197. * @param uri The uri to load
  88198. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88199. */
  88200. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88201. /**
  88202. * Define this method to modify the default behavior when loading buffer views.
  88203. * @param context The context when loading the asset
  88204. * @param bufferView The glTF buffer view property
  88205. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88206. */
  88207. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88208. /**
  88209. * Define this method to modify the default behavior when loading buffers.
  88210. * @param context The context when loading the asset
  88211. * @param buffer The glTF buffer property
  88212. * @param byteOffset The byte offset to load
  88213. * @param byteLength The byte length to load
  88214. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  88215. */
  88216. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88217. }
  88218. }
  88219. declare module BABYLON.GLTF2 {
  88220. /**
  88221. * Helper class for working with arrays when loading the glTF asset
  88222. */
  88223. export class ArrayItem {
  88224. /**
  88225. * Gets an item from the given array.
  88226. * @param context The context when loading the asset
  88227. * @param array The array to get the item from
  88228. * @param index The index to the array
  88229. * @returns The array item
  88230. */
  88231. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  88232. /**
  88233. * Assign an `index` field to each item of the given array.
  88234. * @param array The array of items
  88235. */
  88236. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  88237. }
  88238. /**
  88239. * The glTF 2.0 loader
  88240. */
  88241. export class GLTFLoader implements IGLTFLoader {
  88242. /** @hidden */
  88243. _completePromises: Promise<any>[];
  88244. /** @hidden */
  88245. _forAssetContainer: boolean;
  88246. /** Storage */
  88247. _babylonLights: Light[];
  88248. /** @hidden */
  88249. _disableInstancedMesh: number;
  88250. private _disposed;
  88251. private _parent;
  88252. private _state;
  88253. private _extensions;
  88254. private _rootUrl;
  88255. private _fileName;
  88256. private _uniqueRootUrl;
  88257. private _gltf;
  88258. private _bin;
  88259. private _babylonScene;
  88260. private _rootBabylonMesh;
  88261. private _defaultBabylonMaterialData;
  88262. private static _RegisteredExtensions;
  88263. /**
  88264. * The default glTF sampler.
  88265. */
  88266. static readonly DefaultSampler: ISampler;
  88267. /**
  88268. * Registers a loader extension.
  88269. * @param name The name of the loader extension.
  88270. * @param factory The factory function that creates the loader extension.
  88271. */
  88272. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  88273. /**
  88274. * Unregisters a loader extension.
  88275. * @param name The name of the loader extension.
  88276. * @returns A boolean indicating whether the extension has been unregistered
  88277. */
  88278. static UnregisterExtension(name: string): boolean;
  88279. /**
  88280. * The loader state.
  88281. */
  88282. get state(): Nullable<GLTFLoaderState>;
  88283. /**
  88284. * The object that represents the glTF JSON.
  88285. */
  88286. get gltf(): IGLTF;
  88287. /**
  88288. * The BIN chunk of a binary glTF.
  88289. */
  88290. get bin(): Nullable<IDataBuffer>;
  88291. /**
  88292. * The parent file loader.
  88293. */
  88294. get parent(): GLTFFileLoader;
  88295. /**
  88296. * The Babylon scene when loading the asset.
  88297. */
  88298. get babylonScene(): Scene;
  88299. /**
  88300. * The root Babylon mesh when loading the asset.
  88301. */
  88302. get rootBabylonMesh(): Mesh;
  88303. /** @hidden */
  88304. constructor(parent: GLTFFileLoader);
  88305. /** @hidden */
  88306. dispose(): void;
  88307. /** @hidden */
  88308. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88309. /** @hidden */
  88310. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88311. private _loadAsync;
  88312. private _loadData;
  88313. private _setupData;
  88314. private _loadExtensions;
  88315. private _checkExtensions;
  88316. private _setState;
  88317. private _createRootNode;
  88318. /**
  88319. * Loads a glTF scene.
  88320. * @param context The context when loading the asset
  88321. * @param scene The glTF scene property
  88322. * @returns A promise that resolves when the load is complete
  88323. */
  88324. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  88325. private _forEachPrimitive;
  88326. private _getGeometries;
  88327. private _getMeshes;
  88328. private _getTransformNodes;
  88329. private _getSkeletons;
  88330. private _getAnimationGroups;
  88331. private _startAnimations;
  88332. /**
  88333. * Loads a glTF node.
  88334. * @param context The context when loading the asset
  88335. * @param node The glTF node property
  88336. * @param assign A function called synchronously after parsing the glTF properties
  88337. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  88338. */
  88339. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  88340. private _loadMeshAsync;
  88341. /**
  88342. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  88343. * @param context The context when loading the asset
  88344. * @param name The mesh name when loading the asset
  88345. * @param node The glTF node when loading the asset
  88346. * @param mesh The glTF mesh when loading the asset
  88347. * @param primitive The glTF mesh primitive property
  88348. * @param assign A function called synchronously after parsing the glTF properties
  88349. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  88350. */
  88351. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  88352. private _loadVertexDataAsync;
  88353. private _createMorphTargets;
  88354. private _loadMorphTargetsAsync;
  88355. private _loadMorphTargetVertexDataAsync;
  88356. private static _LoadTransform;
  88357. private _loadSkinAsync;
  88358. private _loadBones;
  88359. private _loadBone;
  88360. private _loadSkinInverseBindMatricesDataAsync;
  88361. private _updateBoneMatrices;
  88362. private _getNodeMatrix;
  88363. /**
  88364. * Loads a glTF camera.
  88365. * @param context The context when loading the asset
  88366. * @param camera The glTF camera property
  88367. * @param assign A function called synchronously after parsing the glTF properties
  88368. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  88369. */
  88370. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  88371. private _loadAnimationsAsync;
  88372. /**
  88373. * Loads a glTF animation.
  88374. * @param context The context when loading the asset
  88375. * @param animation The glTF animation property
  88376. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  88377. */
  88378. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  88379. /**
  88380. * @hidden Loads a glTF animation channel.
  88381. * @param context The context when loading the asset
  88382. * @param animationContext The context of the animation when loading the asset
  88383. * @param animation The glTF animation property
  88384. * @param channel The glTF animation channel property
  88385. * @param babylonAnimationGroup The babylon animation group property
  88386. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  88387. * @returns A void promise when the channel load is complete
  88388. */
  88389. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  88390. private _loadAnimationSamplerAsync;
  88391. /**
  88392. * Loads a glTF buffer.
  88393. * @param context The context when loading the asset
  88394. * @param buffer The glTF buffer property
  88395. * @param byteOffset The byte offset to use
  88396. * @param byteLength The byte length to use
  88397. * @returns A promise that resolves with the loaded data when the load is complete
  88398. */
  88399. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  88400. /**
  88401. * Loads a glTF buffer view.
  88402. * @param context The context when loading the asset
  88403. * @param bufferView The glTF buffer view property
  88404. * @returns A promise that resolves with the loaded data when the load is complete
  88405. */
  88406. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  88407. private _loadAccessorAsync;
  88408. /** @hidden */
  88409. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  88410. private _loadIndicesAccessorAsync;
  88411. private _loadVertexBufferViewAsync;
  88412. private _loadVertexAccessorAsync;
  88413. private _loadMaterialMetallicRoughnessPropertiesAsync;
  88414. /** @hidden */
  88415. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  88416. private _createDefaultMaterial;
  88417. /**
  88418. * Creates a Babylon material from a glTF material.
  88419. * @param context The context when loading the asset
  88420. * @param material The glTF material property
  88421. * @param babylonDrawMode The draw mode for the Babylon material
  88422. * @returns The Babylon material
  88423. */
  88424. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  88425. /**
  88426. * Loads properties from a glTF material into a Babylon material.
  88427. * @param context The context when loading the asset
  88428. * @param material The glTF material property
  88429. * @param babylonMaterial The Babylon material
  88430. * @returns A promise that resolves when the load is complete
  88431. */
  88432. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88433. /**
  88434. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  88435. * @param context The context when loading the asset
  88436. * @param material The glTF material property
  88437. * @param babylonMaterial The Babylon material
  88438. * @returns A promise that resolves when the load is complete
  88439. */
  88440. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  88441. /**
  88442. * Loads the alpha properties from a glTF material into a Babylon material.
  88443. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  88444. * @param context The context when loading the asset
  88445. * @param material The glTF material property
  88446. * @param babylonMaterial The Babylon material
  88447. */
  88448. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  88449. /**
  88450. * Loads a glTF texture info.
  88451. * @param context The context when loading the asset
  88452. * @param textureInfo The glTF texture info property
  88453. * @param assign A function called synchronously after parsing the glTF properties
  88454. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  88455. */
  88456. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88457. /** @hidden */
  88458. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  88459. /** @hidden */
  88460. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  88461. private _loadSampler;
  88462. /**
  88463. * Loads a glTF image.
  88464. * @param context The context when loading the asset
  88465. * @param image The glTF image property
  88466. * @returns A promise that resolves with the loaded data when the load is complete
  88467. */
  88468. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  88469. /**
  88470. * Loads a glTF uri.
  88471. * @param context The context when loading the asset
  88472. * @param property The glTF property associated with the uri
  88473. * @param uri The base64 or relative uri
  88474. * @returns A promise that resolves with the loaded data when the load is complete
  88475. */
  88476. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  88477. /**
  88478. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  88479. * @param babylonObject the Babylon object with metadata
  88480. * @param pointer the JSON pointer
  88481. */
  88482. static AddPointerMetadata(babylonObject: {
  88483. metadata: any;
  88484. }, pointer: string): void;
  88485. private static _GetTextureWrapMode;
  88486. private static _GetTextureSamplingMode;
  88487. private static _GetTypedArrayConstructor;
  88488. private static _GetTypedArray;
  88489. private static _GetNumComponents;
  88490. private static _ValidateUri;
  88491. /** @hidden */
  88492. static _GetDrawMode(context: string, mode: number | undefined): number;
  88493. private _compileMaterialsAsync;
  88494. private _compileShadowGeneratorsAsync;
  88495. private _forEachExtensions;
  88496. private _applyExtensions;
  88497. private _extensionsOnLoading;
  88498. private _extensionsOnReady;
  88499. private _extensionsLoadSceneAsync;
  88500. private _extensionsLoadNodeAsync;
  88501. private _extensionsLoadCameraAsync;
  88502. private _extensionsLoadVertexDataAsync;
  88503. private _extensionsLoadMeshPrimitiveAsync;
  88504. private _extensionsLoadMaterialAsync;
  88505. private _extensionsCreateMaterial;
  88506. private _extensionsLoadMaterialPropertiesAsync;
  88507. private _extensionsLoadTextureInfoAsync;
  88508. private _extensionsLoadTextureAsync;
  88509. private _extensionsLoadAnimationAsync;
  88510. private _extensionsLoadSkinAsync;
  88511. private _extensionsLoadUriAsync;
  88512. private _extensionsLoadBufferViewAsync;
  88513. private _extensionsLoadBufferAsync;
  88514. /**
  88515. * Helper method called by a loader extension to load an glTF extension.
  88516. * @param context The context when loading the asset
  88517. * @param property The glTF property to load the extension from
  88518. * @param extensionName The name of the extension to load
  88519. * @param actionAsync The action to run
  88520. * @returns The promise returned by actionAsync or null if the extension does not exist
  88521. */
  88522. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88523. /**
  88524. * Helper method called by a loader extension to load a glTF extra.
  88525. * @param context The context when loading the asset
  88526. * @param property The glTF property to load the extra from
  88527. * @param extensionName The name of the extension to load
  88528. * @param actionAsync The action to run
  88529. * @returns The promise returned by actionAsync or null if the extra does not exist
  88530. */
  88531. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  88532. /**
  88533. * Checks for presence of an extension.
  88534. * @param name The name of the extension to check
  88535. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  88536. */
  88537. isExtensionUsed(name: string): boolean;
  88538. /**
  88539. * Increments the indentation level and logs a message.
  88540. * @param message The message to log
  88541. */
  88542. logOpen(message: string): void;
  88543. /**
  88544. * Decrements the indentation level.
  88545. */
  88546. logClose(): void;
  88547. /**
  88548. * Logs a message
  88549. * @param message The message to log
  88550. */
  88551. log(message: string): void;
  88552. /**
  88553. * Starts a performance counter.
  88554. * @param counterName The name of the performance counter
  88555. */
  88556. startPerformanceCounter(counterName: string): void;
  88557. /**
  88558. * Ends a performance counter.
  88559. * @param counterName The name of the performance counter
  88560. */
  88561. endPerformanceCounter(counterName: string): void;
  88562. }
  88563. }
  88564. declare module BABYLON.GLTF2.Loader.Extensions {
  88565. /** @hidden */
  88566. interface IEXTLightsImageBased_LightImageBased {
  88567. _babylonTexture?: BaseTexture;
  88568. _loaded?: Promise<void>;
  88569. }
  88570. /**
  88571. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  88572. */
  88573. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  88574. /**
  88575. * The name of this extension.
  88576. */
  88577. readonly name: string;
  88578. /**
  88579. * Defines whether this extension is enabled.
  88580. */
  88581. enabled: boolean;
  88582. private _loader;
  88583. private _lights?;
  88584. /** @hidden */
  88585. constructor(loader: GLTFLoader);
  88586. /** @hidden */
  88587. dispose(): void;
  88588. /** @hidden */
  88589. onLoading(): void;
  88590. /** @hidden */
  88591. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88592. private _loadLightAsync;
  88593. }
  88594. }
  88595. declare module BABYLON.GLTF2.Loader.Extensions {
  88596. /**
  88597. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  88598. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  88599. * !!! Experimental Extension Subject to Changes !!!
  88600. */
  88601. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  88602. /**
  88603. * The name of this extension.
  88604. */
  88605. readonly name: string;
  88606. /**
  88607. * Defines whether this extension is enabled.
  88608. */
  88609. enabled: boolean;
  88610. private _loader;
  88611. /** @hidden */
  88612. constructor(loader: GLTFLoader);
  88613. /** @hidden */
  88614. dispose(): void;
  88615. /** @hidden */
  88616. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88617. }
  88618. }
  88619. declare module BABYLON.GLTF2.Loader.Extensions {
  88620. /**
  88621. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  88622. *
  88623. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  88624. */
  88625. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  88626. /**
  88627. * The name of this extension.
  88628. */
  88629. readonly name: string;
  88630. /**
  88631. * Defines whether this extension is enabled.
  88632. */
  88633. enabled: boolean;
  88634. /**
  88635. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  88636. */
  88637. static DecoderPath: string;
  88638. private _loader;
  88639. private _decoderPromise?;
  88640. /** @hidden */
  88641. constructor(loader: GLTFLoader);
  88642. /** @hidden */
  88643. dispose(): void;
  88644. /** @hidden */
  88645. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  88646. }
  88647. }
  88648. declare module BABYLON.GLTF2.Loader.Extensions {
  88649. /**
  88650. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  88651. */
  88652. export class EXT_texture_webp implements IGLTFLoaderExtension {
  88653. /** The name of this extension. */
  88654. readonly name: string;
  88655. /** Defines whether this extension is enabled. */
  88656. enabled: boolean;
  88657. private _loader;
  88658. /** @hidden */
  88659. constructor(loader: GLTFLoader);
  88660. /** @hidden */
  88661. dispose(): void;
  88662. /** @hidden */
  88663. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88664. }
  88665. }
  88666. declare module BABYLON.GLTF2.Loader.Extensions {
  88667. /**
  88668. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  88669. */
  88670. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88671. /**
  88672. * The name of this extension.
  88673. */
  88674. readonly name: string;
  88675. /**
  88676. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88677. */
  88678. dracoCompression?: DracoCompression;
  88679. /**
  88680. * Defines whether this extension is enabled.
  88681. */
  88682. enabled: boolean;
  88683. private _loader;
  88684. /** @hidden */
  88685. constructor(loader: GLTFLoader);
  88686. /** @hidden */
  88687. dispose(): void;
  88688. /** @hidden */
  88689. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88690. }
  88691. }
  88692. declare module BABYLON.GLTF2.Loader.Extensions {
  88693. /**
  88694. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88695. */
  88696. export class KHR_lights implements IGLTFLoaderExtension {
  88697. /**
  88698. * The name of this extension.
  88699. */
  88700. readonly name: string;
  88701. /**
  88702. * Defines whether this extension is enabled.
  88703. */
  88704. enabled: boolean;
  88705. private _loader;
  88706. private _lights?;
  88707. /** @hidden */
  88708. constructor(loader: GLTFLoader);
  88709. /** @hidden */
  88710. dispose(): void;
  88711. /** @hidden */
  88712. onLoading(): void;
  88713. /** @hidden */
  88714. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88715. }
  88716. }
  88717. declare module BABYLON.GLTF2.Loader.Extensions {
  88718. /**
  88719. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88720. */
  88721. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88722. /**
  88723. * The name of this extension.
  88724. */
  88725. readonly name: string;
  88726. /**
  88727. * Defines whether this extension is enabled.
  88728. */
  88729. enabled: boolean;
  88730. /**
  88731. * Defines a number that determines the order the extensions are applied.
  88732. */
  88733. order: number;
  88734. private _loader;
  88735. /** @hidden */
  88736. constructor(loader: GLTFLoader);
  88737. /** @hidden */
  88738. dispose(): void;
  88739. /** @hidden */
  88740. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88741. private _loadSpecularGlossinessPropertiesAsync;
  88742. }
  88743. }
  88744. declare module BABYLON.GLTF2.Loader.Extensions {
  88745. /**
  88746. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88747. */
  88748. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88749. /**
  88750. * The name of this extension.
  88751. */
  88752. readonly name: string;
  88753. /**
  88754. * Defines whether this extension is enabled.
  88755. */
  88756. enabled: boolean;
  88757. /**
  88758. * Defines a number that determines the order the extensions are applied.
  88759. */
  88760. order: number;
  88761. private _loader;
  88762. /** @hidden */
  88763. constructor(loader: GLTFLoader);
  88764. /** @hidden */
  88765. dispose(): void;
  88766. /** @hidden */
  88767. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88768. private _loadUnlitPropertiesAsync;
  88769. }
  88770. }
  88771. declare module BABYLON.GLTF2.Loader.Extensions {
  88772. /**
  88773. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88774. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88775. */
  88776. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88777. /**
  88778. * The name of this extension.
  88779. */
  88780. readonly name: string;
  88781. /**
  88782. * Defines whether this extension is enabled.
  88783. */
  88784. enabled: boolean;
  88785. /**
  88786. * Defines a number that determines the order the extensions are applied.
  88787. */
  88788. order: number;
  88789. private _loader;
  88790. /** @hidden */
  88791. constructor(loader: GLTFLoader);
  88792. /** @hidden */
  88793. dispose(): void;
  88794. /** @hidden */
  88795. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88796. private _loadClearCoatPropertiesAsync;
  88797. }
  88798. }
  88799. declare module BABYLON.GLTF2.Loader.Extensions {
  88800. /**
  88801. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88802. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88803. * !!! Experimental Extension Subject to Changes !!!
  88804. */
  88805. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88806. /**
  88807. * The name of this extension.
  88808. */
  88809. readonly name: string;
  88810. /**
  88811. * Defines whether this extension is enabled.
  88812. */
  88813. enabled: boolean;
  88814. /**
  88815. * Defines a number that determines the order the extensions are applied.
  88816. */
  88817. order: number;
  88818. private _loader;
  88819. /** @hidden */
  88820. constructor(loader: GLTFLoader);
  88821. /** @hidden */
  88822. dispose(): void;
  88823. /** @hidden */
  88824. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88825. private _loadSheenPropertiesAsync;
  88826. }
  88827. }
  88828. declare module BABYLON.GLTF2.Loader.Extensions {
  88829. /**
  88830. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88831. * !!! Experimental Extension Subject to Changes !!!
  88832. */
  88833. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88834. /**
  88835. * The name of this extension.
  88836. */
  88837. readonly name: string;
  88838. /**
  88839. * Defines whether this extension is enabled.
  88840. */
  88841. enabled: boolean;
  88842. /**
  88843. * Defines a number that determines the order the extensions are applied.
  88844. */
  88845. order: number;
  88846. private _loader;
  88847. /** @hidden */
  88848. constructor(loader: GLTFLoader);
  88849. /** @hidden */
  88850. dispose(): void;
  88851. /** @hidden */
  88852. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88853. private _loadSpecularPropertiesAsync;
  88854. }
  88855. }
  88856. declare module BABYLON.GLTF2.Loader.Extensions {
  88857. /**
  88858. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88859. * !!! Experimental Extension Subject to Changes !!!
  88860. */
  88861. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88862. /**
  88863. * Default ior Value from the spec.
  88864. */
  88865. private static readonly _DEFAULT_IOR;
  88866. /**
  88867. * The name of this extension.
  88868. */
  88869. readonly name: string;
  88870. /**
  88871. * Defines whether this extension is enabled.
  88872. */
  88873. enabled: boolean;
  88874. /**
  88875. * Defines a number that determines the order the extensions are applied.
  88876. */
  88877. order: number;
  88878. private _loader;
  88879. /** @hidden */
  88880. constructor(loader: GLTFLoader);
  88881. /** @hidden */
  88882. dispose(): void;
  88883. /** @hidden */
  88884. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88885. private _loadIorPropertiesAsync;
  88886. }
  88887. }
  88888. declare module BABYLON.GLTF2.Loader.Extensions {
  88889. /**
  88890. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88891. */
  88892. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88893. /**
  88894. * The name of this extension.
  88895. */
  88896. readonly name: string;
  88897. /**
  88898. * Defines whether this extension is enabled.
  88899. */
  88900. enabled: boolean;
  88901. private _loader;
  88902. private _variants?;
  88903. /** @hidden */
  88904. constructor(loader: GLTFLoader);
  88905. /** @hidden */
  88906. dispose(): void;
  88907. /**
  88908. * Gets the list of available variant names for this asset.
  88909. * @param rootMesh The glTF root mesh
  88910. * @returns the list of all the variant names for this model
  88911. */
  88912. static GetAvailableVariants(rootMesh: Mesh): string[];
  88913. /**
  88914. * Gets the list of available variant names for this asset.
  88915. * @param rootMesh The glTF root mesh
  88916. * @returns the list of all the variant names for this model
  88917. */
  88918. getAvailableVariants(rootMesh: Mesh): string[];
  88919. /**
  88920. * Select a variant given a variant name or a list of variant names.
  88921. * @param rootMesh The glTF root mesh
  88922. * @param variantName The variant name(s) to select.
  88923. */
  88924. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88925. /**
  88926. * Select a variant given a variant name or a list of variant names.
  88927. * @param rootMesh The glTF root mesh
  88928. * @param variantName The variant name(s) to select.
  88929. */
  88930. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88931. /**
  88932. * Reset back to the original before selecting a variant.
  88933. * @param rootMesh The glTF root mesh
  88934. */
  88935. static Reset(rootMesh: Mesh): void;
  88936. /**
  88937. * Reset back to the original before selecting a variant.
  88938. * @param rootMesh The glTF root mesh
  88939. */
  88940. reset(rootMesh: Mesh): void;
  88941. /**
  88942. * Gets the last selected variant name(s) or null if original.
  88943. * @param rootMesh The glTF root mesh
  88944. * @returns The selected variant name(s).
  88945. */
  88946. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88947. /**
  88948. * Gets the last selected variant name(s) or null if original.
  88949. * @param rootMesh The glTF root mesh
  88950. * @returns The selected variant name(s).
  88951. */
  88952. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88953. private static _GetExtensionMetadata;
  88954. /** @hidden */
  88955. onLoading(): void;
  88956. /** @hidden */
  88957. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88958. }
  88959. }
  88960. declare module BABYLON.GLTF2.Loader.Extensions {
  88961. /**
  88962. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88963. */
  88964. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88965. /**
  88966. * The name of this extension.
  88967. */
  88968. readonly name: string;
  88969. /**
  88970. * Defines whether this extension is enabled.
  88971. */
  88972. enabled: boolean;
  88973. /**
  88974. * Defines a number that determines the order the extensions are applied.
  88975. */
  88976. order: number;
  88977. private _loader;
  88978. /** @hidden */
  88979. constructor(loader: GLTFLoader);
  88980. /** @hidden */
  88981. dispose(): void;
  88982. /** @hidden */
  88983. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88984. private _loadTransparentPropertiesAsync;
  88985. }
  88986. }
  88987. declare module BABYLON.GLTF2.Loader.Extensions {
  88988. /**
  88989. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88990. * !!! Experimental Extension Subject to Changes !!!
  88991. */
  88992. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88993. /**
  88994. * The name of this extension.
  88995. */
  88996. readonly name: string;
  88997. /**
  88998. * Defines whether this extension is enabled.
  88999. */
  89000. enabled: boolean;
  89001. /**
  89002. * Defines a number that determines the order the extensions are applied.
  89003. */
  89004. order: number;
  89005. private _loader;
  89006. /** @hidden */
  89007. constructor(loader: GLTFLoader);
  89008. /** @hidden */
  89009. dispose(): void;
  89010. /** @hidden */
  89011. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89012. private _loadTranslucentPropertiesAsync;
  89013. }
  89014. }
  89015. declare module BABYLON.GLTF2.Loader.Extensions {
  89016. /**
  89017. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  89018. */
  89019. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  89020. /**
  89021. * The name of this extension.
  89022. */
  89023. readonly name: string;
  89024. /**
  89025. * Defines whether this extension is enabled.
  89026. */
  89027. enabled: boolean;
  89028. /** @hidden */
  89029. constructor(loader: GLTFLoader);
  89030. /** @hidden */
  89031. dispose(): void;
  89032. }
  89033. }
  89034. declare module BABYLON.GLTF2.Loader.Extensions {
  89035. /**
  89036. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  89037. * !!! Experimental Extension Subject to Changes !!!
  89038. */
  89039. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  89040. /** The name of this extension. */
  89041. readonly name: string;
  89042. /** Defines whether this extension is enabled. */
  89043. enabled: boolean;
  89044. private _loader;
  89045. /** @hidden */
  89046. constructor(loader: GLTFLoader);
  89047. /** @hidden */
  89048. dispose(): void;
  89049. /** @hidden */
  89050. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89051. }
  89052. }
  89053. declare module BABYLON.GLTF2.Loader.Extensions {
  89054. /**
  89055. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  89056. */
  89057. export class KHR_texture_transform implements IGLTFLoaderExtension {
  89058. /**
  89059. * The name of this extension.
  89060. */
  89061. readonly name: string;
  89062. /**
  89063. * Defines whether this extension is enabled.
  89064. */
  89065. enabled: boolean;
  89066. private _loader;
  89067. /** @hidden */
  89068. constructor(loader: GLTFLoader);
  89069. /** @hidden */
  89070. dispose(): void;
  89071. /** @hidden */
  89072. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  89073. }
  89074. }
  89075. declare module BABYLON.GLTF2.Loader.Extensions {
  89076. /**
  89077. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1893)
  89078. * !!! Experimental Extension Subject to Changes !!!
  89079. */
  89080. export class KHR_xmp_json_ld implements IGLTFLoaderExtension {
  89081. /**
  89082. * The name of this extension.
  89083. */
  89084. readonly name: string;
  89085. /**
  89086. * Defines whether this extension is enabled.
  89087. */
  89088. enabled: boolean;
  89089. /**
  89090. * Defines a number that determines the order the extensions are applied.
  89091. */
  89092. order: number;
  89093. private _loader;
  89094. /** @hidden */
  89095. constructor(loader: GLTFLoader);
  89096. /** @hidden */
  89097. dispose(): void;
  89098. /**
  89099. * Called after the loader state changes to LOADING.
  89100. */
  89101. onLoading(): void;
  89102. }
  89103. }
  89104. declare module BABYLON.GLTF2.Loader.Extensions {
  89105. /**
  89106. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  89107. */
  89108. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  89109. /**
  89110. * The name of this extension.
  89111. */
  89112. readonly name: string;
  89113. /**
  89114. * Defines whether this extension is enabled.
  89115. */
  89116. enabled: boolean;
  89117. private _loader;
  89118. private _clips;
  89119. private _emitters;
  89120. /** @hidden */
  89121. constructor(loader: GLTFLoader);
  89122. /** @hidden */
  89123. dispose(): void;
  89124. /** @hidden */
  89125. onLoading(): void;
  89126. /** @hidden */
  89127. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89128. /** @hidden */
  89129. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89130. /** @hidden */
  89131. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  89132. private _loadClipAsync;
  89133. private _loadEmitterAsync;
  89134. private _getEventAction;
  89135. private _loadAnimationEventAsync;
  89136. }
  89137. }
  89138. declare module BABYLON.GLTF2.Loader.Extensions {
  89139. /**
  89140. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  89141. */
  89142. export class MSFT_lod implements IGLTFLoaderExtension {
  89143. /**
  89144. * The name of this extension.
  89145. */
  89146. readonly name: string;
  89147. /**
  89148. * Defines whether this extension is enabled.
  89149. */
  89150. enabled: boolean;
  89151. /**
  89152. * Defines a number that determines the order the extensions are applied.
  89153. */
  89154. order: number;
  89155. /**
  89156. * Maximum number of LODs to load, starting from the lowest LOD.
  89157. */
  89158. maxLODsToLoad: number;
  89159. /**
  89160. * Observable raised when all node LODs of one level are loaded.
  89161. * The event data is the index of the loaded LOD starting from zero.
  89162. * Dispose the loader to cancel the loading of the next level of LODs.
  89163. */
  89164. onNodeLODsLoadedObservable: Observable<number>;
  89165. /**
  89166. * Observable raised when all material LODs of one level are loaded.
  89167. * The event data is the index of the loaded LOD starting from zero.
  89168. * Dispose the loader to cancel the loading of the next level of LODs.
  89169. */
  89170. onMaterialLODsLoadedObservable: Observable<number>;
  89171. private _loader;
  89172. private _bufferLODs;
  89173. private _nodeIndexLOD;
  89174. private _nodeSignalLODs;
  89175. private _nodePromiseLODs;
  89176. private _nodeBufferLODs;
  89177. private _materialIndexLOD;
  89178. private _materialSignalLODs;
  89179. private _materialPromiseLODs;
  89180. private _materialBufferLODs;
  89181. /** @hidden */
  89182. constructor(loader: GLTFLoader);
  89183. /** @hidden */
  89184. dispose(): void;
  89185. /** @hidden */
  89186. onReady(): void;
  89187. /** @hidden */
  89188. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  89189. /** @hidden */
  89190. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89191. /** @hidden */
  89192. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  89193. /** @hidden */
  89194. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  89195. /** @hidden */
  89196. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  89197. private _loadBufferLOD;
  89198. /**
  89199. * Gets an array of LOD properties from lowest to highest.
  89200. */
  89201. private _getLODs;
  89202. private _disposeTransformNode;
  89203. private _disposeMaterials;
  89204. }
  89205. }
  89206. declare module BABYLON.GLTF2.Loader.Extensions {
  89207. /** @hidden */
  89208. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  89209. readonly name: string;
  89210. enabled: boolean;
  89211. private _loader;
  89212. constructor(loader: GLTFLoader);
  89213. dispose(): void;
  89214. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89215. }
  89216. }
  89217. declare module BABYLON.GLTF2.Loader.Extensions {
  89218. /** @hidden */
  89219. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  89220. readonly name: string;
  89221. enabled: boolean;
  89222. private _loader;
  89223. constructor(loader: GLTFLoader);
  89224. dispose(): void;
  89225. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  89226. }
  89227. }
  89228. declare module BABYLON.GLTF2.Loader.Extensions {
  89229. /**
  89230. * Store glTF extras (if present) in BJS objects' metadata
  89231. */
  89232. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  89233. /**
  89234. * The name of this extension.
  89235. */
  89236. readonly name: string;
  89237. /**
  89238. * Defines whether this extension is enabled.
  89239. */
  89240. enabled: boolean;
  89241. private _loader;
  89242. private _assignExtras;
  89243. /** @hidden */
  89244. constructor(loader: GLTFLoader);
  89245. /** @hidden */
  89246. dispose(): void;
  89247. /** @hidden */
  89248. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  89249. /** @hidden */
  89250. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  89251. /** @hidden */
  89252. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  89253. }
  89254. }
  89255. declare module BABYLON {
  89256. /**
  89257. * Class reading and parsing the MTL file bundled with the obj file.
  89258. */
  89259. export class MTLFileLoader {
  89260. /**
  89261. * Invert Y-Axis of referenced textures on load
  89262. */
  89263. static INVERT_TEXTURE_Y: boolean;
  89264. /**
  89265. * All material loaded from the mtl will be set here
  89266. */
  89267. materials: StandardMaterial[];
  89268. /**
  89269. * This function will read the mtl file and create each material described inside
  89270. * This function could be improve by adding :
  89271. * -some component missing (Ni, Tf...)
  89272. * -including the specific options available
  89273. *
  89274. * @param scene defines the scene the material will be created in
  89275. * @param data defines the mtl data to parse
  89276. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  89277. * @param forAssetContainer defines if the material should be registered in the scene
  89278. */
  89279. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  89280. /**
  89281. * Gets the texture for the material.
  89282. *
  89283. * If the material is imported from input file,
  89284. * We sanitize the url to ensure it takes the textre from aside the material.
  89285. *
  89286. * @param rootUrl The root url to load from
  89287. * @param value The value stored in the mtl
  89288. * @return The Texture
  89289. */
  89290. private static _getTexture;
  89291. }
  89292. }
  89293. declare module BABYLON {
  89294. /**
  89295. * Options for loading OBJ/MTL files
  89296. */
  89297. type MeshLoadOptions = {
  89298. /**
  89299. * Defines if UVs are optimized by default during load.
  89300. */
  89301. OptimizeWithUV: boolean;
  89302. /**
  89303. * Defines custom scaling of UV coordinates of loaded meshes.
  89304. */
  89305. UVScaling: Vector2;
  89306. /**
  89307. * Invert model on y-axis (does a model scaling inversion)
  89308. */
  89309. InvertY: boolean;
  89310. /**
  89311. * Invert Y-Axis of referenced textures on load
  89312. */
  89313. InvertTextureY: boolean;
  89314. /**
  89315. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89316. */
  89317. ImportVertexColors: boolean;
  89318. /**
  89319. * Compute the normals for the model, even if normals are present in the file.
  89320. */
  89321. ComputeNormals: boolean;
  89322. /**
  89323. * 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.
  89324. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89325. */
  89326. OptimizeNormals: boolean;
  89327. /**
  89328. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89329. */
  89330. SkipMaterials: boolean;
  89331. /**
  89332. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89333. */
  89334. MaterialLoadingFailsSilently: boolean;
  89335. };
  89336. /**
  89337. * OBJ file type loader.
  89338. * This is a babylon scene loader plugin.
  89339. */
  89340. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  89341. /**
  89342. * Defines if UVs are optimized by default during load.
  89343. */
  89344. static OPTIMIZE_WITH_UV: boolean;
  89345. /**
  89346. * Invert model on y-axis (does a model scaling inversion)
  89347. */
  89348. static INVERT_Y: boolean;
  89349. /**
  89350. * Invert Y-Axis of referenced textures on load
  89351. */
  89352. static get INVERT_TEXTURE_Y(): boolean;
  89353. static set INVERT_TEXTURE_Y(value: boolean);
  89354. /**
  89355. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  89356. */
  89357. static IMPORT_VERTEX_COLORS: boolean;
  89358. /**
  89359. * Compute the normals for the model, even if normals are present in the file.
  89360. */
  89361. static COMPUTE_NORMALS: boolean;
  89362. /**
  89363. * 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.
  89364. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  89365. */
  89366. static OPTIMIZE_NORMALS: boolean;
  89367. /**
  89368. * Defines custom scaling of UV coordinates of loaded meshes.
  89369. */
  89370. static UV_SCALING: Vector2;
  89371. /**
  89372. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  89373. */
  89374. static SKIP_MATERIALS: boolean;
  89375. /**
  89376. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  89377. *
  89378. * Defaults to true for backwards compatibility.
  89379. */
  89380. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  89381. /**
  89382. * Defines the name of the plugin.
  89383. */
  89384. name: string;
  89385. /**
  89386. * Defines the extension the plugin is able to load.
  89387. */
  89388. extensions: string;
  89389. /** @hidden */
  89390. obj: RegExp;
  89391. /** @hidden */
  89392. group: RegExp;
  89393. /** @hidden */
  89394. mtllib: RegExp;
  89395. /** @hidden */
  89396. usemtl: RegExp;
  89397. /** @hidden */
  89398. smooth: RegExp;
  89399. /** @hidden */
  89400. vertexPattern: RegExp;
  89401. /** @hidden */
  89402. normalPattern: RegExp;
  89403. /** @hidden */
  89404. uvPattern: RegExp;
  89405. /** @hidden */
  89406. facePattern1: RegExp;
  89407. /** @hidden */
  89408. facePattern2: RegExp;
  89409. /** @hidden */
  89410. facePattern3: RegExp;
  89411. /** @hidden */
  89412. facePattern4: RegExp;
  89413. /** @hidden */
  89414. facePattern5: RegExp;
  89415. private _forAssetContainer;
  89416. private _meshLoadOptions;
  89417. /**
  89418. * Creates loader for .OBJ files
  89419. *
  89420. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  89421. */
  89422. constructor(meshLoadOptions?: MeshLoadOptions);
  89423. private static get currentMeshLoadOptions();
  89424. /**
  89425. * Calls synchronously the MTL file attached to this obj.
  89426. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  89427. * Without this function materials are not displayed in the first frame (but displayed after).
  89428. * In consequence it is impossible to get material information in your HTML file
  89429. *
  89430. * @param url The URL of the MTL file
  89431. * @param rootUrl
  89432. * @param onSuccess Callback function to be called when the MTL file is loaded
  89433. * @private
  89434. */
  89435. private _loadMTL;
  89436. /**
  89437. * Instantiates a OBJ file loader plugin.
  89438. * @returns the created plugin
  89439. */
  89440. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  89441. /**
  89442. * If the data string can be loaded directly.
  89443. *
  89444. * @param data string containing the file data
  89445. * @returns if the data can be loaded directly
  89446. */
  89447. canDirectLoad(data: string): boolean;
  89448. /**
  89449. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  89450. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  89451. * @param scene the scene the meshes should be added to
  89452. * @param data the OBJ data to load
  89453. * @param rootUrl root url to load from
  89454. * @param onProgress event that fires when loading progress has occured
  89455. * @param fileName Defines the name of the file to load
  89456. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  89457. */
  89458. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  89459. /**
  89460. * Imports all objects from the loaded OBJ data and adds them to the scene
  89461. * @param scene the scene the objects should be added to
  89462. * @param data the OBJ data to load
  89463. * @param rootUrl root url to load from
  89464. * @param onProgress event that fires when loading progress has occured
  89465. * @param fileName Defines the name of the file to load
  89466. * @returns a promise which completes when objects have been loaded to the scene
  89467. */
  89468. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  89469. /**
  89470. * Load into an asset container.
  89471. * @param scene The scene to load into
  89472. * @param data The data to import
  89473. * @param rootUrl The root url for scene and resources
  89474. * @param onProgress The callback when the load progresses
  89475. * @param fileName Defines the name of the file to load
  89476. * @returns The loaded asset container
  89477. */
  89478. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  89479. private _optimizeNormals;
  89480. /**
  89481. * Read the OBJ file and create an Array of meshes.
  89482. * Each mesh contains all information given by the OBJ and the MTL file.
  89483. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  89484. *
  89485. * @param meshesNames
  89486. * @param scene Scene The scene where are displayed the data
  89487. * @param data String The content of the obj file
  89488. * @param rootUrl String The path to the folder
  89489. * @returns Array<AbstractMesh>
  89490. * @private
  89491. */
  89492. private _parseSolid;
  89493. }
  89494. }
  89495. declare module BABYLON {
  89496. /**
  89497. * STL file type loader.
  89498. * This is a babylon scene loader plugin.
  89499. */
  89500. export class STLFileLoader implements ISceneLoaderPlugin {
  89501. /** @hidden */
  89502. solidPattern: RegExp;
  89503. /** @hidden */
  89504. facetsPattern: RegExp;
  89505. /** @hidden */
  89506. normalPattern: RegExp;
  89507. /** @hidden */
  89508. vertexPattern: RegExp;
  89509. /**
  89510. * Defines the name of the plugin.
  89511. */
  89512. name: string;
  89513. /**
  89514. * Defines the extensions the stl loader is able to load.
  89515. * force data to come in as an ArrayBuffer
  89516. * we'll convert to string if it looks like it's an ASCII .stl
  89517. */
  89518. extensions: ISceneLoaderPluginExtensions;
  89519. /**
  89520. * Import meshes into a scene.
  89521. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  89522. * @param scene The scene to import into
  89523. * @param data The data to import
  89524. * @param rootUrl The root url for scene and resources
  89525. * @param meshes The meshes array to import into
  89526. * @param particleSystems The particle systems array to import into
  89527. * @param skeletons The skeletons array to import into
  89528. * @param onError The callback when import fails
  89529. * @returns True if successful or false otherwise
  89530. */
  89531. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  89532. /**
  89533. * Load into a scene.
  89534. * @param scene The scene to load into
  89535. * @param data The data to import
  89536. * @param rootUrl The root url for scene and resources
  89537. * @param onError The callback when import fails
  89538. * @returns true if successful or false otherwise
  89539. */
  89540. load(scene: Scene, data: any, rootUrl: string): boolean;
  89541. /**
  89542. * Load into an asset container.
  89543. * @param scene The scene to load into
  89544. * @param data The data to import
  89545. * @param rootUrl The root url for scene and resources
  89546. * @param onError The callback when import fails
  89547. * @returns The loaded asset container
  89548. */
  89549. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  89550. private _isBinary;
  89551. private _parseBinary;
  89552. private _parseASCII;
  89553. }
  89554. }
  89555. declare module BABYLON {
  89556. /**
  89557. * Class for generating OBJ data from a Babylon scene.
  89558. */
  89559. export class OBJExport {
  89560. /**
  89561. * Exports the geometry of a Mesh array in .OBJ file format (text)
  89562. * @param mesh defines the list of meshes to serialize
  89563. * @param materials defines if materials should be exported
  89564. * @param matlibname defines the name of the associated mtl file
  89565. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  89566. * @returns the OBJ content
  89567. */
  89568. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  89569. /**
  89570. * Exports the material(s) of a mesh in .MTL file format (text)
  89571. * @param mesh defines the mesh to extract the material from
  89572. * @returns the mtl content
  89573. */
  89574. static MTL(mesh: Mesh): string;
  89575. }
  89576. }
  89577. declare module BABYLON {
  89578. /** @hidden */
  89579. export var __IGLTFExporterExtension: number;
  89580. /**
  89581. * Interface for extending the exporter
  89582. * @hidden
  89583. */
  89584. export interface IGLTFExporterExtension {
  89585. /**
  89586. * The name of this extension
  89587. */
  89588. readonly name: string;
  89589. /**
  89590. * Defines whether this extension is enabled
  89591. */
  89592. enabled: boolean;
  89593. /**
  89594. * Defines whether this extension is required
  89595. */
  89596. required: boolean;
  89597. }
  89598. }
  89599. declare module BABYLON.GLTF2.Exporter {
  89600. /** @hidden */
  89601. export var __IGLTFExporterExtensionV2: number;
  89602. /**
  89603. * Interface for a glTF exporter extension
  89604. * @hidden
  89605. */
  89606. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  89607. /**
  89608. * Define this method to modify the default behavior before exporting a texture
  89609. * @param context The context when loading the asset
  89610. * @param babylonTexture The Babylon.js texture
  89611. * @param mimeType The mime-type of the generated image
  89612. * @returns A promise that resolves with the exported texture
  89613. */
  89614. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  89615. /**
  89616. * Define this method to get notified when a texture info is created
  89617. * @param context The context when loading the asset
  89618. * @param textureInfo The glTF texture info
  89619. * @param babylonTexture The Babylon.js texture
  89620. */
  89621. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89622. /**
  89623. * Define this method to modify the default behavior when exporting texture info
  89624. * @param context The context when loading the asset
  89625. * @param meshPrimitive glTF mesh primitive
  89626. * @param babylonSubMesh Babylon submesh
  89627. * @param binaryWriter glTF serializer binary writer instance
  89628. * @returns nullable IMeshPrimitive promise
  89629. */
  89630. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  89631. /**
  89632. * Define this method to modify the default behavior when exporting a node
  89633. * @param context The context when exporting the node
  89634. * @param node glTF node
  89635. * @param babylonNode BabylonJS node
  89636. * @returns nullable INode promise
  89637. */
  89638. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89639. [key: number]: number;
  89640. }): Promise<Nullable<INode>>;
  89641. /**
  89642. * Define this method to modify the default behavior when exporting a material
  89643. * @param material glTF material
  89644. * @param babylonMaterial BabylonJS material
  89645. * @returns nullable IMaterial promise
  89646. */
  89647. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  89648. /**
  89649. * Define this method to return additional textures to export from a material
  89650. * @param material glTF material
  89651. * @param babylonMaterial BabylonJS material
  89652. * @returns List of textures
  89653. */
  89654. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89655. /** Gets a boolean indicating that this extension was used */
  89656. wasUsed: boolean;
  89657. /** Gets a boolean indicating that this extension is required for the file to work */
  89658. required: boolean;
  89659. /**
  89660. * Called after the exporter state changes to EXPORTING
  89661. */
  89662. onExporting?(): void;
  89663. }
  89664. }
  89665. declare module BABYLON.GLTF2.Exporter {
  89666. /**
  89667. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  89668. * @hidden
  89669. */
  89670. export class _GLTFMaterialExporter {
  89671. /**
  89672. * Represents the dielectric specular values for R, G and B
  89673. */
  89674. private static readonly _DielectricSpecular;
  89675. /**
  89676. * Allows the maximum specular power to be defined for material calculations
  89677. */
  89678. private static readonly _MaxSpecularPower;
  89679. /**
  89680. * Mapping to store textures
  89681. */
  89682. private _textureMap;
  89683. /**
  89684. * Numeric tolerance value
  89685. */
  89686. private static readonly _Epsilon;
  89687. /**
  89688. * Reference to the glTF Exporter
  89689. */
  89690. private _exporter;
  89691. constructor(exporter: _Exporter);
  89692. /**
  89693. * Specifies if two colors are approximately equal in value
  89694. * @param color1 first color to compare to
  89695. * @param color2 second color to compare to
  89696. * @param epsilon threshold value
  89697. */
  89698. private static FuzzyEquals;
  89699. /**
  89700. * Gets the materials from a Babylon scene and converts them to glTF materials
  89701. * @param scene babylonjs scene
  89702. * @param mimeType texture mime type
  89703. * @param images array of images
  89704. * @param textures array of textures
  89705. * @param materials array of materials
  89706. * @param imageData mapping of texture names to base64 textures
  89707. * @param hasTextureCoords specifies if texture coordinates are present on the material
  89708. */
  89709. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89710. /**
  89711. * Makes a copy of the glTF material without the texture parameters
  89712. * @param originalMaterial original glTF material
  89713. * @returns glTF material without texture parameters
  89714. */
  89715. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89716. /**
  89717. * Specifies if the material has any texture parameters present
  89718. * @param material glTF Material
  89719. * @returns boolean specifying if texture parameters are present
  89720. */
  89721. _hasTexturesPresent(material: IMaterial): boolean;
  89722. /**
  89723. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89724. * @param babylonStandardMaterial
  89725. * @returns glTF Metallic Roughness Material representation
  89726. */
  89727. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89728. /**
  89729. * Computes the metallic factor
  89730. * @param diffuse diffused value
  89731. * @param specular specular value
  89732. * @param oneMinusSpecularStrength one minus the specular strength
  89733. * @returns metallic value
  89734. */
  89735. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89736. /**
  89737. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89738. * @param glTFMaterial glTF material
  89739. * @param babylonMaterial Babylon material
  89740. */
  89741. private static _SetAlphaMode;
  89742. /**
  89743. * Converts a Babylon Standard Material to a glTF Material
  89744. * @param babylonStandardMaterial BJS Standard Material
  89745. * @param mimeType mime type to use for the textures
  89746. * @param images array of glTF image interfaces
  89747. * @param textures array of glTF texture interfaces
  89748. * @param materials array of glTF material interfaces
  89749. * @param imageData map of image file name to data
  89750. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89751. */
  89752. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89753. private _finishMaterial;
  89754. /**
  89755. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89756. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89757. * @param mimeType mime type to use for the textures
  89758. * @param images array of glTF image interfaces
  89759. * @param textures array of glTF texture interfaces
  89760. * @param materials array of glTF material interfaces
  89761. * @param imageData map of image file name to data
  89762. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89763. */
  89764. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89765. /**
  89766. * Converts an image typed array buffer to a base64 image
  89767. * @param buffer typed array buffer
  89768. * @param width width of the image
  89769. * @param height height of the image
  89770. * @param mimeType mimetype of the image
  89771. * @returns base64 image string
  89772. */
  89773. private _createBase64FromCanvasAsync;
  89774. /**
  89775. * Generates a white texture based on the specified width and height
  89776. * @param width width of the texture in pixels
  89777. * @param height height of the texture in pixels
  89778. * @param scene babylonjs scene
  89779. * @returns white texture
  89780. */
  89781. private _createWhiteTexture;
  89782. /**
  89783. * 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
  89784. * @param texture1 first texture to resize
  89785. * @param texture2 second texture to resize
  89786. * @param scene babylonjs scene
  89787. * @returns resized textures or null
  89788. */
  89789. private _resizeTexturesToSameDimensions;
  89790. /**
  89791. * Converts an array of pixels to a Float32Array
  89792. * Throws an error if the pixel format is not supported
  89793. * @param pixels - array buffer containing pixel values
  89794. * @returns Float32 of pixels
  89795. */
  89796. private _convertPixelArrayToFloat32;
  89797. /**
  89798. * Convert Specular Glossiness Textures to Metallic Roughness
  89799. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89800. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89801. * @param diffuseTexture texture used to store diffuse information
  89802. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89803. * @param factors specular glossiness material factors
  89804. * @param mimeType the mime type to use for the texture
  89805. * @returns pbr metallic roughness interface or null
  89806. */
  89807. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89808. /**
  89809. * Converts specular glossiness material properties to metallic roughness
  89810. * @param specularGlossiness interface with specular glossiness material properties
  89811. * @returns interface with metallic roughness material properties
  89812. */
  89813. private _convertSpecularGlossinessToMetallicRoughness;
  89814. /**
  89815. * Calculates the surface reflectance, independent of lighting conditions
  89816. * @param color Color source to calculate brightness from
  89817. * @returns number representing the perceived brightness, or zero if color is undefined
  89818. */
  89819. private _getPerceivedBrightness;
  89820. /**
  89821. * Returns the maximum color component value
  89822. * @param color
  89823. * @returns maximum color component value, or zero if color is null or undefined
  89824. */
  89825. private _getMaxComponent;
  89826. /**
  89827. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89828. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89829. * @param mimeType mime type to use for the textures
  89830. * @param images array of glTF image interfaces
  89831. * @param textures array of glTF texture interfaces
  89832. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89833. * @param imageData map of image file name to data
  89834. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89835. * @returns glTF PBR Metallic Roughness factors
  89836. */
  89837. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89838. private _getGLTFTextureSampler;
  89839. private _getGLTFTextureWrapMode;
  89840. private _getGLTFTextureWrapModesSampler;
  89841. /**
  89842. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89843. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89844. * @param mimeType mime type to use for the textures
  89845. * @param images array of glTF image interfaces
  89846. * @param textures array of glTF texture interfaces
  89847. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89848. * @param imageData map of image file name to data
  89849. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89850. * @returns glTF PBR Metallic Roughness factors
  89851. */
  89852. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89853. /**
  89854. * Converts a Babylon PBR Base Material to a glTF Material
  89855. * @param babylonPBRMaterial BJS PBR Base Material
  89856. * @param mimeType mime type to use for the textures
  89857. * @param images array of glTF image interfaces
  89858. * @param textures array of glTF texture interfaces
  89859. * @param materials array of glTF material interfaces
  89860. * @param imageData map of image file name to data
  89861. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89862. */
  89863. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89864. private setMetallicRoughnessPbrMaterial;
  89865. private getPixelsFromTexture;
  89866. /**
  89867. * Extracts a texture from a Babylon texture into file data and glTF data
  89868. * @param babylonTexture Babylon texture to extract
  89869. * @param mimeType Mime Type of the babylonTexture
  89870. * @return glTF texture info, or null if the texture format is not supported
  89871. */
  89872. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89873. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89874. /**
  89875. * Builds a texture from base64 string
  89876. * @param base64Texture base64 texture string
  89877. * @param baseTextureName Name to use for the texture
  89878. * @param mimeType image mime type for the texture
  89879. * @param images array of images
  89880. * @param textures array of textures
  89881. * @param imageData map of image data
  89882. * @returns glTF texture info, or null if the texture format is not supported
  89883. */
  89884. private _getTextureInfoFromBase64;
  89885. }
  89886. }
  89887. declare module BABYLON {
  89888. /**
  89889. * Class for holding and downloading glTF file data
  89890. */
  89891. export class GLTFData {
  89892. /**
  89893. * Object which contains the file name as the key and its data as the value
  89894. */
  89895. glTFFiles: {
  89896. [fileName: string]: string | Blob;
  89897. };
  89898. /**
  89899. * Initializes the glTF file object
  89900. */
  89901. constructor();
  89902. /**
  89903. * Downloads the glTF data as files based on their names and data
  89904. */
  89905. downloadFiles(): void;
  89906. }
  89907. }
  89908. declare module BABYLON {
  89909. /**
  89910. * Holds a collection of exporter options and parameters
  89911. */
  89912. export interface IExportOptions {
  89913. /**
  89914. * Function which indicates whether a babylon node should be exported or not
  89915. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89916. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89917. */
  89918. shouldExportNode?(node: Node): boolean;
  89919. /**
  89920. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89921. * @param metadata source metadata to read from
  89922. * @returns the data to store to glTF node extras
  89923. */
  89924. metadataSelector?(metadata: any): any;
  89925. /**
  89926. * The sample rate to bake animation curves
  89927. */
  89928. animationSampleRate?: number;
  89929. /**
  89930. * Begin serialization without waiting for the scene to be ready
  89931. */
  89932. exportWithoutWaitingForScene?: boolean;
  89933. /**
  89934. * Indicates if coordinate system swapping root nodes should be included in export
  89935. */
  89936. includeCoordinateSystemConversionNodes?: boolean;
  89937. }
  89938. /**
  89939. * Class for generating glTF data from a Babylon scene.
  89940. */
  89941. export class GLTF2Export {
  89942. /**
  89943. * Exports the geometry of the scene to .gltf file format asynchronously
  89944. * @param scene Babylon scene with scene hierarchy information
  89945. * @param filePrefix File prefix to use when generating the glTF file
  89946. * @param options Exporter options
  89947. * @returns Returns an object with a .gltf file and associates texture names
  89948. * as keys and their data and paths as values
  89949. */
  89950. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89951. private static _PreExportAsync;
  89952. private static _PostExportAsync;
  89953. /**
  89954. * Exports the geometry of the scene to .glb file format asychronously
  89955. * @param scene Babylon scene with scene hierarchy information
  89956. * @param filePrefix File prefix to use when generating glb file
  89957. * @param options Exporter options
  89958. * @returns Returns an object with a .glb filename as key and data as value
  89959. */
  89960. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89961. }
  89962. }
  89963. declare module BABYLON.GLTF2.Exporter {
  89964. /**
  89965. * @hidden
  89966. */
  89967. export class _GLTFUtilities {
  89968. /**
  89969. * Creates a buffer view based on the supplied arguments
  89970. * @param bufferIndex index value of the specified buffer
  89971. * @param byteOffset byte offset value
  89972. * @param byteLength byte length of the bufferView
  89973. * @param byteStride byte distance between conequential elements
  89974. * @param name name of the buffer view
  89975. * @returns bufferView for glTF
  89976. */
  89977. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89978. /**
  89979. * Creates an accessor based on the supplied arguments
  89980. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89981. * @param name The name of the accessor
  89982. * @param type The type of the accessor
  89983. * @param componentType The datatype of components in the attribute
  89984. * @param count The number of attributes referenced by this accessor
  89985. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89986. * @param min Minimum value of each component in this attribute
  89987. * @param max Maximum value of each component in this attribute
  89988. * @returns accessor for glTF
  89989. */
  89990. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89991. /**
  89992. * Calculates the minimum and maximum values of an array of position floats
  89993. * @param positions Positions array of a mesh
  89994. * @param vertexStart Starting vertex offset to calculate min and max values
  89995. * @param vertexCount Number of vertices to check for min and max values
  89996. * @returns min number array and max number array
  89997. */
  89998. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89999. min: number[];
  90000. max: number[];
  90001. };
  90002. /**
  90003. * Converts a new right-handed Vector3
  90004. * @param vector vector3 array
  90005. * @returns right-handed Vector3
  90006. */
  90007. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  90008. /**
  90009. * Converts a Vector3 to right-handed
  90010. * @param vector Vector3 to convert to right-handed
  90011. */
  90012. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  90013. /**
  90014. * Converts a three element number array to right-handed
  90015. * @param vector number array to convert to right-handed
  90016. */
  90017. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  90018. /**
  90019. * Converts a new right-handed Vector3
  90020. * @param vector vector3 array
  90021. * @returns right-handed Vector3
  90022. */
  90023. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  90024. /**
  90025. * Converts a Vector3 to right-handed
  90026. * @param vector Vector3 to convert to right-handed
  90027. */
  90028. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  90029. /**
  90030. * Converts a three element number array to right-handed
  90031. * @param vector number array to convert to right-handed
  90032. */
  90033. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  90034. /**
  90035. * Converts a Vector4 to right-handed
  90036. * @param vector Vector4 to convert to right-handed
  90037. */
  90038. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  90039. /**
  90040. * Converts a Vector4 to right-handed
  90041. * @param vector Vector4 to convert to right-handed
  90042. */
  90043. static _GetRightHandedArray4FromRef(vector: number[]): void;
  90044. /**
  90045. * Converts a Quaternion to right-handed
  90046. * @param quaternion Source quaternion to convert to right-handed
  90047. */
  90048. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  90049. /**
  90050. * Converts a Quaternion to right-handed
  90051. * @param quaternion Source quaternion to convert to right-handed
  90052. */
  90053. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  90054. static _NormalizeTangentFromRef(tangent: Vector4): void;
  90055. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  90056. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  90057. }
  90058. }
  90059. declare module BABYLON.GLTF2.Exporter {
  90060. /**
  90061. * Converts Babylon Scene into glTF 2.0.
  90062. * @hidden
  90063. */
  90064. export class _Exporter {
  90065. /**
  90066. * Stores the glTF to export
  90067. */
  90068. _glTF: IGLTF;
  90069. /**
  90070. * Stores all generated buffer views, which represents views into the main glTF buffer data
  90071. */
  90072. _bufferViews: IBufferView[];
  90073. /**
  90074. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  90075. */
  90076. _accessors: IAccessor[];
  90077. /**
  90078. * Stores all the generated nodes, which contains transform and/or mesh information per node
  90079. */
  90080. _nodes: INode[];
  90081. /**
  90082. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  90083. */
  90084. private _scenes;
  90085. /**
  90086. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  90087. */
  90088. private _meshes;
  90089. /**
  90090. * Stores all the generated material information, which represents the appearance of each primitive
  90091. */
  90092. _materials: IMaterial[];
  90093. _materialMap: {
  90094. [materialID: number]: number;
  90095. };
  90096. /**
  90097. * Stores all the generated texture information, which is referenced by glTF materials
  90098. */
  90099. _textures: ITexture[];
  90100. /**
  90101. * Stores all the generated image information, which is referenced by glTF textures
  90102. */
  90103. _images: IImage[];
  90104. /**
  90105. * Stores all the texture samplers
  90106. */
  90107. _samplers: ISampler[];
  90108. /**
  90109. * Stores all the generated glTF skins
  90110. */
  90111. _skins: ISkin[];
  90112. /**
  90113. * Stores all the generated animation samplers, which is referenced by glTF animations
  90114. */
  90115. /**
  90116. * Stores the animations for glTF models
  90117. */
  90118. private _animations;
  90119. /**
  90120. * Stores the total amount of bytes stored in the glTF buffer
  90121. */
  90122. private _totalByteLength;
  90123. /**
  90124. * Stores a reference to the Babylon scene containing the source geometry and material information
  90125. */
  90126. _babylonScene: Scene;
  90127. /**
  90128. * Stores a map of the image data, where the key is the file name and the value
  90129. * is the image data
  90130. */
  90131. _imageData: {
  90132. [fileName: string]: {
  90133. data: Uint8Array;
  90134. mimeType: ImageMimeType;
  90135. };
  90136. };
  90137. protected _orderedImageData: Array<{
  90138. data: Uint8Array;
  90139. mimeType: ImageMimeType;
  90140. }>;
  90141. /**
  90142. * Stores a map of the unique id of a node to its index in the node array
  90143. */
  90144. _nodeMap: {
  90145. [key: number]: number;
  90146. };
  90147. /**
  90148. * Specifies if the source Babylon scene was left handed, and needed conversion.
  90149. */
  90150. _convertToRightHandedSystem: boolean;
  90151. /**
  90152. * Specifies if a Babylon node should be converted to right-handed on export
  90153. */
  90154. _convertToRightHandedSystemMap: {
  90155. [nodeId: number]: boolean;
  90156. };
  90157. _includeCoordinateSystemConversionNodes: boolean;
  90158. /**
  90159. * Baked animation sample rate
  90160. */
  90161. private _animationSampleRate;
  90162. private _options;
  90163. private _localEngine;
  90164. _glTFMaterialExporter: _GLTFMaterialExporter;
  90165. private _extensions;
  90166. private static _ExtensionNames;
  90167. private static _ExtensionFactories;
  90168. private _applyExtension;
  90169. private _applyExtensions;
  90170. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  90171. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  90172. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90173. [key: number]: number;
  90174. }): Promise<Nullable<INode>>;
  90175. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  90176. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  90177. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  90178. private _forEachExtensions;
  90179. private _extensionsOnExporting;
  90180. /**
  90181. * Load glTF serializer extensions
  90182. */
  90183. private _loadExtensions;
  90184. /**
  90185. * Creates a glTF Exporter instance, which can accept optional exporter options
  90186. * @param babylonScene Babylon scene object
  90187. * @param options Options to modify the behavior of the exporter
  90188. */
  90189. constructor(babylonScene: Scene, options?: IExportOptions);
  90190. dispose(): void;
  90191. /**
  90192. * Registers a glTF exporter extension
  90193. * @param name Name of the extension to export
  90194. * @param factory The factory function that creates the exporter extension
  90195. */
  90196. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  90197. /**
  90198. * Un-registers an exporter extension
  90199. * @param name The name fo the exporter extension
  90200. * @returns A boolean indicating whether the extension has been un-registered
  90201. */
  90202. static UnregisterExtension(name: string): boolean;
  90203. private reorderIndicesBasedOnPrimitiveMode;
  90204. /**
  90205. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  90206. * clock-wise during export to glTF
  90207. * @param submesh BabylonJS submesh
  90208. * @param primitiveMode Primitive mode of the mesh
  90209. * @param sideOrientation the winding order of the submesh
  90210. * @param vertexBufferKind The type of vertex attribute
  90211. * @param meshAttributeArray The vertex attribute data
  90212. * @param byteOffset The offset to the binary data
  90213. * @param binaryWriter The binary data for the glTF file
  90214. * @param convertToRightHandedSystem Converts the values to right-handed
  90215. */
  90216. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  90217. /**
  90218. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  90219. * clock-wise during export to glTF
  90220. * @param submesh BabylonJS submesh
  90221. * @param primitiveMode Primitive mode of the mesh
  90222. * @param sideOrientation the winding order of the submesh
  90223. * @param vertexBufferKind The type of vertex attribute
  90224. * @param meshAttributeArray The vertex attribute data
  90225. * @param byteOffset The offset to the binary data
  90226. * @param binaryWriter The binary data for the glTF file
  90227. * @param convertToRightHandedSystem Converts the values to right-handed
  90228. */
  90229. private reorderTriangleFillMode;
  90230. /**
  90231. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  90232. * clock-wise during export to glTF
  90233. * @param submesh BabylonJS submesh
  90234. * @param primitiveMode Primitive mode of the mesh
  90235. * @param sideOrientation the winding order of the submesh
  90236. * @param vertexBufferKind The type of vertex attribute
  90237. * @param meshAttributeArray The vertex attribute data
  90238. * @param byteOffset The offset to the binary data
  90239. * @param binaryWriter The binary data for the glTF file
  90240. * @param convertToRightHandedSystem Converts the values to right-handed
  90241. */
  90242. private reorderTriangleStripDrawMode;
  90243. /**
  90244. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  90245. * clock-wise during export to glTF
  90246. * @param submesh BabylonJS submesh
  90247. * @param primitiveMode Primitive mode of the mesh
  90248. * @param sideOrientation the winding order of the submesh
  90249. * @param vertexBufferKind The type of vertex attribute
  90250. * @param meshAttributeArray The vertex attribute data
  90251. * @param byteOffset The offset to the binary data
  90252. * @param binaryWriter The binary data for the glTF file
  90253. * @param convertToRightHandedSystem Converts the values to right-handed
  90254. */
  90255. private reorderTriangleFanMode;
  90256. /**
  90257. * Writes the vertex attribute data to binary
  90258. * @param vertices The vertices to write to the binary writer
  90259. * @param byteOffset The offset into the binary writer to overwrite binary data
  90260. * @param vertexAttributeKind The vertex attribute type
  90261. * @param meshAttributeArray The vertex attribute data
  90262. * @param binaryWriter The writer containing the binary data
  90263. * @param convertToRightHandedSystem Converts the values to right-handed
  90264. */
  90265. private writeVertexAttributeData;
  90266. /**
  90267. * Writes mesh attribute data to a data buffer
  90268. * Returns the bytelength of the data
  90269. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90270. * @param meshAttributeArray Array containing the attribute data
  90271. * @param byteStride Specifies the space between data
  90272. * @param binaryWriter The buffer to write the binary data to
  90273. * @param convertToRightHandedSystem Converts the values to right-handed
  90274. */
  90275. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  90276. /**
  90277. * Writes mesh attribute data to a data buffer
  90278. * Returns the bytelength of the data
  90279. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  90280. * @param meshAttributeArray Array containing the attribute data
  90281. * @param byteStride Specifies the space between data
  90282. * @param binaryWriter The buffer to write the binary data to
  90283. * @param convertToRightHandedSystem Converts the values to right-handed
  90284. */
  90285. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  90286. /**
  90287. * Generates glTF json data
  90288. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  90289. * @param glTFPrefix Text to use when prefixing a glTF file
  90290. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  90291. * @returns json data as string
  90292. */
  90293. private generateJSON;
  90294. /**
  90295. * Generates data for .gltf and .bin files based on the glTF prefix string
  90296. * @param glTFPrefix Text to use when prefixing a glTF file
  90297. * @param dispose Dispose the exporter
  90298. * @returns GLTFData with glTF file data
  90299. */
  90300. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90301. /**
  90302. * Creates a binary buffer for glTF
  90303. * @returns array buffer for binary data
  90304. */
  90305. private _generateBinaryAsync;
  90306. /**
  90307. * Pads the number to a multiple of 4
  90308. * @param num number to pad
  90309. * @returns padded number
  90310. */
  90311. private _getPadding;
  90312. /**
  90313. * @hidden
  90314. */
  90315. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  90316. /**
  90317. * Sets the TRS for each node
  90318. * @param node glTF Node for storing the transformation data
  90319. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  90320. * @param convertToRightHandedSystem Converts the values to right-handed
  90321. */
  90322. private setNodeTransformation;
  90323. private getVertexBufferFromMesh;
  90324. /**
  90325. * Creates a bufferview based on the vertices type for the Babylon mesh
  90326. * @param kind Indicates the type of vertices data
  90327. * @param componentType Indicates the numerical type used to store the data
  90328. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  90329. * @param binaryWriter The buffer to write the bufferview data to
  90330. * @param convertToRightHandedSystem Converts the values to right-handed
  90331. */
  90332. private createBufferViewKind;
  90333. /**
  90334. * Creates a bufferview based on the vertices type for the Babylon mesh
  90335. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  90336. * @param babylonMorphTarget the morph target to be exported
  90337. * @param binaryWriter The buffer to write the bufferview data to
  90338. * @param convertToRightHandedSystem Converts the values to right-handed
  90339. */
  90340. private setMorphTargetAttributes;
  90341. /**
  90342. * The primitive mode of the Babylon mesh
  90343. * @param babylonMesh The BabylonJS mesh
  90344. */
  90345. private getMeshPrimitiveMode;
  90346. /**
  90347. * Sets the primitive mode of the glTF mesh primitive
  90348. * @param meshPrimitive glTF mesh primitive
  90349. * @param primitiveMode The primitive mode
  90350. */
  90351. private setPrimitiveMode;
  90352. /**
  90353. * Sets the vertex attribute accessor based of the glTF mesh primitive
  90354. * @param meshPrimitive glTF mesh primitive
  90355. * @param attributeKind vertex attribute
  90356. * @returns boolean specifying if uv coordinates are present
  90357. */
  90358. private setAttributeKind;
  90359. /**
  90360. * Sets data for the primitive attributes of each submesh
  90361. * @param mesh glTF Mesh object to store the primitive attribute information
  90362. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  90363. * @param binaryWriter Buffer to write the attribute data to
  90364. * @param convertToRightHandedSystem Converts the values to right-handed
  90365. */
  90366. private setPrimitiveAttributesAsync;
  90367. /**
  90368. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  90369. * @param node The node to check
  90370. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  90371. */
  90372. private isBabylonCoordinateSystemConvertingNode;
  90373. /**
  90374. * Creates a glTF scene based on the array of meshes
  90375. * Returns the the total byte offset
  90376. * @param babylonScene Babylon scene to get the mesh data from
  90377. * @param binaryWriter Buffer to write binary data to
  90378. */
  90379. private createSceneAsync;
  90380. /**
  90381. * Creates a mapping of Node unique id to node index and handles animations
  90382. * @param babylonScene Babylon Scene
  90383. * @param nodes Babylon transform nodes
  90384. * @param binaryWriter Buffer to write binary data to
  90385. * @returns Node mapping of unique id to index
  90386. */
  90387. private createNodeMapAndAnimationsAsync;
  90388. /**
  90389. * Creates a glTF node from a Babylon mesh
  90390. * @param babylonMesh Source Babylon mesh
  90391. * @param binaryWriter Buffer for storing geometry data
  90392. * @param convertToRightHandedSystem Converts the values to right-handed
  90393. * @param nodeMap Node mapping of unique id to glTF node index
  90394. * @returns glTF node
  90395. */
  90396. private createNodeAsync;
  90397. /**
  90398. * Creates a glTF skin from a Babylon skeleton
  90399. * @param babylonScene Babylon Scene
  90400. * @param nodes Babylon transform nodes
  90401. * @param binaryWriter Buffer to write binary data to
  90402. * @returns Node mapping of unique id to index
  90403. */
  90404. private createSkinsAsync;
  90405. }
  90406. /**
  90407. * @hidden
  90408. *
  90409. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  90410. */
  90411. export class _BinaryWriter {
  90412. /**
  90413. * Array buffer which stores all binary data
  90414. */
  90415. private _arrayBuffer;
  90416. /**
  90417. * View of the array buffer
  90418. */
  90419. private _dataView;
  90420. /**
  90421. * byte offset of data in array buffer
  90422. */
  90423. private _byteOffset;
  90424. /**
  90425. * Initialize binary writer with an initial byte length
  90426. * @param byteLength Initial byte length of the array buffer
  90427. */
  90428. constructor(byteLength: number);
  90429. /**
  90430. * Resize the array buffer to the specified byte length
  90431. * @param byteLength
  90432. */
  90433. private resizeBuffer;
  90434. /**
  90435. * Get an array buffer with the length of the byte offset
  90436. * @returns ArrayBuffer resized to the byte offset
  90437. */
  90438. getArrayBuffer(): ArrayBuffer;
  90439. /**
  90440. * Get the byte offset of the array buffer
  90441. * @returns byte offset
  90442. */
  90443. getByteOffset(): number;
  90444. /**
  90445. * Stores an UInt8 in the array buffer
  90446. * @param entry
  90447. * @param byteOffset If defined, specifies where to set the value as an offset.
  90448. */
  90449. setUInt8(entry: number, byteOffset?: number): void;
  90450. /**
  90451. * Stores an UInt16 in the array buffer
  90452. * @param entry
  90453. * @param byteOffset If defined, specifies where to set the value as an offset.
  90454. */
  90455. setUInt16(entry: number, byteOffset?: number): void;
  90456. /**
  90457. * Gets an UInt32 in the array buffer
  90458. * @param entry
  90459. * @param byteOffset If defined, specifies where to set the value as an offset.
  90460. */
  90461. getUInt32(byteOffset: number): number;
  90462. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90463. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  90464. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90465. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  90466. /**
  90467. * Stores a Float32 in the array buffer
  90468. * @param entry
  90469. */
  90470. setFloat32(entry: number, byteOffset?: number): void;
  90471. /**
  90472. * Stores an UInt32 in the array buffer
  90473. * @param entry
  90474. * @param byteOffset If defined, specifies where to set the value as an offset.
  90475. */
  90476. setUInt32(entry: number, byteOffset?: number): void;
  90477. }
  90478. }
  90479. declare module BABYLON.GLTF2.Exporter {
  90480. /**
  90481. * @hidden
  90482. * Interface to store animation data.
  90483. */
  90484. export interface _IAnimationData {
  90485. /**
  90486. * Keyframe data.
  90487. */
  90488. inputs: number[];
  90489. /**
  90490. * Value data.
  90491. */
  90492. outputs: number[][];
  90493. /**
  90494. * Animation interpolation data.
  90495. */
  90496. samplerInterpolation: AnimationSamplerInterpolation;
  90497. /**
  90498. * Minimum keyframe value.
  90499. */
  90500. inputsMin: number;
  90501. /**
  90502. * Maximum keyframe value.
  90503. */
  90504. inputsMax: number;
  90505. }
  90506. /**
  90507. * @hidden
  90508. */
  90509. export interface _IAnimationInfo {
  90510. /**
  90511. * The target channel for the animation
  90512. */
  90513. animationChannelTargetPath: AnimationChannelTargetPath;
  90514. /**
  90515. * The glTF accessor type for the data.
  90516. */
  90517. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  90518. /**
  90519. * Specifies if quaternions should be used.
  90520. */
  90521. useQuaternion: boolean;
  90522. }
  90523. /**
  90524. * @hidden
  90525. * Utility class for generating glTF animation data from BabylonJS.
  90526. */
  90527. export class _GLTFAnimation {
  90528. /**
  90529. * @ignore
  90530. *
  90531. * Creates glTF channel animation from BabylonJS animation.
  90532. * @param babylonTransformNode - BabylonJS mesh.
  90533. * @param animation - animation.
  90534. * @param animationChannelTargetPath - The target animation channel.
  90535. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  90536. * @param useQuaternion - Specifies if quaternions are used.
  90537. * @returns nullable IAnimationData
  90538. */
  90539. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  90540. private static _DeduceAnimationInfo;
  90541. /**
  90542. * @ignore
  90543. * Create node animations from the transform node animations
  90544. * @param babylonNode
  90545. * @param runtimeGLTFAnimation
  90546. * @param idleGLTFAnimations
  90547. * @param nodeMap
  90548. * @param nodes
  90549. * @param binaryWriter
  90550. * @param bufferViews
  90551. * @param accessors
  90552. * @param convertToRightHandedSystem
  90553. * @param animationSampleRate
  90554. */
  90555. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90556. [key: number]: number;
  90557. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90558. /**
  90559. * @ignore
  90560. * Create individual morph animations from the mesh's morph target animation tracks
  90561. * @param babylonNode
  90562. * @param runtimeGLTFAnimation
  90563. * @param idleGLTFAnimations
  90564. * @param nodeMap
  90565. * @param nodes
  90566. * @param binaryWriter
  90567. * @param bufferViews
  90568. * @param accessors
  90569. * @param convertToRightHandedSystem
  90570. * @param animationSampleRate
  90571. */
  90572. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  90573. [key: number]: number;
  90574. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  90575. /**
  90576. * @ignore
  90577. * Create node and morph animations from the animation groups
  90578. * @param babylonScene
  90579. * @param glTFAnimations
  90580. * @param nodeMap
  90581. * @param nodes
  90582. * @param binaryWriter
  90583. * @param bufferViews
  90584. * @param accessors
  90585. * @param convertToRightHandedSystemMap
  90586. * @param animationSampleRate
  90587. */
  90588. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  90589. [key: number]: number;
  90590. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  90591. [nodeId: number]: boolean;
  90592. }, animationSampleRate: number): void;
  90593. private static AddAnimation;
  90594. /**
  90595. * Create a baked animation
  90596. * @param babylonTransformNode BabylonJS mesh
  90597. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  90598. * @param animationChannelTargetPath animation target channel
  90599. * @param minFrame minimum animation frame
  90600. * @param maxFrame maximum animation frame
  90601. * @param fps frames per second of the animation
  90602. * @param inputs input key frames of the animation
  90603. * @param outputs output key frame data of the animation
  90604. * @param convertToRightHandedSystem converts the values to right-handed
  90605. * @param useQuaternion specifies if quaternions should be used
  90606. */
  90607. private static _CreateBakedAnimation;
  90608. private static _ConvertFactorToVector3OrQuaternion;
  90609. private static _SetInterpolatedValue;
  90610. /**
  90611. * Creates linear animation from the animation key frames
  90612. * @param babylonTransformNode BabylonJS mesh
  90613. * @param animation BabylonJS animation
  90614. * @param animationChannelTargetPath The target animation channel
  90615. * @param frameDelta The difference between the last and first frame of the animation
  90616. * @param inputs Array to store the key frame times
  90617. * @param outputs Array to store the key frame data
  90618. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90619. * @param useQuaternion Specifies if quaternions are used in the animation
  90620. */
  90621. private static _CreateLinearOrStepAnimation;
  90622. /**
  90623. * Creates cubic spline animation from the animation key frames
  90624. * @param babylonTransformNode BabylonJS mesh
  90625. * @param animation BabylonJS animation
  90626. * @param animationChannelTargetPath The target animation channel
  90627. * @param frameDelta The difference between the last and first frame of the animation
  90628. * @param inputs Array to store the key frame times
  90629. * @param outputs Array to store the key frame data
  90630. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  90631. * @param useQuaternion Specifies if quaternions are used in the animation
  90632. */
  90633. private static _CreateCubicSplineAnimation;
  90634. private static _GetBasePositionRotationOrScale;
  90635. /**
  90636. * Adds a key frame value
  90637. * @param keyFrame
  90638. * @param animation
  90639. * @param outputs
  90640. * @param animationChannelTargetPath
  90641. * @param basePositionRotationOrScale
  90642. * @param convertToRightHandedSystem
  90643. * @param useQuaternion
  90644. */
  90645. private static _AddKeyframeValue;
  90646. /**
  90647. * Determine the interpolation based on the key frames
  90648. * @param keyFrames
  90649. * @param animationChannelTargetPath
  90650. * @param useQuaternion
  90651. */
  90652. private static _DeduceInterpolation;
  90653. /**
  90654. * Adds an input tangent or output tangent to the output data
  90655. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  90656. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  90657. * @param outputs The animation data by keyframe
  90658. * @param animationChannelTargetPath The target animation channel
  90659. * @param interpolation The interpolation type
  90660. * @param keyFrame The key frame with the animation data
  90661. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  90662. * @param useQuaternion Specifies if quaternions are used
  90663. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  90664. */
  90665. private static AddSplineTangent;
  90666. /**
  90667. * Get the minimum and maximum key frames' frame values
  90668. * @param keyFrames animation key frames
  90669. * @returns the minimum and maximum key frame value
  90670. */
  90671. private static calculateMinMaxKeyFrames;
  90672. }
  90673. }
  90674. declare module BABYLON.GLTF2.Exporter {
  90675. /** @hidden */
  90676. export var textureTransformPixelShader: {
  90677. name: string;
  90678. shader: string;
  90679. };
  90680. }
  90681. declare module BABYLON.GLTF2.Exporter.Extensions {
  90682. /**
  90683. * @hidden
  90684. */
  90685. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  90686. private _recordedTextures;
  90687. /** Name of this extension */
  90688. readonly name: string;
  90689. /** Defines whether this extension is enabled */
  90690. enabled: boolean;
  90691. /** Defines whether this extension is required */
  90692. required: boolean;
  90693. /** Reference to the glTF exporter */
  90694. private _wasUsed;
  90695. constructor(exporter: _Exporter);
  90696. dispose(): void;
  90697. /** @hidden */
  90698. get wasUsed(): boolean;
  90699. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90700. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  90701. /**
  90702. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  90703. * @param babylonTexture
  90704. * @param offset
  90705. * @param rotation
  90706. * @param scale
  90707. * @param scene
  90708. */
  90709. private _textureTransformTextureAsync;
  90710. }
  90711. }
  90712. declare module BABYLON.GLTF2.Exporter.Extensions {
  90713. /**
  90714. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90715. */
  90716. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90717. /** The name of this extension. */
  90718. readonly name: string;
  90719. /** Defines whether this extension is enabled. */
  90720. enabled: boolean;
  90721. /** Defines whether this extension is required */
  90722. required: boolean;
  90723. /** Reference to the glTF exporter */
  90724. private _exporter;
  90725. private _lights;
  90726. /** @hidden */
  90727. constructor(exporter: _Exporter);
  90728. /** @hidden */
  90729. dispose(): void;
  90730. /** @hidden */
  90731. get wasUsed(): boolean;
  90732. /** @hidden */
  90733. onExporting(): void;
  90734. /**
  90735. * Define this method to modify the default behavior when exporting a node
  90736. * @param context The context when exporting the node
  90737. * @param node glTF node
  90738. * @param babylonNode BabylonJS node
  90739. * @param nodeMap Node mapping of unique id to glTF node index
  90740. * @returns nullable INode promise
  90741. */
  90742. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90743. [key: number]: number;
  90744. }): Promise<Nullable<INode>>;
  90745. }
  90746. }
  90747. declare module BABYLON.GLTF2.Exporter.Extensions {
  90748. /**
  90749. * @hidden
  90750. */
  90751. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90752. /** Name of this extension */
  90753. readonly name: string;
  90754. /** Defines whether this extension is enabled */
  90755. enabled: boolean;
  90756. /** Defines whether this extension is required */
  90757. required: boolean;
  90758. /** Reference to the glTF exporter */
  90759. private _textureInfos;
  90760. private _exportedTextures;
  90761. private _wasUsed;
  90762. constructor(exporter: _Exporter);
  90763. dispose(): void;
  90764. /** @hidden */
  90765. get wasUsed(): boolean;
  90766. private _getTextureIndex;
  90767. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90768. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90769. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90770. }
  90771. }
  90772. declare module BABYLON.GLTF2.Exporter.Extensions {
  90773. /**
  90774. * @hidden
  90775. */
  90776. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90777. /** Name of this extension */
  90778. readonly name: string;
  90779. /** Defines whether this extension is enabled */
  90780. enabled: boolean;
  90781. /** Defines whether this extension is required */
  90782. required: boolean;
  90783. private _wasUsed;
  90784. constructor(exporter: _Exporter);
  90785. /** @hidden */
  90786. get wasUsed(): boolean;
  90787. dispose(): void;
  90788. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90789. }
  90790. }
  90791. declare module BABYLON {
  90792. /**
  90793. * Class for generating STL data from a Babylon scene.
  90794. */
  90795. export class STLExport {
  90796. /**
  90797. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90798. * @param meshes list defines the mesh to serialize
  90799. * @param download triggers the automatic download of the file.
  90800. * @param fileName changes the downloads fileName.
  90801. * @param binary changes the STL to a binary type.
  90802. * @param isLittleEndian toggle for binary type exporter.
  90803. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90804. * @returns the STL as UTF8 string
  90805. */
  90806. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90807. }
  90808. }
  90809. declare module "babylonjs-gltf2interface" {
  90810. export = BABYLON.GLTF2;
  90811. }
  90812. /**
  90813. * Module for glTF 2.0 Interface
  90814. */
  90815. declare module BABYLON.GLTF2 {
  90816. /**
  90817. * The datatype of the components in the attribute
  90818. */
  90819. const enum AccessorComponentType {
  90820. /**
  90821. * Byte
  90822. */
  90823. BYTE = 5120,
  90824. /**
  90825. * Unsigned Byte
  90826. */
  90827. UNSIGNED_BYTE = 5121,
  90828. /**
  90829. * Short
  90830. */
  90831. SHORT = 5122,
  90832. /**
  90833. * Unsigned Short
  90834. */
  90835. UNSIGNED_SHORT = 5123,
  90836. /**
  90837. * Unsigned Int
  90838. */
  90839. UNSIGNED_INT = 5125,
  90840. /**
  90841. * Float
  90842. */
  90843. FLOAT = 5126,
  90844. }
  90845. /**
  90846. * Specifies if the attirbute is a scalar, vector, or matrix
  90847. */
  90848. const enum AccessorType {
  90849. /**
  90850. * Scalar
  90851. */
  90852. SCALAR = "SCALAR",
  90853. /**
  90854. * Vector2
  90855. */
  90856. VEC2 = "VEC2",
  90857. /**
  90858. * Vector3
  90859. */
  90860. VEC3 = "VEC3",
  90861. /**
  90862. * Vector4
  90863. */
  90864. VEC4 = "VEC4",
  90865. /**
  90866. * Matrix2x2
  90867. */
  90868. MAT2 = "MAT2",
  90869. /**
  90870. * Matrix3x3
  90871. */
  90872. MAT3 = "MAT3",
  90873. /**
  90874. * Matrix4x4
  90875. */
  90876. MAT4 = "MAT4",
  90877. }
  90878. /**
  90879. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90880. */
  90881. const enum AnimationChannelTargetPath {
  90882. /**
  90883. * Translation
  90884. */
  90885. TRANSLATION = "translation",
  90886. /**
  90887. * Rotation
  90888. */
  90889. ROTATION = "rotation",
  90890. /**
  90891. * Scale
  90892. */
  90893. SCALE = "scale",
  90894. /**
  90895. * Weights
  90896. */
  90897. WEIGHTS = "weights",
  90898. }
  90899. /**
  90900. * Interpolation algorithm
  90901. */
  90902. const enum AnimationSamplerInterpolation {
  90903. /**
  90904. * The animated values are linearly interpolated between keyframes
  90905. */
  90906. LINEAR = "LINEAR",
  90907. /**
  90908. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90909. */
  90910. STEP = "STEP",
  90911. /**
  90912. * The animation's interpolation is computed using a cubic spline with specified tangents
  90913. */
  90914. CUBICSPLINE = "CUBICSPLINE",
  90915. }
  90916. /**
  90917. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90918. */
  90919. const enum CameraType {
  90920. /**
  90921. * A perspective camera containing properties to create a perspective projection matrix
  90922. */
  90923. PERSPECTIVE = "perspective",
  90924. /**
  90925. * An orthographic camera containing properties to create an orthographic projection matrix
  90926. */
  90927. ORTHOGRAPHIC = "orthographic",
  90928. }
  90929. /**
  90930. * The mime-type of the image
  90931. */
  90932. const enum ImageMimeType {
  90933. /**
  90934. * JPEG Mime-type
  90935. */
  90936. JPEG = "image/jpeg",
  90937. /**
  90938. * PNG Mime-type
  90939. */
  90940. PNG = "image/png",
  90941. }
  90942. /**
  90943. * The alpha rendering mode of the material
  90944. */
  90945. const enum MaterialAlphaMode {
  90946. /**
  90947. * The alpha value is ignored and the rendered output is fully opaque
  90948. */
  90949. OPAQUE = "OPAQUE",
  90950. /**
  90951. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90952. */
  90953. MASK = "MASK",
  90954. /**
  90955. * 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)
  90956. */
  90957. BLEND = "BLEND",
  90958. }
  90959. /**
  90960. * The type of the primitives to render
  90961. */
  90962. const enum MeshPrimitiveMode {
  90963. /**
  90964. * Points
  90965. */
  90966. POINTS = 0,
  90967. /**
  90968. * Lines
  90969. */
  90970. LINES = 1,
  90971. /**
  90972. * Line Loop
  90973. */
  90974. LINE_LOOP = 2,
  90975. /**
  90976. * Line Strip
  90977. */
  90978. LINE_STRIP = 3,
  90979. /**
  90980. * Triangles
  90981. */
  90982. TRIANGLES = 4,
  90983. /**
  90984. * Triangle Strip
  90985. */
  90986. TRIANGLE_STRIP = 5,
  90987. /**
  90988. * Triangle Fan
  90989. */
  90990. TRIANGLE_FAN = 6,
  90991. }
  90992. /**
  90993. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90994. */
  90995. const enum TextureMagFilter {
  90996. /**
  90997. * Nearest
  90998. */
  90999. NEAREST = 9728,
  91000. /**
  91001. * Linear
  91002. */
  91003. LINEAR = 9729,
  91004. }
  91005. /**
  91006. * Minification filter. All valid values correspond to WebGL enums
  91007. */
  91008. const enum TextureMinFilter {
  91009. /**
  91010. * Nearest
  91011. */
  91012. NEAREST = 9728,
  91013. /**
  91014. * Linear
  91015. */
  91016. LINEAR = 9729,
  91017. /**
  91018. * Nearest Mip-Map Nearest
  91019. */
  91020. NEAREST_MIPMAP_NEAREST = 9984,
  91021. /**
  91022. * Linear Mipmap Nearest
  91023. */
  91024. LINEAR_MIPMAP_NEAREST = 9985,
  91025. /**
  91026. * Nearest Mipmap Linear
  91027. */
  91028. NEAREST_MIPMAP_LINEAR = 9986,
  91029. /**
  91030. * Linear Mipmap Linear
  91031. */
  91032. LINEAR_MIPMAP_LINEAR = 9987,
  91033. }
  91034. /**
  91035. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91036. */
  91037. const enum TextureWrapMode {
  91038. /**
  91039. * Clamp to Edge
  91040. */
  91041. CLAMP_TO_EDGE = 33071,
  91042. /**
  91043. * Mirrored Repeat
  91044. */
  91045. MIRRORED_REPEAT = 33648,
  91046. /**
  91047. * Repeat
  91048. */
  91049. REPEAT = 10497,
  91050. }
  91051. /**
  91052. * glTF Property
  91053. */
  91054. interface IProperty {
  91055. /**
  91056. * Dictionary object with extension-specific objects
  91057. */
  91058. extensions?: {
  91059. [key: string]: any;
  91060. };
  91061. /**
  91062. * Application-Specific data
  91063. */
  91064. extras?: any;
  91065. }
  91066. /**
  91067. * glTF Child of Root Property
  91068. */
  91069. interface IChildRootProperty extends IProperty {
  91070. /**
  91071. * The user-defined name of this object
  91072. */
  91073. name?: string;
  91074. }
  91075. /**
  91076. * Indices of those attributes that deviate from their initialization value
  91077. */
  91078. interface IAccessorSparseIndices extends IProperty {
  91079. /**
  91080. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91081. */
  91082. bufferView: number;
  91083. /**
  91084. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91085. */
  91086. byteOffset?: number;
  91087. /**
  91088. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  91089. */
  91090. componentType: AccessorComponentType;
  91091. }
  91092. /**
  91093. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  91094. */
  91095. interface IAccessorSparseValues extends IProperty {
  91096. /**
  91097. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  91098. */
  91099. bufferView: number;
  91100. /**
  91101. * The offset relative to the start of the bufferView in bytes. Must be aligned
  91102. */
  91103. byteOffset?: number;
  91104. }
  91105. /**
  91106. * Sparse storage of attributes that deviate from their initialization value
  91107. */
  91108. interface IAccessorSparse extends IProperty {
  91109. /**
  91110. * The number of attributes encoded in this sparse accessor
  91111. */
  91112. count: number;
  91113. /**
  91114. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  91115. */
  91116. indices: IAccessorSparseIndices;
  91117. /**
  91118. * 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
  91119. */
  91120. values: IAccessorSparseValues;
  91121. }
  91122. /**
  91123. * 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
  91124. */
  91125. interface IAccessor extends IChildRootProperty {
  91126. /**
  91127. * The index of the bufferview
  91128. */
  91129. bufferView?: number;
  91130. /**
  91131. * The offset relative to the start of the bufferView in bytes
  91132. */
  91133. byteOffset?: number;
  91134. /**
  91135. * The datatype of components in the attribute
  91136. */
  91137. componentType: AccessorComponentType;
  91138. /**
  91139. * Specifies whether integer data values should be normalized
  91140. */
  91141. normalized?: boolean;
  91142. /**
  91143. * The number of attributes referenced by this accessor
  91144. */
  91145. count: number;
  91146. /**
  91147. * Specifies if the attribute is a scalar, vector, or matrix
  91148. */
  91149. type: AccessorType;
  91150. /**
  91151. * Maximum value of each component in this attribute
  91152. */
  91153. max?: number[];
  91154. /**
  91155. * Minimum value of each component in this attribute
  91156. */
  91157. min?: number[];
  91158. /**
  91159. * Sparse storage of attributes that deviate from their initialization value
  91160. */
  91161. sparse?: IAccessorSparse;
  91162. }
  91163. /**
  91164. * Targets an animation's sampler at a node's property
  91165. */
  91166. interface IAnimationChannel extends IProperty {
  91167. /**
  91168. * The index of a sampler in this animation used to compute the value for the target
  91169. */
  91170. sampler: number;
  91171. /**
  91172. * The index of the node and TRS property to target
  91173. */
  91174. target: IAnimationChannelTarget;
  91175. }
  91176. /**
  91177. * The index of the node and TRS property that an animation channel targets
  91178. */
  91179. interface IAnimationChannelTarget extends IProperty {
  91180. /**
  91181. * The index of the node to target
  91182. */
  91183. node: number;
  91184. /**
  91185. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  91186. */
  91187. path: AnimationChannelTargetPath;
  91188. }
  91189. /**
  91190. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91191. */
  91192. interface IAnimationSampler extends IProperty {
  91193. /**
  91194. * The index of an accessor containing keyframe input values, e.g., time
  91195. */
  91196. input: number;
  91197. /**
  91198. * Interpolation algorithm
  91199. */
  91200. interpolation?: AnimationSamplerInterpolation;
  91201. /**
  91202. * The index of an accessor, containing keyframe output values
  91203. */
  91204. output: number;
  91205. }
  91206. /**
  91207. * A keyframe animation
  91208. */
  91209. interface IAnimation extends IChildRootProperty {
  91210. /**
  91211. * An array of channels, each of which targets an animation's sampler at a node's property
  91212. */
  91213. channels: IAnimationChannel[];
  91214. /**
  91215. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  91216. */
  91217. samplers: IAnimationSampler[];
  91218. }
  91219. /**
  91220. * Metadata about the glTF asset
  91221. */
  91222. interface IAsset extends IChildRootProperty {
  91223. /**
  91224. * A copyright message suitable for display to credit the content creator
  91225. */
  91226. copyright?: string;
  91227. /**
  91228. * Tool that generated this glTF model. Useful for debugging
  91229. */
  91230. generator?: string;
  91231. /**
  91232. * The glTF version that this asset targets
  91233. */
  91234. version: string;
  91235. /**
  91236. * The minimum glTF version that this asset targets
  91237. */
  91238. minVersion?: string;
  91239. }
  91240. /**
  91241. * A buffer points to binary geometry, animation, or skins
  91242. */
  91243. interface IBuffer extends IChildRootProperty {
  91244. /**
  91245. * 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
  91246. */
  91247. uri?: string;
  91248. /**
  91249. * The length of the buffer in bytes
  91250. */
  91251. byteLength: number;
  91252. }
  91253. /**
  91254. * A view into a buffer generally representing a subset of the buffer
  91255. */
  91256. interface IBufferView extends IChildRootProperty {
  91257. /**
  91258. * The index of the buffer
  91259. */
  91260. buffer: number;
  91261. /**
  91262. * The offset into the buffer in bytes
  91263. */
  91264. byteOffset?: number;
  91265. /**
  91266. * The lenth of the bufferView in bytes
  91267. */
  91268. byteLength: number;
  91269. /**
  91270. * The stride, in bytes
  91271. */
  91272. byteStride?: number;
  91273. }
  91274. /**
  91275. * An orthographic camera containing properties to create an orthographic projection matrix
  91276. */
  91277. interface ICameraOrthographic extends IProperty {
  91278. /**
  91279. * The floating-point horizontal magnification of the view. Must not be zero
  91280. */
  91281. xmag: number;
  91282. /**
  91283. * The floating-point vertical magnification of the view. Must not be zero
  91284. */
  91285. ymag: number;
  91286. /**
  91287. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  91288. */
  91289. zfar: number;
  91290. /**
  91291. * The floating-point distance to the near clipping plane
  91292. */
  91293. znear: number;
  91294. }
  91295. /**
  91296. * A perspective camera containing properties to create a perspective projection matrix
  91297. */
  91298. interface ICameraPerspective extends IProperty {
  91299. /**
  91300. * The floating-point aspect ratio of the field of view
  91301. */
  91302. aspectRatio?: number;
  91303. /**
  91304. * The floating-point vertical field of view in radians
  91305. */
  91306. yfov: number;
  91307. /**
  91308. * The floating-point distance to the far clipping plane
  91309. */
  91310. zfar?: number;
  91311. /**
  91312. * The floating-point distance to the near clipping plane
  91313. */
  91314. znear: number;
  91315. }
  91316. /**
  91317. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  91318. */
  91319. interface ICamera extends IChildRootProperty {
  91320. /**
  91321. * An orthographic camera containing properties to create an orthographic projection matrix
  91322. */
  91323. orthographic?: ICameraOrthographic;
  91324. /**
  91325. * A perspective camera containing properties to create a perspective projection matrix
  91326. */
  91327. perspective?: ICameraPerspective;
  91328. /**
  91329. * Specifies if the camera uses a perspective or orthographic projection
  91330. */
  91331. type: CameraType;
  91332. }
  91333. /**
  91334. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  91335. */
  91336. interface IImage extends IChildRootProperty {
  91337. /**
  91338. * 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
  91339. */
  91340. uri?: string;
  91341. /**
  91342. * The image's MIME type
  91343. */
  91344. mimeType?: ImageMimeType;
  91345. /**
  91346. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  91347. */
  91348. bufferView?: number;
  91349. }
  91350. /**
  91351. * Material Normal Texture Info
  91352. */
  91353. interface IMaterialNormalTextureInfo extends ITextureInfo {
  91354. /**
  91355. * The scalar multiplier applied to each normal vector of the normal texture
  91356. */
  91357. scale?: number;
  91358. }
  91359. /**
  91360. * Material Occlusion Texture Info
  91361. */
  91362. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  91363. /**
  91364. * A scalar multiplier controlling the amount of occlusion applied
  91365. */
  91366. strength?: number;
  91367. }
  91368. /**
  91369. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  91370. */
  91371. interface IMaterialPbrMetallicRoughness {
  91372. /**
  91373. * The material's base color factor
  91374. */
  91375. baseColorFactor?: number[];
  91376. /**
  91377. * The base color texture
  91378. */
  91379. baseColorTexture?: ITextureInfo;
  91380. /**
  91381. * The metalness of the material
  91382. */
  91383. metallicFactor?: number;
  91384. /**
  91385. * The roughness of the material
  91386. */
  91387. roughnessFactor?: number;
  91388. /**
  91389. * The metallic-roughness texture
  91390. */
  91391. metallicRoughnessTexture?: ITextureInfo;
  91392. }
  91393. /**
  91394. * The material appearance of a primitive
  91395. */
  91396. interface IMaterial extends IChildRootProperty {
  91397. /**
  91398. * 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
  91399. */
  91400. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  91401. /**
  91402. * The normal map texture
  91403. */
  91404. normalTexture?: IMaterialNormalTextureInfo;
  91405. /**
  91406. * The occlusion map texture
  91407. */
  91408. occlusionTexture?: IMaterialOcclusionTextureInfo;
  91409. /**
  91410. * The emissive map texture
  91411. */
  91412. emissiveTexture?: ITextureInfo;
  91413. /**
  91414. * 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
  91415. */
  91416. emissiveFactor?: number[];
  91417. /**
  91418. * The alpha rendering mode of the material
  91419. */
  91420. alphaMode?: MaterialAlphaMode;
  91421. /**
  91422. * The alpha cutoff value of the material
  91423. */
  91424. alphaCutoff?: number;
  91425. /**
  91426. * Specifies whether the material is double sided
  91427. */
  91428. doubleSided?: boolean;
  91429. }
  91430. /**
  91431. * Geometry to be rendered with the given material
  91432. */
  91433. interface IMeshPrimitive extends IProperty {
  91434. /**
  91435. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  91436. */
  91437. attributes: {
  91438. [name: string]: number;
  91439. };
  91440. /**
  91441. * The index of the accessor that contains the indices
  91442. */
  91443. indices?: number;
  91444. /**
  91445. * The index of the material to apply to this primitive when rendering
  91446. */
  91447. material?: number;
  91448. /**
  91449. * The type of primitives to render. All valid values correspond to WebGL enums
  91450. */
  91451. mode?: MeshPrimitiveMode;
  91452. /**
  91453. * 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
  91454. */
  91455. targets?: {
  91456. [name: string]: number;
  91457. }[];
  91458. }
  91459. /**
  91460. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  91461. */
  91462. interface IMesh extends IChildRootProperty {
  91463. /**
  91464. * An array of primitives, each defining geometry to be rendered with a material
  91465. */
  91466. primitives: IMeshPrimitive[];
  91467. /**
  91468. * Array of weights to be applied to the Morph Targets
  91469. */
  91470. weights?: number[];
  91471. }
  91472. /**
  91473. * A node in the node hierarchy
  91474. */
  91475. interface INode extends IChildRootProperty {
  91476. /**
  91477. * The index of the camera referenced by this node
  91478. */
  91479. camera?: number;
  91480. /**
  91481. * The indices of this node's children
  91482. */
  91483. children?: number[];
  91484. /**
  91485. * The index of the skin referenced by this node
  91486. */
  91487. skin?: number;
  91488. /**
  91489. * A floating-point 4x4 transformation matrix stored in column-major order
  91490. */
  91491. matrix?: number[];
  91492. /**
  91493. * The index of the mesh in this node
  91494. */
  91495. mesh?: number;
  91496. /**
  91497. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  91498. */
  91499. rotation?: number[];
  91500. /**
  91501. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  91502. */
  91503. scale?: number[];
  91504. /**
  91505. * The node's translation along the x, y, and z axes
  91506. */
  91507. translation?: number[];
  91508. /**
  91509. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  91510. */
  91511. weights?: number[];
  91512. }
  91513. /**
  91514. * Texture sampler properties for filtering and wrapping modes
  91515. */
  91516. interface ISampler extends IChildRootProperty {
  91517. /**
  91518. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  91519. */
  91520. magFilter?: TextureMagFilter;
  91521. /**
  91522. * Minification filter. All valid values correspond to WebGL enums
  91523. */
  91524. minFilter?: TextureMinFilter;
  91525. /**
  91526. * S (U) wrapping mode. All valid values correspond to WebGL enums
  91527. */
  91528. wrapS?: TextureWrapMode;
  91529. /**
  91530. * T (V) wrapping mode. All valid values correspond to WebGL enums
  91531. */
  91532. wrapT?: TextureWrapMode;
  91533. }
  91534. /**
  91535. * The root nodes of a scene
  91536. */
  91537. interface IScene extends IChildRootProperty {
  91538. /**
  91539. * The indices of each root node
  91540. */
  91541. nodes: number[];
  91542. }
  91543. /**
  91544. * Joints and matrices defining a skin
  91545. */
  91546. interface ISkin extends IChildRootProperty {
  91547. /**
  91548. * 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
  91549. */
  91550. inverseBindMatrices?: number;
  91551. /**
  91552. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  91553. */
  91554. skeleton?: number;
  91555. /**
  91556. * 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)
  91557. */
  91558. joints: number[];
  91559. }
  91560. /**
  91561. * A texture and its sampler
  91562. */
  91563. interface ITexture extends IChildRootProperty {
  91564. /**
  91565. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  91566. */
  91567. sampler?: number;
  91568. /**
  91569. * The index of the image used by this texture
  91570. */
  91571. source: number;
  91572. }
  91573. /**
  91574. * Reference to a texture
  91575. */
  91576. interface ITextureInfo extends IProperty {
  91577. /**
  91578. * The index of the texture
  91579. */
  91580. index: number;
  91581. /**
  91582. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  91583. */
  91584. texCoord?: number;
  91585. }
  91586. /**
  91587. * The root object for a glTF asset
  91588. */
  91589. interface IGLTF extends IProperty {
  91590. /**
  91591. * An array of accessors. An accessor is a typed view into a bufferView
  91592. */
  91593. accessors?: IAccessor[];
  91594. /**
  91595. * An array of keyframe animations
  91596. */
  91597. animations?: IAnimation[];
  91598. /**
  91599. * Metadata about the glTF asset
  91600. */
  91601. asset: IAsset;
  91602. /**
  91603. * An array of buffers. A buffer points to binary geometry, animation, or skins
  91604. */
  91605. buffers?: IBuffer[];
  91606. /**
  91607. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  91608. */
  91609. bufferViews?: IBufferView[];
  91610. /**
  91611. * An array of cameras
  91612. */
  91613. cameras?: ICamera[];
  91614. /**
  91615. * Names of glTF extensions used somewhere in this asset
  91616. */
  91617. extensionsUsed?: string[];
  91618. /**
  91619. * Names of glTF extensions required to properly load this asset
  91620. */
  91621. extensionsRequired?: string[];
  91622. /**
  91623. * An array of images. An image defines data used to create a texture
  91624. */
  91625. images?: IImage[];
  91626. /**
  91627. * An array of materials. A material defines the appearance of a primitive
  91628. */
  91629. materials?: IMaterial[];
  91630. /**
  91631. * An array of meshes. A mesh is a set of primitives to be rendered
  91632. */
  91633. meshes?: IMesh[];
  91634. /**
  91635. * An array of nodes
  91636. */
  91637. nodes?: INode[];
  91638. /**
  91639. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  91640. */
  91641. samplers?: ISampler[];
  91642. /**
  91643. * The index of the default scene
  91644. */
  91645. scene?: number;
  91646. /**
  91647. * An array of scenes
  91648. */
  91649. scenes?: IScene[];
  91650. /**
  91651. * An array of skins. A skin is defined by joints and matrices
  91652. */
  91653. skins?: ISkin[];
  91654. /**
  91655. * An array of textures
  91656. */
  91657. textures?: ITexture[];
  91658. }
  91659. /**
  91660. * The glTF validation results
  91661. * @ignore
  91662. */
  91663. interface IGLTFValidationResults {
  91664. info: {
  91665. generator: string;
  91666. hasAnimations: boolean;
  91667. hasDefaultScene: boolean;
  91668. hasMaterials: boolean;
  91669. hasMorphTargets: boolean;
  91670. hasSkins: boolean;
  91671. hasTextures: boolean;
  91672. maxAttributesUsed: number;
  91673. primitivesCount: number
  91674. };
  91675. issues: {
  91676. messages: Array<string>;
  91677. numErrors: number;
  91678. numHints: number;
  91679. numInfos: number;
  91680. numWarnings: number;
  91681. truncated: boolean
  91682. };
  91683. mimeType: string;
  91684. uri: string;
  91685. validatedAt: string;
  91686. validatorVersion: string;
  91687. }
  91688. /**
  91689. * The glTF validation options
  91690. */
  91691. interface IGLTFValidationOptions {
  91692. /** Uri to use */
  91693. uri?: string;
  91694. /** Function used to load external resources */
  91695. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  91696. /** Boolean indicating that we need to validate accessor data */
  91697. validateAccessorData?: boolean;
  91698. /** max number of issues allowed */
  91699. maxIssues?: number;
  91700. /** Ignored issues */
  91701. ignoredIssues?: Array<string>;
  91702. /** Value to override severy settings */
  91703. severityOverrides?: Object;
  91704. }
  91705. /**
  91706. * The glTF validator object
  91707. * @ignore
  91708. */
  91709. interface IGLTFValidator {
  91710. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91711. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91712. }
  91713. /**
  91714. * Interfaces from the EXT_lights_image_based extension
  91715. */
  91716. /** @hidden */
  91717. interface IEXTLightsImageBased_LightReferenceImageBased {
  91718. light: number;
  91719. }
  91720. /** @hidden */
  91721. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91722. intensity: number;
  91723. rotation: number[];
  91724. specularImageSize: number;
  91725. specularImages: number[][];
  91726. irradianceCoefficients: number[][];
  91727. }
  91728. /** @hidden */
  91729. interface IEXTLightsImageBased {
  91730. lights: IEXTLightsImageBased_LightImageBased[];
  91731. }
  91732. /**
  91733. * Interfaces from the EXT_mesh_gpu_instancing extension
  91734. * !!! Experimental Extension Subject to Changes !!!
  91735. */
  91736. /** @hidden */
  91737. interface IEXTMeshGpuInstancing {
  91738. mesh?: number;
  91739. attributes: { [name: string]: number };
  91740. }
  91741. /**
  91742. * Interfaces from the KHR_draco_mesh_compression extension
  91743. */
  91744. /** @hidden */
  91745. interface IKHRDracoMeshCompression {
  91746. bufferView: number;
  91747. attributes: { [name: string]: number };
  91748. }
  91749. /**
  91750. * Interfaces from the KHR_lights_punctual extension
  91751. */
  91752. /** @hidden */
  91753. const enum IKHRLightsPunctual_LightType {
  91754. DIRECTIONAL = "directional",
  91755. POINT = "point",
  91756. SPOT = "spot"
  91757. }
  91758. /** @hidden */
  91759. interface IKHRLightsPunctual_LightReference {
  91760. light: number;
  91761. }
  91762. /** @hidden */
  91763. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91764. type: IKHRLightsPunctual_LightType;
  91765. color?: number[];
  91766. intensity?: number;
  91767. range?: number;
  91768. spot?: {
  91769. innerConeAngle?: number;
  91770. outerConeAngle?: number;
  91771. };
  91772. }
  91773. /** @hidden */
  91774. interface IKHRLightsPunctual {
  91775. lights: IKHRLightsPunctual_Light[];
  91776. }
  91777. /**
  91778. * Interfaces from the KHR_materials_clearcoat extension
  91779. * !!! Experimental Extension Subject to Changes !!!
  91780. */
  91781. /** @hidden */
  91782. interface IKHRMaterialsClearcoat {
  91783. clearcoatFactor: number;
  91784. clearcoatTexture: ITextureInfo;
  91785. clearcoatRoughnessFactor: number;
  91786. clearcoatRoughnessTexture: ITextureInfo;
  91787. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91788. }
  91789. /**
  91790. * Interfaces from the KHR_materials_ior extension
  91791. * !!! Experimental Extension Subject to Changes !!!
  91792. */
  91793. /** @hidden */
  91794. interface IKHRMaterialsIor {
  91795. ior: number;
  91796. }
  91797. /**
  91798. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91799. */
  91800. /** @hidden */
  91801. interface IKHRMaterialsPbrSpecularGlossiness {
  91802. diffuseFactor: number[];
  91803. diffuseTexture: ITextureInfo;
  91804. specularFactor: number[];
  91805. glossinessFactor: number;
  91806. specularGlossinessTexture: ITextureInfo;
  91807. }
  91808. /**
  91809. * Interfaces from the KHR_materials_sheen extension
  91810. * !!! Experimental Extension Subject to Changes !!!
  91811. */
  91812. /** @hidden */
  91813. interface IKHRMaterialsSheen {
  91814. sheenColorFactor?: number[];
  91815. sheenColorTexture?: ITextureInfo;
  91816. sheenRoughnessFactor?: number;
  91817. sheenRoughnessTexture?: ITextureInfo;
  91818. }
  91819. /**
  91820. * Interfaces from the KHR_materials_specular extension
  91821. * !!! Experimental Extension Subject to Changes !!!
  91822. */
  91823. /** @hidden */
  91824. interface IKHRMaterialsSpecular {
  91825. specularFactor: number;
  91826. specularColorFactor: number[];
  91827. specularTexture: ITextureInfo;
  91828. }
  91829. /**
  91830. * Interfaces from the KHR_materials_transmission extension
  91831. * !!! Experimental Extension Subject to Changes !!!
  91832. */
  91833. /** @hidden */
  91834. interface IKHRMaterialsTransmission {
  91835. transmissionFactor?: number;
  91836. transmissionTexture?: ITextureInfo;
  91837. }
  91838. /**
  91839. * Interfaces from the KHR_materials_translucency extension
  91840. * !!! Experimental Extension Subject to Changes !!!
  91841. */
  91842. /** @hidden */
  91843. interface IKHRMaterialsTranslucency {
  91844. translucencyFactor?: number;
  91845. translucencyTexture?: ITextureInfo;
  91846. }
  91847. /**
  91848. * Interfaces from the KHR_materials_variants extension
  91849. * !!! Experimental Extension Subject to Changes !!!
  91850. */
  91851. /** @hidden */
  91852. interface IKHRMaterialVariants_Mapping extends IProperty {
  91853. mappings: Array<{
  91854. variants: number[];
  91855. material: number;
  91856. }>;
  91857. }
  91858. /** @hidden */
  91859. interface IKHRMaterialVariants_Variant extends IProperty {
  91860. name: string;
  91861. }
  91862. /** @hidden */
  91863. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91864. variants: Array<IKHRMaterialVariants_Variant>;
  91865. }
  91866. /**
  91867. * Interfaces from the KHR_texture_basisu extension
  91868. * !!! Experimental Extension Subject to Changes !!!
  91869. */
  91870. /** @hidden */
  91871. interface IKHRTextureBasisU {
  91872. source: number;
  91873. }
  91874. /**
  91875. * Interfaces from the EXT_texture_webp extension
  91876. */
  91877. /** @hidden */
  91878. interface IEXTTextureWebP {
  91879. source: number;
  91880. }
  91881. /**
  91882. * Interfaces from the KHR_texture_transform extension
  91883. */
  91884. /** @hidden */
  91885. interface IKHRTextureTransform {
  91886. offset?: number[];
  91887. rotation?: number;
  91888. scale?: number[];
  91889. texCoord?: number;
  91890. }
  91891. /**
  91892. * Interfaces from the KHR_xmp_json_ld extension
  91893. * !!! Experimental Extension Subject to Changes !!!
  91894. */
  91895. /** @hidden */
  91896. interface IKHRXmpJsonLd_Gltf {
  91897. packets: Array<{
  91898. [key: string]: unknown;
  91899. }>;
  91900. }
  91901. /** @hidden */
  91902. interface IKHRXmpJsonLd_Node {
  91903. packet: number;
  91904. }
  91905. /**
  91906. * Interfaces from the MSFT_audio_emitter extension
  91907. */
  91908. /** @hidden */
  91909. interface IMSFTAudioEmitter_ClipReference {
  91910. clip: number;
  91911. weight?: number;
  91912. }
  91913. /** @hidden */
  91914. interface IMSFTAudioEmitter_EmittersReference {
  91915. emitters: number[];
  91916. }
  91917. /** @hidden */
  91918. const enum IMSFTAudioEmitter_DistanceModel {
  91919. linear = "linear",
  91920. inverse = "inverse",
  91921. exponential = "exponential",
  91922. }
  91923. /** @hidden */
  91924. interface IMSFTAudioEmitter_Emitter {
  91925. name?: string;
  91926. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91927. refDistance?: number;
  91928. maxDistance?: number;
  91929. rolloffFactor?: number;
  91930. innerAngle?: number;
  91931. outerAngle?: number;
  91932. loop?: boolean;
  91933. volume?: number;
  91934. clips: IMSFTAudioEmitter_ClipReference[];
  91935. }
  91936. /** @hidden */
  91937. const enum IMSFTAudioEmitter_AudioMimeType {
  91938. WAV = "audio/wav",
  91939. }
  91940. /** @hidden */
  91941. interface IMSFTAudioEmitter_Clip extends IProperty {
  91942. uri?: string;
  91943. bufferView?: number;
  91944. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91945. }
  91946. /** @hidden */
  91947. const enum IMSFTAudioEmitter_AnimationEventAction {
  91948. play = "play",
  91949. pause = "pause",
  91950. stop = "stop",
  91951. }
  91952. /** @hidden */
  91953. interface IMSFTAudioEmitter_AnimationEvent {
  91954. action: IMSFTAudioEmitter_AnimationEventAction;
  91955. emitter: number;
  91956. time: number;
  91957. startOffset?: number;
  91958. }
  91959. /**
  91960. * Interfaces from the MSFT_lod extension
  91961. */
  91962. /** @hidden */
  91963. interface IMSFTLOD {
  91964. ids: number[];
  91965. }
  91966. /**
  91967. * Interfaces from the EXT_meshopt_compression extension
  91968. */
  91969. /** @hidden */
  91970. interface IEXTMeshoptCompression {
  91971. buffer: number;
  91972. byteOffset?: number;
  91973. byteLength: number;
  91974. byteStride: number;
  91975. count: number;
  91976. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91977. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91978. }
  91979. }
  91980. declare module BABYLON {
  91981. /** @hidden */
  91982. export var cellPixelShader: {
  91983. name: string;
  91984. shader: string;
  91985. };
  91986. }
  91987. declare module BABYLON {
  91988. /** @hidden */
  91989. export var cellVertexShader: {
  91990. name: string;
  91991. shader: string;
  91992. };
  91993. }
  91994. declare module BABYLON {
  91995. export class CellMaterial extends BABYLON.PushMaterial {
  91996. private _diffuseTexture;
  91997. diffuseTexture: BABYLON.BaseTexture;
  91998. diffuseColor: BABYLON.Color3;
  91999. _computeHighLevel: boolean;
  92000. computeHighLevel: boolean;
  92001. private _disableLighting;
  92002. disableLighting: boolean;
  92003. private _maxSimultaneousLights;
  92004. maxSimultaneousLights: number;
  92005. constructor(name: string, scene: BABYLON.Scene);
  92006. needAlphaBlending(): boolean;
  92007. needAlphaTesting(): boolean;
  92008. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92009. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92010. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92011. getAnimatables(): BABYLON.IAnimatable[];
  92012. getActiveTextures(): BABYLON.BaseTexture[];
  92013. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92014. dispose(forceDisposeEffect?: boolean): void;
  92015. getClassName(): string;
  92016. clone(name: string): CellMaterial;
  92017. serialize(): any;
  92018. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  92019. }
  92020. }
  92021. declare module BABYLON {
  92022. export class CustomShaderStructure {
  92023. FragmentStore: string;
  92024. VertexStore: string;
  92025. constructor();
  92026. }
  92027. export class ShaderSpecialParts {
  92028. constructor();
  92029. Fragment_Begin: string;
  92030. Fragment_Definitions: string;
  92031. Fragment_MainBegin: string;
  92032. Fragment_Custom_Diffuse: string;
  92033. Fragment_Before_Lights: string;
  92034. Fragment_Before_Fog: string;
  92035. Fragment_Custom_Alpha: string;
  92036. Fragment_Before_FragColor: string;
  92037. Vertex_Begin: string;
  92038. Vertex_Definitions: string;
  92039. Vertex_MainBegin: string;
  92040. Vertex_Before_PositionUpdated: string;
  92041. Vertex_Before_NormalUpdated: string;
  92042. Vertex_After_WorldPosComputed: string;
  92043. Vertex_MainEnd: string;
  92044. }
  92045. export class CustomMaterial extends BABYLON.StandardMaterial {
  92046. static ShaderIndexer: number;
  92047. CustomParts: ShaderSpecialParts;
  92048. _isCreatedShader: boolean;
  92049. _createdShaderName: string;
  92050. _customUniform: string[];
  92051. _newUniforms: string[];
  92052. _newUniformInstances: {
  92053. [name: string]: any;
  92054. };
  92055. _newSamplerInstances: {
  92056. [name: string]: BABYLON.Texture;
  92057. };
  92058. _customAttributes: string[];
  92059. FragmentShader: string;
  92060. VertexShader: string;
  92061. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92062. ReviewUniform(name: string, arr: string[]): string[];
  92063. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  92064. constructor(name: string, scene: BABYLON.Scene);
  92065. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  92066. AddAttribute(name: string): CustomMaterial;
  92067. Fragment_Begin(shaderPart: string): CustomMaterial;
  92068. Fragment_Definitions(shaderPart: string): CustomMaterial;
  92069. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  92070. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  92071. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  92072. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  92073. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  92074. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  92075. Vertex_Begin(shaderPart: string): CustomMaterial;
  92076. Vertex_Definitions(shaderPart: string): CustomMaterial;
  92077. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  92078. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  92079. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  92080. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  92081. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  92082. }
  92083. }
  92084. declare module BABYLON {
  92085. export class ShaderAlebdoParts {
  92086. constructor();
  92087. Fragment_Begin: string;
  92088. Fragment_Definitions: string;
  92089. Fragment_MainBegin: string;
  92090. Fragment_Custom_Albedo: string;
  92091. Fragment_Before_Lights: string;
  92092. Fragment_Custom_MetallicRoughness: string;
  92093. Fragment_Custom_MicroSurface: string;
  92094. Fragment_Before_Fog: string;
  92095. Fragment_Custom_Alpha: string;
  92096. Fragment_Before_FragColor: string;
  92097. Vertex_Begin: string;
  92098. Vertex_Definitions: string;
  92099. Vertex_MainBegin: string;
  92100. Vertex_Before_PositionUpdated: string;
  92101. Vertex_Before_NormalUpdated: string;
  92102. Vertex_After_WorldPosComputed: string;
  92103. Vertex_MainEnd: string;
  92104. }
  92105. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  92106. static ShaderIndexer: number;
  92107. CustomParts: ShaderAlebdoParts;
  92108. _isCreatedShader: boolean;
  92109. _createdShaderName: string;
  92110. _customUniform: string[];
  92111. _newUniforms: string[];
  92112. _newUniformInstances: {
  92113. [name: string]: any;
  92114. };
  92115. _newSamplerInstances: {
  92116. [name: string]: BABYLON.Texture;
  92117. };
  92118. _customAttributes: string[];
  92119. FragmentShader: string;
  92120. VertexShader: string;
  92121. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  92122. ReviewUniform(name: string, arr: string[]): string[];
  92123. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[], options?: BABYLON.ICustomShaderNameResolveOptions): string;
  92124. constructor(name: string, scene: BABYLON.Scene);
  92125. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  92126. AddAttribute(name: string): PBRCustomMaterial;
  92127. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  92128. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  92129. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  92130. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  92131. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  92132. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  92133. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  92134. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  92135. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  92136. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  92137. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  92138. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  92139. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  92140. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  92141. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  92142. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  92143. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  92144. }
  92145. }
  92146. declare module BABYLON {
  92147. /** @hidden */
  92148. export var firePixelShader: {
  92149. name: string;
  92150. shader: string;
  92151. };
  92152. }
  92153. declare module BABYLON {
  92154. /** @hidden */
  92155. export var fireVertexShader: {
  92156. name: string;
  92157. shader: string;
  92158. };
  92159. }
  92160. declare module BABYLON {
  92161. export class FireMaterial extends BABYLON.PushMaterial {
  92162. private _diffuseTexture;
  92163. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92164. private _distortionTexture;
  92165. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92166. private _opacityTexture;
  92167. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  92168. diffuseColor: BABYLON.Color3;
  92169. speed: number;
  92170. private _scaledDiffuse;
  92171. private _lastTime;
  92172. constructor(name: string, scene: BABYLON.Scene);
  92173. needAlphaBlending(): boolean;
  92174. needAlphaTesting(): boolean;
  92175. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92176. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92177. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92178. getAnimatables(): BABYLON.IAnimatable[];
  92179. getActiveTextures(): BABYLON.BaseTexture[];
  92180. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92181. getClassName(): string;
  92182. dispose(forceDisposeEffect?: boolean): void;
  92183. clone(name: string): FireMaterial;
  92184. serialize(): any;
  92185. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  92186. }
  92187. }
  92188. declare module BABYLON {
  92189. /** @hidden */
  92190. export var furPixelShader: {
  92191. name: string;
  92192. shader: string;
  92193. };
  92194. }
  92195. declare module BABYLON {
  92196. /** @hidden */
  92197. export var furVertexShader: {
  92198. name: string;
  92199. shader: string;
  92200. };
  92201. }
  92202. declare module BABYLON {
  92203. export class FurMaterial extends BABYLON.PushMaterial {
  92204. private _diffuseTexture;
  92205. diffuseTexture: BABYLON.BaseTexture;
  92206. private _heightTexture;
  92207. heightTexture: BABYLON.BaseTexture;
  92208. diffuseColor: BABYLON.Color3;
  92209. furLength: number;
  92210. furAngle: number;
  92211. furColor: BABYLON.Color3;
  92212. furOffset: number;
  92213. furSpacing: number;
  92214. furGravity: BABYLON.Vector3;
  92215. furSpeed: number;
  92216. furDensity: number;
  92217. furOcclusion: number;
  92218. furTexture: BABYLON.DynamicTexture;
  92219. private _disableLighting;
  92220. disableLighting: boolean;
  92221. private _maxSimultaneousLights;
  92222. maxSimultaneousLights: number;
  92223. highLevelFur: boolean;
  92224. _meshes: BABYLON.AbstractMesh[];
  92225. private _furTime;
  92226. constructor(name: string, scene: BABYLON.Scene);
  92227. get furTime(): number;
  92228. set furTime(furTime: number);
  92229. needAlphaBlending(): boolean;
  92230. needAlphaTesting(): boolean;
  92231. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92232. updateFur(): void;
  92233. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92234. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92235. getAnimatables(): BABYLON.IAnimatable[];
  92236. getActiveTextures(): BABYLON.BaseTexture[];
  92237. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92238. dispose(forceDisposeEffect?: boolean): void;
  92239. clone(name: string): FurMaterial;
  92240. serialize(): any;
  92241. getClassName(): string;
  92242. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  92243. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  92244. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  92245. }
  92246. }
  92247. declare module BABYLON {
  92248. /** @hidden */
  92249. export var gradientPixelShader: {
  92250. name: string;
  92251. shader: string;
  92252. };
  92253. }
  92254. declare module BABYLON {
  92255. /** @hidden */
  92256. export var gradientVertexShader: {
  92257. name: string;
  92258. shader: string;
  92259. };
  92260. }
  92261. declare module BABYLON {
  92262. export class GradientMaterial extends BABYLON.PushMaterial {
  92263. private _maxSimultaneousLights;
  92264. maxSimultaneousLights: number;
  92265. topColor: BABYLON.Color3;
  92266. topColorAlpha: number;
  92267. bottomColor: BABYLON.Color3;
  92268. bottomColorAlpha: number;
  92269. offset: number;
  92270. scale: number;
  92271. smoothness: number;
  92272. private _disableLighting;
  92273. disableLighting: boolean;
  92274. constructor(name: string, scene: BABYLON.Scene);
  92275. needAlphaBlending(): boolean;
  92276. needAlphaTesting(): boolean;
  92277. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92278. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92279. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92280. getAnimatables(): BABYLON.IAnimatable[];
  92281. dispose(forceDisposeEffect?: boolean): void;
  92282. clone(name: string): GradientMaterial;
  92283. serialize(): any;
  92284. getClassName(): string;
  92285. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  92286. }
  92287. }
  92288. declare module BABYLON {
  92289. /** @hidden */
  92290. export var gridPixelShader: {
  92291. name: string;
  92292. shader: string;
  92293. };
  92294. }
  92295. declare module BABYLON {
  92296. /** @hidden */
  92297. export var gridVertexShader: {
  92298. name: string;
  92299. shader: string;
  92300. };
  92301. }
  92302. declare module BABYLON {
  92303. /**
  92304. * The grid materials allows you to wrap any shape with a grid.
  92305. * Colors are customizable.
  92306. */
  92307. export class GridMaterial extends BABYLON.PushMaterial {
  92308. /**
  92309. * Main color of the grid (e.g. between lines)
  92310. */
  92311. mainColor: BABYLON.Color3;
  92312. /**
  92313. * Color of the grid lines.
  92314. */
  92315. lineColor: BABYLON.Color3;
  92316. /**
  92317. * The scale of the grid compared to unit.
  92318. */
  92319. gridRatio: number;
  92320. /**
  92321. * Allows setting an offset for the grid lines.
  92322. */
  92323. gridOffset: BABYLON.Vector3;
  92324. /**
  92325. * The frequency of thicker lines.
  92326. */
  92327. majorUnitFrequency: number;
  92328. /**
  92329. * The visibility of minor units in the grid.
  92330. */
  92331. minorUnitVisibility: number;
  92332. /**
  92333. * The grid opacity outside of the lines.
  92334. */
  92335. opacity: number;
  92336. /**
  92337. * Determine RBG output is premultiplied by alpha value.
  92338. */
  92339. preMultiplyAlpha: boolean;
  92340. private _opacityTexture;
  92341. opacityTexture: BABYLON.BaseTexture;
  92342. private _gridControl;
  92343. /**
  92344. * constructor
  92345. * @param name The name given to the material in order to identify it afterwards.
  92346. * @param scene The scene the material is used in.
  92347. */
  92348. constructor(name: string, scene: BABYLON.Scene);
  92349. /**
  92350. * Returns wehter or not the grid requires alpha blending.
  92351. */
  92352. needAlphaBlending(): boolean;
  92353. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92354. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92355. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92356. /**
  92357. * Dispose the material and its associated resources.
  92358. * @param forceDisposeEffect will also dispose the used effect when true
  92359. */
  92360. dispose(forceDisposeEffect?: boolean): void;
  92361. clone(name: string): GridMaterial;
  92362. serialize(): any;
  92363. getClassName(): string;
  92364. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  92365. }
  92366. }
  92367. declare module BABYLON {
  92368. /** @hidden */
  92369. export var lavaPixelShader: {
  92370. name: string;
  92371. shader: string;
  92372. };
  92373. }
  92374. declare module BABYLON {
  92375. /** @hidden */
  92376. export var lavaVertexShader: {
  92377. name: string;
  92378. shader: string;
  92379. };
  92380. }
  92381. declare module BABYLON {
  92382. export class LavaMaterial extends BABYLON.PushMaterial {
  92383. private _diffuseTexture;
  92384. diffuseTexture: BABYLON.BaseTexture;
  92385. noiseTexture: BABYLON.BaseTexture;
  92386. fogColor: BABYLON.Color3;
  92387. speed: number;
  92388. movingSpeed: number;
  92389. lowFrequencySpeed: number;
  92390. fogDensity: number;
  92391. private _lastTime;
  92392. diffuseColor: BABYLON.Color3;
  92393. private _disableLighting;
  92394. disableLighting: boolean;
  92395. private _unlit;
  92396. unlit: boolean;
  92397. private _maxSimultaneousLights;
  92398. maxSimultaneousLights: number;
  92399. private _scaledDiffuse;
  92400. constructor(name: string, scene: BABYLON.Scene);
  92401. needAlphaBlending(): boolean;
  92402. needAlphaTesting(): boolean;
  92403. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92404. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92405. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92406. getAnimatables(): BABYLON.IAnimatable[];
  92407. getActiveTextures(): BABYLON.BaseTexture[];
  92408. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92409. dispose(forceDisposeEffect?: boolean): void;
  92410. clone(name: string): LavaMaterial;
  92411. serialize(): any;
  92412. getClassName(): string;
  92413. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  92414. }
  92415. }
  92416. declare module BABYLON {
  92417. /** @hidden */
  92418. export var mixPixelShader: {
  92419. name: string;
  92420. shader: string;
  92421. };
  92422. }
  92423. declare module BABYLON {
  92424. /** @hidden */
  92425. export var mixVertexShader: {
  92426. name: string;
  92427. shader: string;
  92428. };
  92429. }
  92430. declare module BABYLON {
  92431. export class MixMaterial extends BABYLON.PushMaterial {
  92432. /**
  92433. * Mix textures
  92434. */
  92435. private _mixTexture1;
  92436. mixTexture1: BABYLON.BaseTexture;
  92437. private _mixTexture2;
  92438. mixTexture2: BABYLON.BaseTexture;
  92439. /**
  92440. * Diffuse textures
  92441. */
  92442. private _diffuseTexture1;
  92443. diffuseTexture1: BABYLON.Texture;
  92444. private _diffuseTexture2;
  92445. diffuseTexture2: BABYLON.Texture;
  92446. private _diffuseTexture3;
  92447. diffuseTexture3: BABYLON.Texture;
  92448. private _diffuseTexture4;
  92449. diffuseTexture4: BABYLON.Texture;
  92450. private _diffuseTexture5;
  92451. diffuseTexture5: BABYLON.Texture;
  92452. private _diffuseTexture6;
  92453. diffuseTexture6: BABYLON.Texture;
  92454. private _diffuseTexture7;
  92455. diffuseTexture7: BABYLON.Texture;
  92456. private _diffuseTexture8;
  92457. diffuseTexture8: BABYLON.Texture;
  92458. /**
  92459. * Uniforms
  92460. */
  92461. diffuseColor: BABYLON.Color3;
  92462. specularColor: BABYLON.Color3;
  92463. specularPower: number;
  92464. private _disableLighting;
  92465. disableLighting: boolean;
  92466. private _maxSimultaneousLights;
  92467. maxSimultaneousLights: number;
  92468. constructor(name: string, scene: BABYLON.Scene);
  92469. needAlphaBlending(): boolean;
  92470. needAlphaTesting(): boolean;
  92471. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92472. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92473. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92474. getAnimatables(): BABYLON.IAnimatable[];
  92475. getActiveTextures(): BABYLON.BaseTexture[];
  92476. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92477. dispose(forceDisposeEffect?: boolean): void;
  92478. clone(name: string): MixMaterial;
  92479. serialize(): any;
  92480. getClassName(): string;
  92481. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  92482. }
  92483. }
  92484. declare module BABYLON {
  92485. /** @hidden */
  92486. export var normalPixelShader: {
  92487. name: string;
  92488. shader: string;
  92489. };
  92490. }
  92491. declare module BABYLON {
  92492. /** @hidden */
  92493. export var normalVertexShader: {
  92494. name: string;
  92495. shader: string;
  92496. };
  92497. }
  92498. declare module BABYLON {
  92499. export class NormalMaterial extends BABYLON.PushMaterial {
  92500. private _diffuseTexture;
  92501. diffuseTexture: BABYLON.BaseTexture;
  92502. diffuseColor: BABYLON.Color3;
  92503. private _disableLighting;
  92504. disableLighting: boolean;
  92505. private _maxSimultaneousLights;
  92506. maxSimultaneousLights: number;
  92507. constructor(name: string, scene: BABYLON.Scene);
  92508. needAlphaBlending(): boolean;
  92509. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  92510. needAlphaTesting(): boolean;
  92511. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92512. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92513. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92514. getAnimatables(): BABYLON.IAnimatable[];
  92515. getActiveTextures(): BABYLON.BaseTexture[];
  92516. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92517. dispose(forceDisposeEffect?: boolean): void;
  92518. clone(name: string): NormalMaterial;
  92519. serialize(): any;
  92520. getClassName(): string;
  92521. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  92522. }
  92523. }
  92524. declare module BABYLON {
  92525. /** @hidden */
  92526. export var shadowOnlyPixelShader: {
  92527. name: string;
  92528. shader: string;
  92529. };
  92530. }
  92531. declare module BABYLON {
  92532. /** @hidden */
  92533. export var shadowOnlyVertexShader: {
  92534. name: string;
  92535. shader: string;
  92536. };
  92537. }
  92538. declare module BABYLON {
  92539. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  92540. private _activeLight;
  92541. private _needAlphaBlending;
  92542. constructor(name: string, scene: BABYLON.Scene);
  92543. shadowColor: BABYLON.Color3;
  92544. needAlphaBlending(): boolean;
  92545. needAlphaTesting(): boolean;
  92546. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92547. get activeLight(): BABYLON.IShadowLight;
  92548. set activeLight(light: BABYLON.IShadowLight);
  92549. private _getFirstShadowLightForMesh;
  92550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92552. clone(name: string): ShadowOnlyMaterial;
  92553. serialize(): any;
  92554. getClassName(): string;
  92555. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  92556. }
  92557. }
  92558. declare module BABYLON {
  92559. /** @hidden */
  92560. export var simplePixelShader: {
  92561. name: string;
  92562. shader: string;
  92563. };
  92564. }
  92565. declare module BABYLON {
  92566. /** @hidden */
  92567. export var simpleVertexShader: {
  92568. name: string;
  92569. shader: string;
  92570. };
  92571. }
  92572. declare module BABYLON {
  92573. export class SimpleMaterial extends BABYLON.PushMaterial {
  92574. private _diffuseTexture;
  92575. diffuseTexture: BABYLON.BaseTexture;
  92576. diffuseColor: BABYLON.Color3;
  92577. private _disableLighting;
  92578. disableLighting: boolean;
  92579. private _maxSimultaneousLights;
  92580. maxSimultaneousLights: number;
  92581. constructor(name: string, scene: BABYLON.Scene);
  92582. needAlphaBlending(): boolean;
  92583. needAlphaTesting(): boolean;
  92584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92585. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92587. getAnimatables(): BABYLON.IAnimatable[];
  92588. getActiveTextures(): BABYLON.BaseTexture[];
  92589. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92590. dispose(forceDisposeEffect?: boolean): void;
  92591. clone(name: string): SimpleMaterial;
  92592. serialize(): any;
  92593. getClassName(): string;
  92594. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  92595. }
  92596. }
  92597. declare module BABYLON {
  92598. /** @hidden */
  92599. export var skyPixelShader: {
  92600. name: string;
  92601. shader: string;
  92602. };
  92603. }
  92604. declare module BABYLON {
  92605. /** @hidden */
  92606. export var skyVertexShader: {
  92607. name: string;
  92608. shader: string;
  92609. };
  92610. }
  92611. declare module BABYLON {
  92612. /**
  92613. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  92614. * @see https://doc.babylonjs.com/extensions/sky
  92615. */
  92616. export class SkyMaterial extends BABYLON.PushMaterial {
  92617. /**
  92618. * Defines the overall luminance of sky in interval ]0, 1[.
  92619. */
  92620. luminance: number;
  92621. /**
  92622. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  92623. */
  92624. turbidity: number;
  92625. /**
  92626. * Defines the sky appearance (light intensity).
  92627. */
  92628. rayleigh: number;
  92629. /**
  92630. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  92631. */
  92632. mieCoefficient: number;
  92633. /**
  92634. * Defines the amount of haze particles following the Mie scattering theory.
  92635. */
  92636. mieDirectionalG: number;
  92637. /**
  92638. * Defines the distance of the sun according to the active scene camera.
  92639. */
  92640. distance: number;
  92641. /**
  92642. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  92643. * "inclined".
  92644. */
  92645. inclination: number;
  92646. /**
  92647. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  92648. * an object direction and a reference direction.
  92649. */
  92650. azimuth: number;
  92651. /**
  92652. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  92653. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  92654. */
  92655. sunPosition: BABYLON.Vector3;
  92656. /**
  92657. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  92658. * .sunPosition property.
  92659. */
  92660. useSunPosition: boolean;
  92661. /**
  92662. * Defines an offset vector used to get a horizon offset.
  92663. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  92664. */
  92665. cameraOffset: BABYLON.Vector3;
  92666. /**
  92667. * Defines the vector the skyMaterial should consider as up. (default is BABYLON.Vector3(0, 1, 0) as returned by BABYLON.Vector3.Up())
  92668. */
  92669. up: BABYLON.Vector3;
  92670. private _cameraPosition;
  92671. private _skyOrientation;
  92672. /**
  92673. * Instantiates a new sky material.
  92674. * This material allows to create dynamic and texture free
  92675. * effects for skyboxes by taking care of the atmosphere state.
  92676. * @see https://doc.babylonjs.com/extensions/sky
  92677. * @param name Define the name of the material in the scene
  92678. * @param scene Define the scene the material belong to
  92679. */
  92680. constructor(name: string, scene: BABYLON.Scene);
  92681. /**
  92682. * Specifies if the material will require alpha blending
  92683. * @returns a boolean specifying if alpha blending is needed
  92684. */
  92685. needAlphaBlending(): boolean;
  92686. /**
  92687. * Specifies if this material should be rendered in alpha test mode
  92688. * @returns false as the sky material doesn't need alpha testing.
  92689. */
  92690. needAlphaTesting(): boolean;
  92691. /**
  92692. * Get the texture used for alpha test purpose.
  92693. * @returns null as the sky material has no texture.
  92694. */
  92695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92696. /**
  92697. * Get if the submesh is ready to be used and all its information available.
  92698. * Child classes can use it to update shaders
  92699. * @param mesh defines the mesh to check
  92700. * @param subMesh defines which submesh to check
  92701. * @param useInstances specifies that instances should be used
  92702. * @returns a boolean indicating that the submesh is ready or not
  92703. */
  92704. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92705. /**
  92706. * Binds the submesh to this material by preparing the effect and shader to draw
  92707. * @param world defines the world transformation matrix
  92708. * @param mesh defines the mesh containing the submesh
  92709. * @param subMesh defines the submesh to bind the material to
  92710. */
  92711. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92712. /**
  92713. * Get the list of animatables in the material.
  92714. * @returns the list of animatables object used in the material
  92715. */
  92716. getAnimatables(): BABYLON.IAnimatable[];
  92717. /**
  92718. * Disposes the material
  92719. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92720. */
  92721. dispose(forceDisposeEffect?: boolean): void;
  92722. /**
  92723. * Makes a duplicate of the material, and gives it a new name
  92724. * @param name defines the new name for the duplicated material
  92725. * @returns the cloned material
  92726. */
  92727. clone(name: string): SkyMaterial;
  92728. /**
  92729. * Serializes this material in a JSON representation
  92730. * @returns the serialized material object
  92731. */
  92732. serialize(): any;
  92733. /**
  92734. * Gets the current class name of the material e.g. "SkyMaterial"
  92735. * Mainly use in serialization.
  92736. * @returns the class name
  92737. */
  92738. getClassName(): string;
  92739. /**
  92740. * Creates a sky material from parsed material data
  92741. * @param source defines the JSON representation of the material
  92742. * @param scene defines the hosting scene
  92743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92744. * @returns a new sky material
  92745. */
  92746. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92747. }
  92748. }
  92749. declare module BABYLON {
  92750. /** @hidden */
  92751. export var terrainPixelShader: {
  92752. name: string;
  92753. shader: string;
  92754. };
  92755. }
  92756. declare module BABYLON {
  92757. /** @hidden */
  92758. export var terrainVertexShader: {
  92759. name: string;
  92760. shader: string;
  92761. };
  92762. }
  92763. declare module BABYLON {
  92764. export class TerrainMaterial extends BABYLON.PushMaterial {
  92765. private _mixTexture;
  92766. mixTexture: BABYLON.BaseTexture;
  92767. private _diffuseTexture1;
  92768. diffuseTexture1: BABYLON.Texture;
  92769. private _diffuseTexture2;
  92770. diffuseTexture2: BABYLON.Texture;
  92771. private _diffuseTexture3;
  92772. diffuseTexture3: BABYLON.Texture;
  92773. private _bumpTexture1;
  92774. bumpTexture1: BABYLON.Texture;
  92775. private _bumpTexture2;
  92776. bumpTexture2: BABYLON.Texture;
  92777. private _bumpTexture3;
  92778. bumpTexture3: BABYLON.Texture;
  92779. diffuseColor: BABYLON.Color3;
  92780. specularColor: BABYLON.Color3;
  92781. specularPower: number;
  92782. private _disableLighting;
  92783. disableLighting: boolean;
  92784. private _maxSimultaneousLights;
  92785. maxSimultaneousLights: number;
  92786. constructor(name: string, scene: BABYLON.Scene);
  92787. needAlphaBlending(): boolean;
  92788. needAlphaTesting(): boolean;
  92789. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92790. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92791. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92792. getAnimatables(): BABYLON.IAnimatable[];
  92793. getActiveTextures(): BABYLON.BaseTexture[];
  92794. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92795. dispose(forceDisposeEffect?: boolean): void;
  92796. clone(name: string): TerrainMaterial;
  92797. serialize(): any;
  92798. getClassName(): string;
  92799. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92800. }
  92801. }
  92802. declare module BABYLON {
  92803. /** @hidden */
  92804. export var triplanarPixelShader: {
  92805. name: string;
  92806. shader: string;
  92807. };
  92808. }
  92809. declare module BABYLON {
  92810. /** @hidden */
  92811. export var triplanarVertexShader: {
  92812. name: string;
  92813. shader: string;
  92814. };
  92815. }
  92816. declare module BABYLON {
  92817. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92818. mixTexture: BABYLON.BaseTexture;
  92819. private _diffuseTextureX;
  92820. diffuseTextureX: BABYLON.BaseTexture;
  92821. private _diffuseTextureY;
  92822. diffuseTextureY: BABYLON.BaseTexture;
  92823. private _diffuseTextureZ;
  92824. diffuseTextureZ: BABYLON.BaseTexture;
  92825. private _normalTextureX;
  92826. normalTextureX: BABYLON.BaseTexture;
  92827. private _normalTextureY;
  92828. normalTextureY: BABYLON.BaseTexture;
  92829. private _normalTextureZ;
  92830. normalTextureZ: BABYLON.BaseTexture;
  92831. tileSize: number;
  92832. diffuseColor: BABYLON.Color3;
  92833. specularColor: BABYLON.Color3;
  92834. specularPower: number;
  92835. private _disableLighting;
  92836. disableLighting: boolean;
  92837. private _maxSimultaneousLights;
  92838. maxSimultaneousLights: number;
  92839. constructor(name: string, scene: BABYLON.Scene);
  92840. needAlphaBlending(): boolean;
  92841. needAlphaTesting(): boolean;
  92842. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92843. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92844. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92845. getAnimatables(): BABYLON.IAnimatable[];
  92846. getActiveTextures(): BABYLON.BaseTexture[];
  92847. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92848. dispose(forceDisposeEffect?: boolean): void;
  92849. clone(name: string): TriPlanarMaterial;
  92850. serialize(): any;
  92851. getClassName(): string;
  92852. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92853. }
  92854. }
  92855. declare module BABYLON {
  92856. /** @hidden */
  92857. export var waterPixelShader: {
  92858. name: string;
  92859. shader: string;
  92860. };
  92861. }
  92862. declare module BABYLON {
  92863. /** @hidden */
  92864. export var waterVertexShader: {
  92865. name: string;
  92866. shader: string;
  92867. };
  92868. }
  92869. declare module BABYLON {
  92870. export class WaterMaterial extends BABYLON.PushMaterial {
  92871. renderTargetSize: BABYLON.Vector2;
  92872. private _bumpTexture;
  92873. bumpTexture: BABYLON.BaseTexture;
  92874. diffuseColor: BABYLON.Color3;
  92875. specularColor: BABYLON.Color3;
  92876. specularPower: number;
  92877. private _disableLighting;
  92878. disableLighting: boolean;
  92879. private _maxSimultaneousLights;
  92880. maxSimultaneousLights: number;
  92881. /**
  92882. * Defines the wind force.
  92883. */
  92884. windForce: number;
  92885. /**
  92886. * Defines the direction of the wind in the plane (X, Z).
  92887. */
  92888. windDirection: BABYLON.Vector2;
  92889. /**
  92890. * Defines the height of the waves.
  92891. */
  92892. waveHeight: number;
  92893. /**
  92894. * Defines the bump height related to the bump map.
  92895. */
  92896. bumpHeight: number;
  92897. /**
  92898. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92899. */
  92900. private _bumpSuperimpose;
  92901. bumpSuperimpose: boolean;
  92902. /**
  92903. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92904. */
  92905. private _fresnelSeparate;
  92906. fresnelSeparate: boolean;
  92907. /**
  92908. * Defines wether or not bump Wwves modify the reflection.
  92909. */
  92910. private _bumpAffectsReflection;
  92911. bumpAffectsReflection: boolean;
  92912. /**
  92913. * Defines the water color blended with the refraction (near).
  92914. */
  92915. waterColor: BABYLON.Color3;
  92916. /**
  92917. * Defines the blend factor related to the water color.
  92918. */
  92919. colorBlendFactor: number;
  92920. /**
  92921. * Defines the water color blended with the reflection (far).
  92922. */
  92923. waterColor2: BABYLON.Color3;
  92924. /**
  92925. * Defines the blend factor related to the water color (reflection, far).
  92926. */
  92927. colorBlendFactor2: number;
  92928. /**
  92929. * Defines the maximum length of a wave.
  92930. */
  92931. waveLength: number;
  92932. /**
  92933. * Defines the waves speed.
  92934. */
  92935. waveSpeed: number;
  92936. /**
  92937. * 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.
  92938. */
  92939. waveCount: number;
  92940. /**
  92941. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92942. * will avoid calculating useless pixels in the pixel shader of the water material.
  92943. */
  92944. disableClipPlane: boolean;
  92945. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92946. private _mesh;
  92947. private _refractionRTT;
  92948. private _reflectionRTT;
  92949. private _reflectionTransform;
  92950. private _lastTime;
  92951. private _lastDeltaTime;
  92952. private _useLogarithmicDepth;
  92953. private _waitingRenderList;
  92954. private _imageProcessingConfiguration;
  92955. private _imageProcessingObserver;
  92956. /**
  92957. * Gets a boolean indicating that current material needs to register RTT
  92958. */
  92959. get hasRenderTargetTextures(): boolean;
  92960. /**
  92961. * Constructor
  92962. */
  92963. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92964. get useLogarithmicDepth(): boolean;
  92965. set useLogarithmicDepth(value: boolean);
  92966. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92967. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92968. addToRenderList(node: any): void;
  92969. enableRenderTargets(enable: boolean): void;
  92970. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92971. get renderTargetsEnabled(): boolean;
  92972. needAlphaBlending(): boolean;
  92973. needAlphaTesting(): boolean;
  92974. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92975. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92976. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92977. private _createRenderTargets;
  92978. getAnimatables(): BABYLON.IAnimatable[];
  92979. getActiveTextures(): BABYLON.BaseTexture[];
  92980. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92981. dispose(forceDisposeEffect?: boolean): void;
  92982. clone(name: string): WaterMaterial;
  92983. serialize(): any;
  92984. getClassName(): string;
  92985. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92986. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92987. }
  92988. }
  92989. declare module BABYLON {
  92990. /** @hidden */
  92991. export var asciiartPixelShader: {
  92992. name: string;
  92993. shader: string;
  92994. };
  92995. }
  92996. declare module BABYLON {
  92997. /**
  92998. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92999. *
  93000. * It basically takes care rendering the font front the given font size to a texture.
  93001. * This is used later on in the postprocess.
  93002. */
  93003. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  93004. private _font;
  93005. private _text;
  93006. private _charSize;
  93007. /**
  93008. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93009. */
  93010. get charSize(): number;
  93011. /**
  93012. * Create a new instance of the Ascii Art FontTexture class
  93013. * @param name the name of the texture
  93014. * @param font the font to use, use the W3C CSS notation
  93015. * @param text the caracter set to use in the rendering.
  93016. * @param scene the scene that owns the texture
  93017. */
  93018. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93019. /**
  93020. * Gets the max char width of a font.
  93021. * @param font the font to use, use the W3C CSS notation
  93022. * @return the max char width
  93023. */
  93024. private getFontWidth;
  93025. /**
  93026. * Gets the max char height of a font.
  93027. * @param font the font to use, use the W3C CSS notation
  93028. * @return the max char height
  93029. */
  93030. private getFontHeight;
  93031. /**
  93032. * Clones the current AsciiArtTexture.
  93033. * @return the clone of the texture.
  93034. */
  93035. clone(): AsciiArtFontTexture;
  93036. /**
  93037. * Parses a json object representing the texture and returns an instance of it.
  93038. * @param source the source JSON representation
  93039. * @param scene the scene to create the texture for
  93040. * @return the parsed texture
  93041. */
  93042. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  93043. }
  93044. /**
  93045. * Option available in the Ascii Art Post Process.
  93046. */
  93047. export interface IAsciiArtPostProcessOptions {
  93048. /**
  93049. * The font to use following the w3c font definition.
  93050. */
  93051. font?: string;
  93052. /**
  93053. * The character set to use in the postprocess.
  93054. */
  93055. characterSet?: string;
  93056. /**
  93057. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93058. * This number is defined between 0 and 1;
  93059. */
  93060. mixToTile?: number;
  93061. /**
  93062. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93063. * This number is defined between 0 and 1;
  93064. */
  93065. mixToNormal?: number;
  93066. }
  93067. /**
  93068. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  93069. *
  93070. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93071. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  93072. */
  93073. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  93074. /**
  93075. * The font texture used to render the char in the post process.
  93076. */
  93077. private _asciiArtFontTexture;
  93078. /**
  93079. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  93080. * This number is defined between 0 and 1;
  93081. */
  93082. mixToTile: number;
  93083. /**
  93084. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  93085. * This number is defined between 0 and 1;
  93086. */
  93087. mixToNormal: number;
  93088. /**
  93089. * Instantiates a new Ascii Art Post Process.
  93090. * @param name the name to give to the postprocess
  93091. * @camera the camera to apply the post process to.
  93092. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  93093. */
  93094. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  93095. }
  93096. }
  93097. declare module BABYLON {
  93098. /** @hidden */
  93099. export var digitalrainPixelShader: {
  93100. name: string;
  93101. shader: string;
  93102. };
  93103. }
  93104. declare module BABYLON {
  93105. /**
  93106. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  93107. *
  93108. * It basically takes care rendering the font front the given font size to a texture.
  93109. * This is used later on in the postprocess.
  93110. */
  93111. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  93112. private _font;
  93113. private _text;
  93114. private _charSize;
  93115. /**
  93116. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  93117. */
  93118. get charSize(): number;
  93119. /**
  93120. * Create a new instance of the Digital Rain FontTexture class
  93121. * @param name the name of the texture
  93122. * @param font the font to use, use the W3C CSS notation
  93123. * @param text the caracter set to use in the rendering.
  93124. * @param scene the scene that owns the texture
  93125. */
  93126. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  93127. /**
  93128. * Gets the max char width of a font.
  93129. * @param font the font to use, use the W3C CSS notation
  93130. * @return the max char width
  93131. */
  93132. private getFontWidth;
  93133. /**
  93134. * Gets the max char height of a font.
  93135. * @param font the font to use, use the W3C CSS notation
  93136. * @return the max char height
  93137. */
  93138. private getFontHeight;
  93139. /**
  93140. * Clones the current DigitalRainFontTexture.
  93141. * @return the clone of the texture.
  93142. */
  93143. clone(): DigitalRainFontTexture;
  93144. /**
  93145. * Parses a json object representing the texture and returns an instance of it.
  93146. * @param source the source JSON representation
  93147. * @param scene the scene to create the texture for
  93148. * @return the parsed texture
  93149. */
  93150. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  93151. }
  93152. /**
  93153. * Option available in the Digital Rain Post Process.
  93154. */
  93155. export interface IDigitalRainPostProcessOptions {
  93156. /**
  93157. * The font to use following the w3c font definition.
  93158. */
  93159. font?: string;
  93160. /**
  93161. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93162. * This number is defined between 0 and 1;
  93163. */
  93164. mixToTile?: number;
  93165. /**
  93166. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93167. * This number is defined between 0 and 1;
  93168. */
  93169. mixToNormal?: number;
  93170. }
  93171. /**
  93172. * DigitalRainPostProcess helps rendering everithing in digital rain.
  93173. *
  93174. * Simmply add it to your scene and let the nerd that lives in you have fun.
  93175. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  93176. */
  93177. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  93178. /**
  93179. * The font texture used to render the char in the post process.
  93180. */
  93181. private _digitalRainFontTexture;
  93182. /**
  93183. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  93184. * This number is defined between 0 and 1;
  93185. */
  93186. mixToTile: number;
  93187. /**
  93188. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  93189. * This number is defined between 0 and 1;
  93190. */
  93191. mixToNormal: number;
  93192. /**
  93193. * Instantiates a new Digital Rain Post Process.
  93194. * @param name the name to give to the postprocess
  93195. * @camera the camera to apply the post process to.
  93196. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  93197. */
  93198. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  93199. }
  93200. }
  93201. declare module BABYLON {
  93202. /** @hidden */
  93203. export var brickProceduralTexturePixelShader: {
  93204. name: string;
  93205. shader: string;
  93206. };
  93207. }
  93208. declare module BABYLON {
  93209. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  93210. private _numberOfBricksHeight;
  93211. private _numberOfBricksWidth;
  93212. private _jointColor;
  93213. private _brickColor;
  93214. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93215. updateShaderUniforms(): void;
  93216. get numberOfBricksHeight(): number;
  93217. set numberOfBricksHeight(value: number);
  93218. get numberOfBricksWidth(): number;
  93219. set numberOfBricksWidth(value: number);
  93220. get jointColor(): BABYLON.Color3;
  93221. set jointColor(value: BABYLON.Color3);
  93222. get brickColor(): BABYLON.Color3;
  93223. set brickColor(value: BABYLON.Color3);
  93224. /**
  93225. * Serializes this brick procedural texture
  93226. * @returns a serialized brick procedural texture object
  93227. */
  93228. serialize(): any;
  93229. /**
  93230. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  93231. * @param parsedTexture defines parsed texture data
  93232. * @param scene defines the current scene
  93233. * @param rootUrl defines the root URL containing brick procedural texture information
  93234. * @returns a parsed Brick Procedural BABYLON.Texture
  93235. */
  93236. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  93237. }
  93238. }
  93239. declare module BABYLON {
  93240. /** @hidden */
  93241. export var cloudProceduralTexturePixelShader: {
  93242. name: string;
  93243. shader: string;
  93244. };
  93245. }
  93246. declare module BABYLON {
  93247. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  93248. private _skyColor;
  93249. private _cloudColor;
  93250. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93251. updateShaderUniforms(): void;
  93252. get skyColor(): BABYLON.Color4;
  93253. set skyColor(value: BABYLON.Color4);
  93254. get cloudColor(): BABYLON.Color4;
  93255. set cloudColor(value: BABYLON.Color4);
  93256. /**
  93257. * Serializes this cloud procedural texture
  93258. * @returns a serialized cloud procedural texture object
  93259. */
  93260. serialize(): any;
  93261. /**
  93262. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  93263. * @param parsedTexture defines parsed texture data
  93264. * @param scene defines the current scene
  93265. * @param rootUrl defines the root URL containing cloud procedural texture information
  93266. * @returns a parsed Cloud Procedural BABYLON.Texture
  93267. */
  93268. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  93269. }
  93270. }
  93271. declare module BABYLON {
  93272. /** @hidden */
  93273. export var fireProceduralTexturePixelShader: {
  93274. name: string;
  93275. shader: string;
  93276. };
  93277. }
  93278. declare module BABYLON {
  93279. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  93280. private _time;
  93281. private _speed;
  93282. private _autoGenerateTime;
  93283. private _fireColors;
  93284. private _alphaThreshold;
  93285. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93286. updateShaderUniforms(): void;
  93287. render(useCameraPostProcess?: boolean): void;
  93288. static get PurpleFireColors(): BABYLON.Color3[];
  93289. static get GreenFireColors(): BABYLON.Color3[];
  93290. static get RedFireColors(): BABYLON.Color3[];
  93291. static get BlueFireColors(): BABYLON.Color3[];
  93292. get autoGenerateTime(): boolean;
  93293. set autoGenerateTime(value: boolean);
  93294. get fireColors(): BABYLON.Color3[];
  93295. set fireColors(value: BABYLON.Color3[]);
  93296. get time(): number;
  93297. set time(value: number);
  93298. get speed(): BABYLON.Vector2;
  93299. set speed(value: BABYLON.Vector2);
  93300. get alphaThreshold(): number;
  93301. set alphaThreshold(value: number);
  93302. /**
  93303. * Serializes this fire procedural texture
  93304. * @returns a serialized fire procedural texture object
  93305. */
  93306. serialize(): any;
  93307. /**
  93308. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  93309. * @param parsedTexture defines parsed texture data
  93310. * @param scene defines the current scene
  93311. * @param rootUrl defines the root URL containing fire procedural texture information
  93312. * @returns a parsed Fire Procedural BABYLON.Texture
  93313. */
  93314. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /** @hidden */
  93319. export var grassProceduralTexturePixelShader: {
  93320. name: string;
  93321. shader: string;
  93322. };
  93323. }
  93324. declare module BABYLON {
  93325. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  93326. private _grassColors;
  93327. private _groundColor;
  93328. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93329. updateShaderUniforms(): void;
  93330. get grassColors(): BABYLON.Color3[];
  93331. set grassColors(value: BABYLON.Color3[]);
  93332. get groundColor(): BABYLON.Color3;
  93333. set groundColor(value: BABYLON.Color3);
  93334. /**
  93335. * Serializes this grass procedural texture
  93336. * @returns a serialized grass procedural texture object
  93337. */
  93338. serialize(): any;
  93339. /**
  93340. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  93341. * @param parsedTexture defines parsed texture data
  93342. * @param scene defines the current scene
  93343. * @param rootUrl defines the root URL containing grass procedural texture information
  93344. * @returns a parsed Grass Procedural BABYLON.Texture
  93345. */
  93346. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /** @hidden */
  93351. export var marbleProceduralTexturePixelShader: {
  93352. name: string;
  93353. shader: string;
  93354. };
  93355. }
  93356. declare module BABYLON {
  93357. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  93358. private _numberOfTilesHeight;
  93359. private _numberOfTilesWidth;
  93360. private _amplitude;
  93361. private _jointColor;
  93362. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93363. updateShaderUniforms(): void;
  93364. get numberOfTilesHeight(): number;
  93365. set numberOfTilesHeight(value: number);
  93366. get amplitude(): number;
  93367. set amplitude(value: number);
  93368. get numberOfTilesWidth(): number;
  93369. set numberOfTilesWidth(value: number);
  93370. get jointColor(): BABYLON.Color3;
  93371. set jointColor(value: BABYLON.Color3);
  93372. /**
  93373. * Serializes this marble procedural texture
  93374. * @returns a serialized marble procedural texture object
  93375. */
  93376. serialize(): any;
  93377. /**
  93378. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  93379. * @param parsedTexture defines parsed texture data
  93380. * @param scene defines the current scene
  93381. * @param rootUrl defines the root URL containing marble procedural texture information
  93382. * @returns a parsed Marble Procedural BABYLON.Texture
  93383. */
  93384. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  93385. }
  93386. }
  93387. declare module BABYLON {
  93388. /** @hidden */
  93389. export var normalMapProceduralTexturePixelShader: {
  93390. name: string;
  93391. shader: string;
  93392. };
  93393. }
  93394. declare module BABYLON {
  93395. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  93396. private _baseTexture;
  93397. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93398. updateShaderUniforms(): void;
  93399. render(useCameraPostProcess?: boolean): void;
  93400. resize(size: any, generateMipMaps: any): void;
  93401. isReady(): boolean;
  93402. get baseTexture(): BABYLON.Texture;
  93403. set baseTexture(texture: BABYLON.Texture);
  93404. /**
  93405. * Serializes this normal map procedural texture
  93406. * @returns a serialized normal map procedural texture object
  93407. */
  93408. serialize(): any;
  93409. /**
  93410. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  93411. * @param parsedTexture defines parsed texture data
  93412. * @param scene defines the current scene
  93413. * @param rootUrl defines the root URL containing normal map procedural texture information
  93414. * @returns a parsed Normal Map Procedural BABYLON.Texture
  93415. */
  93416. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  93417. }
  93418. }
  93419. declare module BABYLON {
  93420. /** @hidden */
  93421. export var perlinNoiseProceduralTexturePixelShader: {
  93422. name: string;
  93423. shader: string;
  93424. };
  93425. }
  93426. declare module BABYLON {
  93427. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  93428. time: number;
  93429. timeScale: number;
  93430. translationSpeed: number;
  93431. private _currentTranslation;
  93432. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93433. updateShaderUniforms(): void;
  93434. render(useCameraPostProcess?: boolean): void;
  93435. resize(size: any, generateMipMaps: any): void;
  93436. /**
  93437. * Serializes this perlin noise procedural texture
  93438. * @returns a serialized perlin noise procedural texture object
  93439. */
  93440. serialize(): any;
  93441. /**
  93442. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  93443. * @param parsedTexture defines parsed texture data
  93444. * @param scene defines the current scene
  93445. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  93446. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  93447. */
  93448. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  93449. }
  93450. }
  93451. declare module BABYLON {
  93452. /** @hidden */
  93453. export var roadProceduralTexturePixelShader: {
  93454. name: string;
  93455. shader: string;
  93456. };
  93457. }
  93458. declare module BABYLON {
  93459. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  93460. private _roadColor;
  93461. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93462. updateShaderUniforms(): void;
  93463. get roadColor(): BABYLON.Color3;
  93464. set roadColor(value: BABYLON.Color3);
  93465. /**
  93466. * Serializes this road procedural texture
  93467. * @returns a serialized road procedural texture object
  93468. */
  93469. serialize(): any;
  93470. /**
  93471. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  93472. * @param parsedTexture defines parsed texture data
  93473. * @param scene defines the current scene
  93474. * @param rootUrl defines the root URL containing road procedural texture information
  93475. * @returns a parsed Road Procedural BABYLON.Texture
  93476. */
  93477. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  93478. }
  93479. }
  93480. declare module BABYLON {
  93481. /** @hidden */
  93482. export var starfieldProceduralTexturePixelShader: {
  93483. name: string;
  93484. shader: string;
  93485. };
  93486. }
  93487. declare module BABYLON {
  93488. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  93489. private _time;
  93490. private _alpha;
  93491. private _beta;
  93492. private _zoom;
  93493. private _formuparam;
  93494. private _stepsize;
  93495. private _tile;
  93496. private _brightness;
  93497. private _darkmatter;
  93498. private _distfading;
  93499. private _saturation;
  93500. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93501. updateShaderUniforms(): void;
  93502. get time(): number;
  93503. set time(value: number);
  93504. get alpha(): number;
  93505. set alpha(value: number);
  93506. get beta(): number;
  93507. set beta(value: number);
  93508. get formuparam(): number;
  93509. set formuparam(value: number);
  93510. get stepsize(): number;
  93511. set stepsize(value: number);
  93512. get zoom(): number;
  93513. set zoom(value: number);
  93514. get tile(): number;
  93515. set tile(value: number);
  93516. get brightness(): number;
  93517. set brightness(value: number);
  93518. get darkmatter(): number;
  93519. set darkmatter(value: number);
  93520. get distfading(): number;
  93521. set distfading(value: number);
  93522. get saturation(): number;
  93523. set saturation(value: number);
  93524. /**
  93525. * Serializes this starfield procedural texture
  93526. * @returns a serialized starfield procedural texture object
  93527. */
  93528. serialize(): any;
  93529. /**
  93530. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  93531. * @param parsedTexture defines parsed texture data
  93532. * @param scene defines the current scene
  93533. * @param rootUrl defines the root URL containing startfield procedural texture information
  93534. * @returns a parsed Starfield Procedural BABYLON.Texture
  93535. */
  93536. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  93537. }
  93538. }
  93539. declare module BABYLON {
  93540. /** @hidden */
  93541. export var woodProceduralTexturePixelShader: {
  93542. name: string;
  93543. shader: string;
  93544. };
  93545. }
  93546. declare module BABYLON {
  93547. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  93548. private _ampScale;
  93549. private _woodColor;
  93550. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  93551. updateShaderUniforms(): void;
  93552. get ampScale(): number;
  93553. set ampScale(value: number);
  93554. get woodColor(): BABYLON.Color3;
  93555. set woodColor(value: BABYLON.Color3);
  93556. /**
  93557. * Serializes this wood procedural texture
  93558. * @returns a serialized wood procedural texture object
  93559. */
  93560. serialize(): any;
  93561. /**
  93562. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  93563. * @param parsedTexture defines parsed texture data
  93564. * @param scene defines the current scene
  93565. * @param rootUrl defines the root URL containing wood procedural texture information
  93566. * @returns a parsed Wood Procedural BABYLON.Texture
  93567. */
  93568. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  93569. }
  93570. }